72dd3c3171289ed72ca8e499c6257c4abc7a684b
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) {
25         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
26         CHECK(ordinal_meth != NULL);
27 }
28
29 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
30 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
31 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
32 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
33
34 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
35 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
36 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
37
38 typedef jlongArray int64_tArray;
39 typedef jbyteArray int8_tArray;
40 typedef jshortArray int16_tArray;
41
42 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
43         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
44         char* conv_buf = MALLOC(len + 1, "str conv buf");
45         memcpy(conv_buf, chars, len);
46         conv_buf[len] = 0;
47         jstring ret = (*env)->NewStringUTF(env, conv_buf);
48         FREE(conv_buf);
49         return ret;
50 }
51 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
52         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
53         char* newchars = MALLOC(str_len + 1, "String chars");
54         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
55         memcpy(newchars, jchars, str_len);
56         newchars[str_len] = 0;
57         (*env)->ReleaseStringUTFChars(env, str, jchars);
58         LDKStr res = {
59                 .chars = newchars,
60                 .len = str_len,
61                 .chars_is_owned = true
62         };
63         return res;
64 }
65
66 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
67         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
68 }
69 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
70         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
71 }
72 #include "version.c"
73 static jclass arr_of_B_clz = NULL;
74 static jclass String_clz = NULL;
75 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
76         arr_of_B_clz = (*env)->FindClass(env, "[B");
77         CHECK(arr_of_B_clz != NULL);
78         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
79         String_clz = (*env)->FindClass(env, "java/lang/String");
80         CHECK(String_clz != NULL);
81         String_clz = (*env)->NewGlobalRef(env, String_clz);
82 }
83 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
84
85 static inline void* untag_ptr(uint64_t ptr) {
86         if (ptr < 4096) return (void*)ptr;
87         if (sizeof(void*) == 4) {
88                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
89                 return (void*)(uintptr_t)ptr;
90         } else {
91                 // For 64-bit systems, assume the top byte is used for tagging, then
92                 // use bit 9 ^ bit 10.
93                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
94                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
95 #ifdef LDK_DEBUG_BUILD
96                 // On debug builds we also use the 11th bit as a debug flag
97                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
98                 CHECK(tenth_bit != eleventh_bit);
99                 p ^= 1ULL << 53;
100 #endif
101                 return (void*)p;
102         }
103 }
104 static inline bool ptr_is_owned(uint64_t ptr) {
105         if(ptr < 4096) return true;
106         if (sizeof(void*) == 4) {
107                 return ptr & (1ULL << 32);
108         } else {
109                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
110                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
111 #ifdef LDK_DEBUG_BUILD
112                 // On debug builds we also use the 11th bit as a debug flag
113                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
114                 CHECK(tenth_bit != eleventh_bit);
115 #endif
116                 return (ninth_bit ^ tenth_bit) ? true : false;
117         }
118 }
119 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
120         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
121         if (sizeof(void*) == 4) {
122                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
123         } else {
124                 CHECK(sizeof(uintptr_t) == 8);
125                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
126                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
127 #ifdef LDK_DEBUG_BUILD
128                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
129                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
130                 CHECK(ninth_bit == tenth_bit);
131                 CHECK(ninth_bit == eleventh_bit);
132                 t ^= 1ULL << 53;
133 #endif
134                 CHECK(ptr_is_owned(t) == is_owned);
135                 CHECK(untag_ptr(t) == ptr);
136                 return t;
137         }
138 }
139
140 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
141         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
142         if (UNLIKELY((*env)->ExceptionCheck(env))) {
143                 (*env)->ExceptionDescribe(env);
144                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
145         }
146         switch (ord) {
147                 case 0: return LDKCOption_NoneZ_Some;
148                 case 1: return LDKCOption_NoneZ_None;
149         }
150         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
151         abort(); // Unreachable, but will let the compiler know we don't return here
152 }
153 static jclass COption_NoneZ_class = NULL;
154 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
155 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
156 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
157         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
158         CHECK(COption_NoneZ_class != NULL);
159         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
160         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
161         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
162         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
163 }
164 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
165         switch (val) {
166                 case LDKCOption_NoneZ_Some:
167                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
168                 case LDKCOption_NoneZ_None:
169                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
170                 default: abort();
171         }
172 }
173
174 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_java(JNIEnv *env, jclass clz) {
175         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
176         if (UNLIKELY((*env)->ExceptionCheck(env))) {
177                 (*env)->ExceptionDescribe(env);
178                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
179         }
180         switch (ord) {
181                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
182                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
183                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
184         }
185         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
186         abort(); // Unreachable, but will let the compiler know we don't return here
187 }
188 static jclass ChannelMonitorUpdateStatus_class = NULL;
189 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
190 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
191 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
192 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
193         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
194         CHECK(ChannelMonitorUpdateStatus_class != NULL);
195         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
196         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
197         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
198         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
199         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
200         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
201 }
202 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
203         switch (val) {
204                 case LDKChannelMonitorUpdateStatus_Completed:
205                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
206                 case LDKChannelMonitorUpdateStatus_InProgress:
207                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
208                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
209                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
210                 default: abort();
211         }
212 }
213
214 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
215         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
216         if (UNLIKELY((*env)->ExceptionCheck(env))) {
217                 (*env)->ExceptionDescribe(env);
218                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
219         }
220         switch (ord) {
221                 case 0: return LDKConfirmationTarget_Background;
222                 case 1: return LDKConfirmationTarget_Normal;
223                 case 2: return LDKConfirmationTarget_HighPriority;
224         }
225         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
226         abort(); // Unreachable, but will let the compiler know we don't return here
227 }
228 static jclass ConfirmationTarget_class = NULL;
229 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
230 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
231 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
232 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
233         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
234         CHECK(ConfirmationTarget_class != NULL);
235         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
236         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
237         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
238         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
239         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
240         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
241 }
242 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
243         switch (val) {
244                 case LDKConfirmationTarget_Background:
245                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
246                 case LDKConfirmationTarget_Normal:
247                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
248                 case LDKConfirmationTarget_HighPriority:
249                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
250                 default: abort();
251         }
252 }
253
254 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
255         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
256         if (UNLIKELY((*env)->ExceptionCheck(env))) {
257                 (*env)->ExceptionDescribe(env);
258                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
259         }
260         switch (ord) {
261                 case 0: return LDKCreationError_DescriptionTooLong;
262                 case 1: return LDKCreationError_RouteTooLong;
263                 case 2: return LDKCreationError_TimestampOutOfBounds;
264                 case 3: return LDKCreationError_InvalidAmount;
265                 case 4: return LDKCreationError_MissingRouteHints;
266                 case 5: return LDKCreationError_MinFinalCltvExpiryDeltaTooShort;
267         }
268         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
269         abort(); // Unreachable, but will let the compiler know we don't return here
270 }
271 static jclass CreationError_class = NULL;
272 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
273 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
274 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
275 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
276 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
277 static jfieldID CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
279         CreationError_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(CreationError_class != NULL);
281         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
282         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
283         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
284         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
285         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
286         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
287         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
288         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
289         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
290         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
291         CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MinFinalCltvExpiryDeltaTooShort", "Lorg/ldk/enums/CreationError;");
292         CHECK(CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort != NULL);
293 }
294 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
295         switch (val) {
296                 case LDKCreationError_DescriptionTooLong:
297                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
298                 case LDKCreationError_RouteTooLong:
299                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
300                 case LDKCreationError_TimestampOutOfBounds:
301                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
302                 case LDKCreationError_InvalidAmount:
303                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
304                 case LDKCreationError_MissingRouteHints:
305                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
306                 case LDKCreationError_MinFinalCltvExpiryDeltaTooShort:
307                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort);
308                 default: abort();
309         }
310 }
311
312 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
313         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
314         if (UNLIKELY((*env)->ExceptionCheck(env))) {
315                 (*env)->ExceptionDescribe(env);
316                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
317         }
318         switch (ord) {
319                 case 0: return LDKCurrency_Bitcoin;
320                 case 1: return LDKCurrency_BitcoinTestnet;
321                 case 2: return LDKCurrency_Regtest;
322                 case 3: return LDKCurrency_Simnet;
323                 case 4: return LDKCurrency_Signet;
324         }
325         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
326         abort(); // Unreachable, but will let the compiler know we don't return here
327 }
328 static jclass Currency_class = NULL;
329 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
330 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
331 static jfieldID Currency_LDKCurrency_Regtest = NULL;
332 static jfieldID Currency_LDKCurrency_Simnet = NULL;
333 static jfieldID Currency_LDKCurrency_Signet = NULL;
334 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
335         Currency_class = (*env)->NewGlobalRef(env, clz);
336         CHECK(Currency_class != NULL);
337         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
338         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
339         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
340         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
341         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
342         CHECK(Currency_LDKCurrency_Regtest != NULL);
343         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
344         CHECK(Currency_LDKCurrency_Simnet != NULL);
345         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
346         CHECK(Currency_LDKCurrency_Signet != NULL);
347 }
348 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
349         switch (val) {
350                 case LDKCurrency_Bitcoin:
351                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
352                 case LDKCurrency_BitcoinTestnet:
353                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
354                 case LDKCurrency_Regtest:
355                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
356                 case LDKCurrency_Simnet:
357                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
358                 case LDKCurrency_Signet:
359                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
360                 default: abort();
361         }
362 }
363
364 static inline LDKFailureCode LDKFailureCode_from_java(JNIEnv *env, jclass clz) {
365         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
366         if (UNLIKELY((*env)->ExceptionCheck(env))) {
367                 (*env)->ExceptionDescribe(env);
368                 (*env)->FatalError(env, "A call to FailureCode.ordinal() from rust threw an exception.");
369         }
370         switch (ord) {
371                 case 0: return LDKFailureCode_TemporaryNodeFailure;
372                 case 1: return LDKFailureCode_RequiredNodeFeatureMissing;
373                 case 2: return LDKFailureCode_IncorrectOrUnknownPaymentDetails;
374         }
375         (*env)->FatalError(env, "A call to FailureCode.ordinal() from rust returned an invalid value.");
376         abort(); // Unreachable, but will let the compiler know we don't return here
377 }
378 static jclass FailureCode_class = NULL;
379 static jfieldID FailureCode_LDKFailureCode_TemporaryNodeFailure = NULL;
380 static jfieldID FailureCode_LDKFailureCode_RequiredNodeFeatureMissing = NULL;
381 static jfieldID FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails = NULL;
382 JNIEXPORT void JNICALL Java_org_ldk_enums_FailureCode_init (JNIEnv *env, jclass clz) {
383         FailureCode_class = (*env)->NewGlobalRef(env, clz);
384         CHECK(FailureCode_class != NULL);
385         FailureCode_LDKFailureCode_TemporaryNodeFailure = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_TemporaryNodeFailure", "Lorg/ldk/enums/FailureCode;");
386         CHECK(FailureCode_LDKFailureCode_TemporaryNodeFailure != NULL);
387         FailureCode_LDKFailureCode_RequiredNodeFeatureMissing = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_RequiredNodeFeatureMissing", "Lorg/ldk/enums/FailureCode;");
388         CHECK(FailureCode_LDKFailureCode_RequiredNodeFeatureMissing != NULL);
389         FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_IncorrectOrUnknownPaymentDetails", "Lorg/ldk/enums/FailureCode;");
390         CHECK(FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails != NULL);
391 }
392 static inline jclass LDKFailureCode_to_java(JNIEnv *env, LDKFailureCode val) {
393         switch (val) {
394                 case LDKFailureCode_TemporaryNodeFailure:
395                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_TemporaryNodeFailure);
396                 case LDKFailureCode_RequiredNodeFeatureMissing:
397                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_RequiredNodeFeatureMissing);
398                 case LDKFailureCode_IncorrectOrUnknownPaymentDetails:
399                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails);
400                 default: abort();
401         }
402 }
403
404 static inline LDKHTLCClaim LDKHTLCClaim_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKHTLCClaim_OfferedTimeout;
412                 case 1: return LDKHTLCClaim_OfferedPreimage;
413                 case 2: return LDKHTLCClaim_AcceptedTimeout;
414                 case 3: return LDKHTLCClaim_AcceptedPreimage;
415                 case 4: return LDKHTLCClaim_Revocation;
416         }
417         (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust returned an invalid value.");
418         abort(); // Unreachable, but will let the compiler know we don't return here
419 }
420 static jclass HTLCClaim_class = NULL;
421 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedTimeout = NULL;
422 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedPreimage = NULL;
423 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedTimeout = NULL;
424 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedPreimage = NULL;
425 static jfieldID HTLCClaim_LDKHTLCClaim_Revocation = NULL;
426 JNIEXPORT void JNICALL Java_org_ldk_enums_HTLCClaim_init (JNIEnv *env, jclass clz) {
427         HTLCClaim_class = (*env)->NewGlobalRef(env, clz);
428         CHECK(HTLCClaim_class != NULL);
429         HTLCClaim_LDKHTLCClaim_OfferedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedTimeout", "Lorg/ldk/enums/HTLCClaim;");
430         CHECK(HTLCClaim_LDKHTLCClaim_OfferedTimeout != NULL);
431         HTLCClaim_LDKHTLCClaim_OfferedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedPreimage", "Lorg/ldk/enums/HTLCClaim;");
432         CHECK(HTLCClaim_LDKHTLCClaim_OfferedPreimage != NULL);
433         HTLCClaim_LDKHTLCClaim_AcceptedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedTimeout", "Lorg/ldk/enums/HTLCClaim;");
434         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedTimeout != NULL);
435         HTLCClaim_LDKHTLCClaim_AcceptedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedPreimage", "Lorg/ldk/enums/HTLCClaim;");
436         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedPreimage != NULL);
437         HTLCClaim_LDKHTLCClaim_Revocation = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_Revocation", "Lorg/ldk/enums/HTLCClaim;");
438         CHECK(HTLCClaim_LDKHTLCClaim_Revocation != NULL);
439 }
440 static inline jclass LDKHTLCClaim_to_java(JNIEnv *env, LDKHTLCClaim val) {
441         switch (val) {
442                 case LDKHTLCClaim_OfferedTimeout:
443                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedTimeout);
444                 case LDKHTLCClaim_OfferedPreimage:
445                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedPreimage);
446                 case LDKHTLCClaim_AcceptedTimeout:
447                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedTimeout);
448                 case LDKHTLCClaim_AcceptedPreimage:
449                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedPreimage);
450                 case LDKHTLCClaim_Revocation:
451                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_Revocation);
452                 default: abort();
453         }
454 }
455
456 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
457         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
458         if (UNLIKELY((*env)->ExceptionCheck(env))) {
459                 (*env)->ExceptionDescribe(env);
460                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
461         }
462         switch (ord) {
463                 case 0: return LDKIOError_NotFound;
464                 case 1: return LDKIOError_PermissionDenied;
465                 case 2: return LDKIOError_ConnectionRefused;
466                 case 3: return LDKIOError_ConnectionReset;
467                 case 4: return LDKIOError_ConnectionAborted;
468                 case 5: return LDKIOError_NotConnected;
469                 case 6: return LDKIOError_AddrInUse;
470                 case 7: return LDKIOError_AddrNotAvailable;
471                 case 8: return LDKIOError_BrokenPipe;
472                 case 9: return LDKIOError_AlreadyExists;
473                 case 10: return LDKIOError_WouldBlock;
474                 case 11: return LDKIOError_InvalidInput;
475                 case 12: return LDKIOError_InvalidData;
476                 case 13: return LDKIOError_TimedOut;
477                 case 14: return LDKIOError_WriteZero;
478                 case 15: return LDKIOError_Interrupted;
479                 case 16: return LDKIOError_Other;
480                 case 17: return LDKIOError_UnexpectedEof;
481         }
482         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
483         abort(); // Unreachable, but will let the compiler know we don't return here
484 }
485 static jclass IOError_class = NULL;
486 static jfieldID IOError_LDKIOError_NotFound = NULL;
487 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
488 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
489 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
490 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
491 static jfieldID IOError_LDKIOError_NotConnected = NULL;
492 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
493 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
494 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
495 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
496 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
497 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
498 static jfieldID IOError_LDKIOError_InvalidData = NULL;
499 static jfieldID IOError_LDKIOError_TimedOut = NULL;
500 static jfieldID IOError_LDKIOError_WriteZero = NULL;
501 static jfieldID IOError_LDKIOError_Interrupted = NULL;
502 static jfieldID IOError_LDKIOError_Other = NULL;
503 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
504 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
505         IOError_class = (*env)->NewGlobalRef(env, clz);
506         CHECK(IOError_class != NULL);
507         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
508         CHECK(IOError_LDKIOError_NotFound != NULL);
509         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
510         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
511         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
512         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
513         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
514         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
515         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
516         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
517         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
518         CHECK(IOError_LDKIOError_NotConnected != NULL);
519         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
520         CHECK(IOError_LDKIOError_AddrInUse != NULL);
521         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
522         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
523         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
524         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
525         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
526         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
527         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
528         CHECK(IOError_LDKIOError_WouldBlock != NULL);
529         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
530         CHECK(IOError_LDKIOError_InvalidInput != NULL);
531         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
532         CHECK(IOError_LDKIOError_InvalidData != NULL);
533         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
534         CHECK(IOError_LDKIOError_TimedOut != NULL);
535         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
536         CHECK(IOError_LDKIOError_WriteZero != NULL);
537         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
538         CHECK(IOError_LDKIOError_Interrupted != NULL);
539         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
540         CHECK(IOError_LDKIOError_Other != NULL);
541         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
542         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
543 }
544 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
545         switch (val) {
546                 case LDKIOError_NotFound:
547                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
548                 case LDKIOError_PermissionDenied:
549                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
550                 case LDKIOError_ConnectionRefused:
551                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
552                 case LDKIOError_ConnectionReset:
553                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
554                 case LDKIOError_ConnectionAborted:
555                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
556                 case LDKIOError_NotConnected:
557                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
558                 case LDKIOError_AddrInUse:
559                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
560                 case LDKIOError_AddrNotAvailable:
561                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
562                 case LDKIOError_BrokenPipe:
563                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
564                 case LDKIOError_AlreadyExists:
565                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
566                 case LDKIOError_WouldBlock:
567                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
568                 case LDKIOError_InvalidInput:
569                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
570                 case LDKIOError_InvalidData:
571                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
572                 case LDKIOError_TimedOut:
573                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
574                 case LDKIOError_WriteZero:
575                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
576                 case LDKIOError_Interrupted:
577                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
578                 case LDKIOError_Other:
579                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
580                 case LDKIOError_UnexpectedEof:
581                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
582                 default: abort();
583         }
584 }
585
586 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
587         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
588         if (UNLIKELY((*env)->ExceptionCheck(env))) {
589                 (*env)->ExceptionDescribe(env);
590                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
591         }
592         switch (ord) {
593                 case 0: return LDKLevel_Gossip;
594                 case 1: return LDKLevel_Trace;
595                 case 2: return LDKLevel_Debug;
596                 case 3: return LDKLevel_Info;
597                 case 4: return LDKLevel_Warn;
598                 case 5: return LDKLevel_Error;
599         }
600         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
601         abort(); // Unreachable, but will let the compiler know we don't return here
602 }
603 static jclass Level_class = NULL;
604 static jfieldID Level_LDKLevel_Gossip = NULL;
605 static jfieldID Level_LDKLevel_Trace = NULL;
606 static jfieldID Level_LDKLevel_Debug = NULL;
607 static jfieldID Level_LDKLevel_Info = NULL;
608 static jfieldID Level_LDKLevel_Warn = NULL;
609 static jfieldID Level_LDKLevel_Error = NULL;
610 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
611         Level_class = (*env)->NewGlobalRef(env, clz);
612         CHECK(Level_class != NULL);
613         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
614         CHECK(Level_LDKLevel_Gossip != NULL);
615         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
616         CHECK(Level_LDKLevel_Trace != NULL);
617         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
618         CHECK(Level_LDKLevel_Debug != NULL);
619         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
620         CHECK(Level_LDKLevel_Info != NULL);
621         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
622         CHECK(Level_LDKLevel_Warn != NULL);
623         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
624         CHECK(Level_LDKLevel_Error != NULL);
625 }
626 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
627         switch (val) {
628                 case LDKLevel_Gossip:
629                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
630                 case LDKLevel_Trace:
631                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
632                 case LDKLevel_Debug:
633                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
634                 case LDKLevel_Info:
635                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
636                 case LDKLevel_Warn:
637                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
638                 case LDKLevel_Error:
639                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
640                 default: abort();
641         }
642 }
643
644 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
645         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
646         if (UNLIKELY((*env)->ExceptionCheck(env))) {
647                 (*env)->ExceptionDescribe(env);
648                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
649         }
650         switch (ord) {
651                 case 0: return LDKNetwork_Bitcoin;
652                 case 1: return LDKNetwork_Testnet;
653                 case 2: return LDKNetwork_Regtest;
654                 case 3: return LDKNetwork_Signet;
655         }
656         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
657         abort(); // Unreachable, but will let the compiler know we don't return here
658 }
659 static jclass Network_class = NULL;
660 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
661 static jfieldID Network_LDKNetwork_Testnet = NULL;
662 static jfieldID Network_LDKNetwork_Regtest = NULL;
663 static jfieldID Network_LDKNetwork_Signet = NULL;
664 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
665         Network_class = (*env)->NewGlobalRef(env, clz);
666         CHECK(Network_class != NULL);
667         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
668         CHECK(Network_LDKNetwork_Bitcoin != NULL);
669         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
670         CHECK(Network_LDKNetwork_Testnet != NULL);
671         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
672         CHECK(Network_LDKNetwork_Regtest != NULL);
673         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
674         CHECK(Network_LDKNetwork_Signet != NULL);
675 }
676 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
677         switch (val) {
678                 case LDKNetwork_Bitcoin:
679                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
680                 case LDKNetwork_Testnet:
681                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
682                 case LDKNetwork_Regtest:
683                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
684                 case LDKNetwork_Signet:
685                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
686                 default: abort();
687         }
688 }
689
690 static inline LDKPaymentFailureReason LDKPaymentFailureReason_from_java(JNIEnv *env, jclass clz) {
691         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
692         if (UNLIKELY((*env)->ExceptionCheck(env))) {
693                 (*env)->ExceptionDescribe(env);
694                 (*env)->FatalError(env, "A call to PaymentFailureReason.ordinal() from rust threw an exception.");
695         }
696         switch (ord) {
697                 case 0: return LDKPaymentFailureReason_RecipientRejected;
698                 case 1: return LDKPaymentFailureReason_UserAbandoned;
699                 case 2: return LDKPaymentFailureReason_RetriesExhausted;
700                 case 3: return LDKPaymentFailureReason_PaymentExpired;
701                 case 4: return LDKPaymentFailureReason_RouteNotFound;
702                 case 5: return LDKPaymentFailureReason_UnexpectedError;
703         }
704         (*env)->FatalError(env, "A call to PaymentFailureReason.ordinal() from rust returned an invalid value.");
705         abort(); // Unreachable, but will let the compiler know we don't return here
706 }
707 static jclass PaymentFailureReason_class = NULL;
708 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected = NULL;
709 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned = NULL;
710 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted = NULL;
711 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired = NULL;
712 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound = NULL;
713 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError = NULL;
714 JNIEXPORT void JNICALL Java_org_ldk_enums_PaymentFailureReason_init (JNIEnv *env, jclass clz) {
715         PaymentFailureReason_class = (*env)->NewGlobalRef(env, clz);
716         CHECK(PaymentFailureReason_class != NULL);
717         PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RecipientRejected", "Lorg/ldk/enums/PaymentFailureReason;");
718         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected != NULL);
719         PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_UserAbandoned", "Lorg/ldk/enums/PaymentFailureReason;");
720         CHECK(PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned != NULL);
721         PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RetriesExhausted", "Lorg/ldk/enums/PaymentFailureReason;");
722         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted != NULL);
723         PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_PaymentExpired", "Lorg/ldk/enums/PaymentFailureReason;");
724         CHECK(PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired != NULL);
725         PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RouteNotFound", "Lorg/ldk/enums/PaymentFailureReason;");
726         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound != NULL);
727         PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_UnexpectedError", "Lorg/ldk/enums/PaymentFailureReason;");
728         CHECK(PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError != NULL);
729 }
730 static inline jclass LDKPaymentFailureReason_to_java(JNIEnv *env, LDKPaymentFailureReason val) {
731         switch (val) {
732                 case LDKPaymentFailureReason_RecipientRejected:
733                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected);
734                 case LDKPaymentFailureReason_UserAbandoned:
735                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned);
736                 case LDKPaymentFailureReason_RetriesExhausted:
737                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted);
738                 case LDKPaymentFailureReason_PaymentExpired:
739                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired);
740                 case LDKPaymentFailureReason_RouteNotFound:
741                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound);
742                 case LDKPaymentFailureReason_UnexpectedError:
743                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError);
744                 default: abort();
745         }
746 }
747
748 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
749         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
751                 (*env)->ExceptionDescribe(env);
752                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
753         }
754         switch (ord) {
755                 case 0: return LDKRecipient_Node;
756                 case 1: return LDKRecipient_PhantomNode;
757         }
758         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
759         abort(); // Unreachable, but will let the compiler know we don't return here
760 }
761 static jclass Recipient_class = NULL;
762 static jfieldID Recipient_LDKRecipient_Node = NULL;
763 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
764 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
765         Recipient_class = (*env)->NewGlobalRef(env, clz);
766         CHECK(Recipient_class != NULL);
767         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
768         CHECK(Recipient_LDKRecipient_Node != NULL);
769         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
770         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
771 }
772 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
773         switch (val) {
774                 case LDKRecipient_Node:
775                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
776                 case LDKRecipient_PhantomNode:
777                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
778                 default: abort();
779         }
780 }
781
782 static inline LDKRetryableSendFailure LDKRetryableSendFailure_from_java(JNIEnv *env, jclass clz) {
783         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
784         if (UNLIKELY((*env)->ExceptionCheck(env))) {
785                 (*env)->ExceptionDescribe(env);
786                 (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust threw an exception.");
787         }
788         switch (ord) {
789                 case 0: return LDKRetryableSendFailure_PaymentExpired;
790                 case 1: return LDKRetryableSendFailure_RouteNotFound;
791                 case 2: return LDKRetryableSendFailure_DuplicatePayment;
792         }
793         (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust returned an invalid value.");
794         abort(); // Unreachable, but will let the compiler know we don't return here
795 }
796 static jclass RetryableSendFailure_class = NULL;
797 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = NULL;
798 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = NULL;
799 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = NULL;
800 JNIEXPORT void JNICALL Java_org_ldk_enums_RetryableSendFailure_init (JNIEnv *env, jclass clz) {
801         RetryableSendFailure_class = (*env)->NewGlobalRef(env, clz);
802         CHECK(RetryableSendFailure_class != NULL);
803         RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_PaymentExpired", "Lorg/ldk/enums/RetryableSendFailure;");
804         CHECK(RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired != NULL);
805         RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_RouteNotFound", "Lorg/ldk/enums/RetryableSendFailure;");
806         CHECK(RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound != NULL);
807         RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_DuplicatePayment", "Lorg/ldk/enums/RetryableSendFailure;");
808         CHECK(RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment != NULL);
809 }
810 static inline jclass LDKRetryableSendFailure_to_java(JNIEnv *env, LDKRetryableSendFailure val) {
811         switch (val) {
812                 case LDKRetryableSendFailure_PaymentExpired:
813                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired);
814                 case LDKRetryableSendFailure_RouteNotFound:
815                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound);
816                 case LDKRetryableSendFailure_DuplicatePayment:
817                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment);
818                 default: abort();
819         }
820 }
821
822 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
823         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
824         if (UNLIKELY((*env)->ExceptionCheck(env))) {
825                 (*env)->ExceptionDescribe(env);
826                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
827         }
828         switch (ord) {
829                 case 0: return LDKSecp256k1Error_IncorrectSignature;
830                 case 1: return LDKSecp256k1Error_InvalidMessage;
831                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
832                 case 3: return LDKSecp256k1Error_InvalidSignature;
833                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
834                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
835                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
836                 case 7: return LDKSecp256k1Error_InvalidTweak;
837                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
838                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
839                 case 10: return LDKSecp256k1Error_InvalidParityValue;
840         }
841         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
842         abort(); // Unreachable, but will let the compiler know we don't return here
843 }
844 static jclass Secp256k1Error_class = NULL;
845 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
846 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
847 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
848 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
849 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
850 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
851 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
852 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
853 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
854 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
855 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
856 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
857         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
858         CHECK(Secp256k1Error_class != NULL);
859         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
860         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
861         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
862         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
863         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
864         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
865         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
866         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
867         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
868         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
869         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
870         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
871         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
872         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
873         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
874         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
875         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
876         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
877         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
878         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
879         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
880         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
881 }
882 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
883         switch (val) {
884                 case LDKSecp256k1Error_IncorrectSignature:
885                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
886                 case LDKSecp256k1Error_InvalidMessage:
887                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
888                 case LDKSecp256k1Error_InvalidPublicKey:
889                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
890                 case LDKSecp256k1Error_InvalidSignature:
891                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
892                 case LDKSecp256k1Error_InvalidSecretKey:
893                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
894                 case LDKSecp256k1Error_InvalidSharedSecret:
895                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
896                 case LDKSecp256k1Error_InvalidRecoveryId:
897                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
898                 case LDKSecp256k1Error_InvalidTweak:
899                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
900                 case LDKSecp256k1Error_NotEnoughMemory:
901                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
902                 case LDKSecp256k1Error_InvalidPublicKeySum:
903                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
904                 case LDKSecp256k1Error_InvalidParityValue:
905                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
906                 default: abort();
907         }
908 }
909
910 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
911         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
912         if (UNLIKELY((*env)->ExceptionCheck(env))) {
913                 (*env)->ExceptionDescribe(env);
914                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
915         }
916         switch (ord) {
917                 case 0: return LDKSemanticError_NoPaymentHash;
918                 case 1: return LDKSemanticError_MultiplePaymentHashes;
919                 case 2: return LDKSemanticError_NoDescription;
920                 case 3: return LDKSemanticError_MultipleDescriptions;
921                 case 4: return LDKSemanticError_NoPaymentSecret;
922                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
923                 case 6: return LDKSemanticError_InvalidFeatures;
924                 case 7: return LDKSemanticError_InvalidRecoveryId;
925                 case 8: return LDKSemanticError_InvalidSignature;
926                 case 9: return LDKSemanticError_ImpreciseAmount;
927         }
928         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
929         abort(); // Unreachable, but will let the compiler know we don't return here
930 }
931 static jclass SemanticError_class = NULL;
932 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
933 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
934 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
935 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
936 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
937 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
938 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
939 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
940 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
941 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
942 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
943         SemanticError_class = (*env)->NewGlobalRef(env, clz);
944         CHECK(SemanticError_class != NULL);
945         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
946         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
947         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
948         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
949         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
950         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
951         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
952         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
953         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
954         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
955         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
956         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
957         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
958         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
959         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
960         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
961         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
962         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
963         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
964         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
965 }
966 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
967         switch (val) {
968                 case LDKSemanticError_NoPaymentHash:
969                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
970                 case LDKSemanticError_MultiplePaymentHashes:
971                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
972                 case LDKSemanticError_NoDescription:
973                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
974                 case LDKSemanticError_MultipleDescriptions:
975                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
976                 case LDKSemanticError_NoPaymentSecret:
977                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
978                 case LDKSemanticError_MultiplePaymentSecrets:
979                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
980                 case LDKSemanticError_InvalidFeatures:
981                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
982                 case LDKSemanticError_InvalidRecoveryId:
983                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
984                 case LDKSemanticError_InvalidSignature:
985                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
986                 case LDKSemanticError_ImpreciseAmount:
987                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
988                 default: abort();
989         }
990 }
991
992 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
993         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
994         if (UNLIKELY((*env)->ExceptionCheck(env))) {
995                 (*env)->ExceptionDescribe(env);
996                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
997         }
998         switch (ord) {
999                 case 0: return LDKSiPrefix_Milli;
1000                 case 1: return LDKSiPrefix_Micro;
1001                 case 2: return LDKSiPrefix_Nano;
1002                 case 3: return LDKSiPrefix_Pico;
1003         }
1004         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
1005         abort(); // Unreachable, but will let the compiler know we don't return here
1006 }
1007 static jclass SiPrefix_class = NULL;
1008 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
1009 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
1010 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
1011 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
1012 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
1013         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
1014         CHECK(SiPrefix_class != NULL);
1015         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
1016         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
1017         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
1018         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
1019         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
1020         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
1021         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
1022         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
1023 }
1024 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
1025         switch (val) {
1026                 case LDKSiPrefix_Milli:
1027                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
1028                 case LDKSiPrefix_Micro:
1029                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
1030                 case LDKSiPrefix_Nano:
1031                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
1032                 case LDKSiPrefix_Pico:
1033                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
1034                 default: abort();
1035         }
1036 }
1037
1038 static inline LDKUtxoLookupError LDKUtxoLookupError_from_java(JNIEnv *env, jclass clz) {
1039         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
1040         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1041                 (*env)->ExceptionDescribe(env);
1042                 (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust threw an exception.");
1043         }
1044         switch (ord) {
1045                 case 0: return LDKUtxoLookupError_UnknownChain;
1046                 case 1: return LDKUtxoLookupError_UnknownTx;
1047         }
1048         (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust returned an invalid value.");
1049         abort(); // Unreachable, but will let the compiler know we don't return here
1050 }
1051 static jclass UtxoLookupError_class = NULL;
1052 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownChain = NULL;
1053 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownTx = NULL;
1054 JNIEXPORT void JNICALL Java_org_ldk_enums_UtxoLookupError_init (JNIEnv *env, jclass clz) {
1055         UtxoLookupError_class = (*env)->NewGlobalRef(env, clz);
1056         CHECK(UtxoLookupError_class != NULL);
1057         UtxoLookupError_LDKUtxoLookupError_UnknownChain = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownChain", "Lorg/ldk/enums/UtxoLookupError;");
1058         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownChain != NULL);
1059         UtxoLookupError_LDKUtxoLookupError_UnknownTx = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownTx", "Lorg/ldk/enums/UtxoLookupError;");
1060         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownTx != NULL);
1061 }
1062 static inline jclass LDKUtxoLookupError_to_java(JNIEnv *env, LDKUtxoLookupError val) {
1063         switch (val) {
1064                 case LDKUtxoLookupError_UnknownChain:
1065                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownChain);
1066                 case LDKUtxoLookupError_UnknownTx:
1067                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownTx);
1068                 default: abort();
1069         }
1070 }
1071
1072 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
1073         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
1074         return ret;
1075 }
1076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
1077         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
1078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
1080         return ret_arr;
1081 }
1082
1083 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
1084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
1085         if (!ptr_is_owned(thing)) return;
1086         void* thing_ptr = untag_ptr(thing);
1087         CHECK_ACCESS(thing_ptr);
1088         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
1089         FREE(untag_ptr(thing));
1090         BigEndianScalar_free(thing_conv);
1091 }
1092
1093 static jclass LDKBech32Error_MissingSeparator_class = NULL;
1094 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
1095 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
1096 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
1097 static jclass LDKBech32Error_InvalidLength_class = NULL;
1098 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
1099 static jclass LDKBech32Error_InvalidChar_class = NULL;
1100 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
1101 static jclass LDKBech32Error_InvalidData_class = NULL;
1102 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
1103 static jclass LDKBech32Error_InvalidPadding_class = NULL;
1104 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
1105 static jclass LDKBech32Error_MixedCase_class = NULL;
1106 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
1107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
1108         LDKBech32Error_MissingSeparator_class =
1109                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
1110         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
1111         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
1112         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
1113         LDKBech32Error_InvalidChecksum_class =
1114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
1115         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
1116         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
1117         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
1118         LDKBech32Error_InvalidLength_class =
1119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
1120         CHECK(LDKBech32Error_InvalidLength_class != NULL);
1121         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
1122         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
1123         LDKBech32Error_InvalidChar_class =
1124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
1125         CHECK(LDKBech32Error_InvalidChar_class != NULL);
1126         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
1127         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1128         LDKBech32Error_InvalidData_class =
1129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1130         CHECK(LDKBech32Error_InvalidData_class != NULL);
1131         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1132         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1133         LDKBech32Error_InvalidPadding_class =
1134                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1135         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1136         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1137         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1138         LDKBech32Error_MixedCase_class =
1139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1140         CHECK(LDKBech32Error_MixedCase_class != NULL);
1141         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1142         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1143 }
1144 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1145         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1146         switch(obj->tag) {
1147                 case LDKBech32Error_MissingSeparator: {
1148                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1149                 }
1150                 case LDKBech32Error_InvalidChecksum: {
1151                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1152                 }
1153                 case LDKBech32Error_InvalidLength: {
1154                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1155                 }
1156                 case LDKBech32Error_InvalidChar: {
1157                         int32_t invalid_char_conv = obj->invalid_char;
1158                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1159                 }
1160                 case LDKBech32Error_InvalidData: {
1161                         int8_t invalid_data_conv = obj->invalid_data;
1162                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1163                 }
1164                 case LDKBech32Error_InvalidPadding: {
1165                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1166                 }
1167                 case LDKBech32Error_MixedCase: {
1168                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1169                 }
1170                 default: abort();
1171         }
1172 }
1173 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1174         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1175         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1176         return ret;
1177 }
1178 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) {
1179         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1180         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1183         CVec_u8Z_free(ret_var);
1184         return ret_arr;
1185 }
1186
1187 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) {
1188         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1189         int64_t ret_conv = TxOut_get_value(thing_conv);
1190         return ret_conv;
1191 }
1192
1193 static jclass LDKCOption_DurationZ_Some_class = NULL;
1194 static jmethodID LDKCOption_DurationZ_Some_meth = NULL;
1195 static jclass LDKCOption_DurationZ_None_class = NULL;
1196 static jmethodID LDKCOption_DurationZ_None_meth = NULL;
1197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1DurationZ_init (JNIEnv *env, jclass clz) {
1198         LDKCOption_DurationZ_Some_class =
1199                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_DurationZ$Some"));
1200         CHECK(LDKCOption_DurationZ_Some_class != NULL);
1201         LDKCOption_DurationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_DurationZ_Some_class, "<init>", "(J)V");
1202         CHECK(LDKCOption_DurationZ_Some_meth != NULL);
1203         LDKCOption_DurationZ_None_class =
1204                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_DurationZ$None"));
1205         CHECK(LDKCOption_DurationZ_None_class != NULL);
1206         LDKCOption_DurationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_DurationZ_None_class, "<init>", "()V");
1207         CHECK(LDKCOption_DurationZ_None_meth != NULL);
1208 }
1209 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1DurationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1210         LDKCOption_DurationZ *obj = (LDKCOption_DurationZ*)untag_ptr(ptr);
1211         switch(obj->tag) {
1212                 case LDKCOption_DurationZ_Some: {
1213                         int64_t some_conv = obj->some;
1214                         return (*env)->NewObject(env, LDKCOption_DurationZ_Some_class, LDKCOption_DurationZ_Some_meth, some_conv);
1215                 }
1216                 case LDKCOption_DurationZ_None: {
1217                         return (*env)->NewObject(env, LDKCOption_DurationZ_None_class, LDKCOption_DurationZ_None_meth);
1218                 }
1219                 default: abort();
1220         }
1221 }
1222 static inline LDKCVec_BlindedPathZ CVec_BlindedPathZ_clone(const LDKCVec_BlindedPathZ *orig) {
1223         LDKCVec_BlindedPathZ ret = { .data = MALLOC(sizeof(LDKBlindedPath) * orig->datalen, "LDKCVec_BlindedPathZ clone bytes"), .datalen = orig->datalen };
1224         for (size_t i = 0; i < ret.datalen; i++) {
1225                 ret.data[i] = BlindedPath_clone(&orig->data[i]);
1226         }
1227         return ret;
1228 }
1229 static jclass LDKCOption_u64Z_Some_class = NULL;
1230 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1231 static jclass LDKCOption_u64Z_None_class = NULL;
1232 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1234         LDKCOption_u64Z_Some_class =
1235                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1236         CHECK(LDKCOption_u64Z_Some_class != NULL);
1237         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1238         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1239         LDKCOption_u64Z_None_class =
1240                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1241         CHECK(LDKCOption_u64Z_None_class != NULL);
1242         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1243         CHECK(LDKCOption_u64Z_None_meth != NULL);
1244 }
1245 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1246         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
1247         switch(obj->tag) {
1248                 case LDKCOption_u64Z_Some: {
1249                         int64_t some_conv = obj->some;
1250                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1251                 }
1252                 case LDKCOption_u64Z_None: {
1253                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1254                 }
1255                 default: abort();
1256         }
1257 }
1258 static jclass LDKAPIError_APIMisuseError_class = NULL;
1259 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
1260 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
1261 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
1262 static jclass LDKAPIError_InvalidRoute_class = NULL;
1263 static jmethodID LDKAPIError_InvalidRoute_meth = NULL;
1264 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
1265 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
1266 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
1267 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
1268 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
1269 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
1270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
1271         LDKAPIError_APIMisuseError_class =
1272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
1273         CHECK(LDKAPIError_APIMisuseError_class != NULL);
1274         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
1275         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
1276         LDKAPIError_FeeRateTooHigh_class =
1277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
1278         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
1279         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
1280         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
1281         LDKAPIError_InvalidRoute_class =
1282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$InvalidRoute"));
1283         CHECK(LDKAPIError_InvalidRoute_class != NULL);
1284         LDKAPIError_InvalidRoute_meth = (*env)->GetMethodID(env, LDKAPIError_InvalidRoute_class, "<init>", "(Ljava/lang/String;)V");
1285         CHECK(LDKAPIError_InvalidRoute_meth != NULL);
1286         LDKAPIError_ChannelUnavailable_class =
1287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
1288         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
1289         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
1290         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
1291         LDKAPIError_MonitorUpdateInProgress_class =
1292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
1293         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
1294         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
1295         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
1296         LDKAPIError_IncompatibleShutdownScript_class =
1297                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
1298         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
1299         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
1300         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
1301 }
1302 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1303         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1304         switch(obj->tag) {
1305                 case LDKAPIError_APIMisuseError: {
1306                         LDKStr err_str = obj->api_misuse_error.err;
1307                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1308                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
1309                 }
1310                 case LDKAPIError_FeeRateTooHigh: {
1311                         LDKStr err_str = obj->fee_rate_too_high.err;
1312                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1313                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
1314                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
1315                 }
1316                 case LDKAPIError_InvalidRoute: {
1317                         LDKStr err_str = obj->invalid_route.err;
1318                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1319                         return (*env)->NewObject(env, LDKAPIError_InvalidRoute_class, LDKAPIError_InvalidRoute_meth, err_conv);
1320                 }
1321                 case LDKAPIError_ChannelUnavailable: {
1322                         LDKStr err_str = obj->channel_unavailable.err;
1323                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1324                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
1325                 }
1326                 case LDKAPIError_MonitorUpdateInProgress: {
1327                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
1328                 }
1329                 case LDKAPIError_IncompatibleShutdownScript: {
1330                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
1331                         int64_t script_ref = 0;
1332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
1333                         script_ref = tag_ptr(script_var.inner, false);
1334                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
1335                 }
1336                 default: abort();
1337         }
1338 }
1339 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1340 CHECK(owner->result_ok);
1341         return *owner->contents.result;
1342 }
1343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1344         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1345         CResult_NoneAPIErrorZ_get_ok(owner_conv);
1346 }
1347
1348 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1349 CHECK(!owner->result_ok);
1350         return APIError_clone(&*owner->contents.err);
1351 }
1352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1353         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1354         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
1355         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
1356         int64_t ret_ref = tag_ptr(ret_copy, true);
1357         return ret_ref;
1358 }
1359
1360 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
1361         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
1362         for (size_t i = 0; i < ret.datalen; i++) {
1363                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
1364         }
1365         return ret;
1366 }
1367 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
1368         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
1369         for (size_t i = 0; i < ret.datalen; i++) {
1370                 ret.data[i] = APIError_clone(&orig->data[i]);
1371         }
1372         return ret;
1373 }
1374 static jclass LDKCOption_CVec_u8ZZ_Some_class = NULL;
1375 static jmethodID LDKCOption_CVec_u8ZZ_Some_meth = NULL;
1376 static jclass LDKCOption_CVec_u8ZZ_None_class = NULL;
1377 static jmethodID LDKCOption_CVec_u8ZZ_None_meth = NULL;
1378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1u8ZZ_init (JNIEnv *env, jclass clz) {
1379         LDKCOption_CVec_u8ZZ_Some_class =
1380                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_u8ZZ$Some"));
1381         CHECK(LDKCOption_CVec_u8ZZ_Some_class != NULL);
1382         LDKCOption_CVec_u8ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_u8ZZ_Some_class, "<init>", "([B)V");
1383         CHECK(LDKCOption_CVec_u8ZZ_Some_meth != NULL);
1384         LDKCOption_CVec_u8ZZ_None_class =
1385                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_u8ZZ$None"));
1386         CHECK(LDKCOption_CVec_u8ZZ_None_class != NULL);
1387         LDKCOption_CVec_u8ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_u8ZZ_None_class, "<init>", "()V");
1388         CHECK(LDKCOption_CVec_u8ZZ_None_meth != NULL);
1389 }
1390 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1u8ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1391         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1392         switch(obj->tag) {
1393                 case LDKCOption_CVec_u8ZZ_Some: {
1394                         LDKCVec_u8Z some_var = obj->some;
1395                         int8_tArray some_arr = (*env)->NewByteArray(env, some_var.datalen);
1396                         (*env)->SetByteArrayRegion(env, some_arr, 0, some_var.datalen, some_var.data);
1397                         return (*env)->NewObject(env, LDKCOption_CVec_u8ZZ_Some_class, LDKCOption_CVec_u8ZZ_Some_meth, some_arr);
1398                 }
1399                 case LDKCOption_CVec_u8ZZ_None: {
1400                         return (*env)->NewObject(env, LDKCOption_CVec_u8ZZ_None_class, LDKCOption_CVec_u8ZZ_None_meth);
1401                 }
1402                 default: abort();
1403         }
1404 }
1405 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1406 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1407 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1408 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1409 static jclass LDKDecodeError_InvalidValue_class = NULL;
1410 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1411 static jclass LDKDecodeError_ShortRead_class = NULL;
1412 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1413 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1414 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1415 static jclass LDKDecodeError_Io_class = NULL;
1416 static jmethodID LDKDecodeError_Io_meth = NULL;
1417 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1418 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1420         LDKDecodeError_UnknownVersion_class =
1421                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1422         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1423         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1424         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1425         LDKDecodeError_UnknownRequiredFeature_class =
1426                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1427         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1428         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1429         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1430         LDKDecodeError_InvalidValue_class =
1431                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1432         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1433         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1434         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1435         LDKDecodeError_ShortRead_class =
1436                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1437         CHECK(LDKDecodeError_ShortRead_class != NULL);
1438         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1439         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1440         LDKDecodeError_BadLengthDescriptor_class =
1441                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1442         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1443         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1444         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1445         LDKDecodeError_Io_class =
1446                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1447         CHECK(LDKDecodeError_Io_class != NULL);
1448         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1449         CHECK(LDKDecodeError_Io_meth != NULL);
1450         LDKDecodeError_UnsupportedCompression_class =
1451                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1452         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1453         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1454         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1455 }
1456 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1457         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1458         switch(obj->tag) {
1459                 case LDKDecodeError_UnknownVersion: {
1460                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1461                 }
1462                 case LDKDecodeError_UnknownRequiredFeature: {
1463                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1464                 }
1465                 case LDKDecodeError_InvalidValue: {
1466                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1467                 }
1468                 case LDKDecodeError_ShortRead: {
1469                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1470                 }
1471                 case LDKDecodeError_BadLengthDescriptor: {
1472                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1473                 }
1474                 case LDKDecodeError_Io: {
1475                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1476                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1477                 }
1478                 case LDKDecodeError_UnsupportedCompression: {
1479                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1480                 }
1481                 default: abort();
1482         }
1483 }
1484 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1485         LDKRecipientOnionFields ret = *owner->contents.result;
1486         ret.is_owned = false;
1487         return ret;
1488 }
1489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1490         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1491         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(owner_conv);
1492         int64_t ret_ref = 0;
1493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1495         return ret_ref;
1496 }
1497
1498 static inline struct LDKDecodeError CResult_RecipientOnionFieldsDecodeErrorZ_get_err(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1499 CHECK(!owner->result_ok);
1500         return DecodeError_clone(&*owner->contents.err);
1501 }
1502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1503         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1504         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1505         *ret_copy = CResult_RecipientOnionFieldsDecodeErrorZ_get_err(owner_conv);
1506         int64_t ret_ref = tag_ptr(ret_copy, true);
1507         return ret_ref;
1508 }
1509
1510 static jclass LDKCOption_HTLCClaimZ_Some_class = NULL;
1511 static jmethodID LDKCOption_HTLCClaimZ_Some_meth = NULL;
1512 static jclass LDKCOption_HTLCClaimZ_None_class = NULL;
1513 static jmethodID LDKCOption_HTLCClaimZ_None_meth = NULL;
1514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCClaimZ_init (JNIEnv *env, jclass clz) {
1515         LDKCOption_HTLCClaimZ_Some_class =
1516                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$Some"));
1517         CHECK(LDKCOption_HTLCClaimZ_Some_class != NULL);
1518         LDKCOption_HTLCClaimZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_Some_class, "<init>", "(Lorg/ldk/enums/HTLCClaim;)V");
1519         CHECK(LDKCOption_HTLCClaimZ_Some_meth != NULL);
1520         LDKCOption_HTLCClaimZ_None_class =
1521                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$None"));
1522         CHECK(LDKCOption_HTLCClaimZ_None_class != NULL);
1523         LDKCOption_HTLCClaimZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_None_class, "<init>", "()V");
1524         CHECK(LDKCOption_HTLCClaimZ_None_meth != NULL);
1525 }
1526 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCClaimZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1527         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
1528         switch(obj->tag) {
1529                 case LDKCOption_HTLCClaimZ_Some: {
1530                         jclass some_conv = LDKHTLCClaim_to_java(env, obj->some);
1531                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_Some_class, LDKCOption_HTLCClaimZ_Some_meth, some_conv);
1532                 }
1533                 case LDKCOption_HTLCClaimZ_None: {
1534                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_None_class, LDKCOption_HTLCClaimZ_None_meth);
1535                 }
1536                 default: abort();
1537         }
1538 }
1539 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1540 CHECK(owner->result_ok);
1541         return *owner->contents.result;
1542 }
1543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1544         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1545         CResult_NoneNoneZ_get_ok(owner_conv);
1546 }
1547
1548 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1549 CHECK(!owner->result_ok);
1550         return *owner->contents.err;
1551 }
1552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1553         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1554         CResult_NoneNoneZ_get_err(owner_conv);
1555 }
1556
1557 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1558         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1559         ret.is_owned = false;
1560         return ret;
1561 }
1562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1563         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1564         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1565         int64_t ret_ref = 0;
1566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1568         return ret_ref;
1569 }
1570
1571 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1572 CHECK(!owner->result_ok);
1573         return DecodeError_clone(&*owner->contents.err);
1574 }
1575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1576         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1577         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1578         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1579         int64_t ret_ref = tag_ptr(ret_copy, true);
1580         return ret_ref;
1581 }
1582
1583 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1584         LDKTxCreationKeys ret = *owner->contents.result;
1585         ret.is_owned = false;
1586         return ret;
1587 }
1588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1589         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1590         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1591         int64_t ret_ref = 0;
1592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1593         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1594         return ret_ref;
1595 }
1596
1597 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1598 CHECK(!owner->result_ok);
1599         return DecodeError_clone(&*owner->contents.err);
1600 }
1601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1602         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1603         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1604         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1605         int64_t ret_ref = tag_ptr(ret_copy, true);
1606         return ret_ref;
1607 }
1608
1609 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1610         LDKChannelPublicKeys ret = *owner->contents.result;
1611         ret.is_owned = false;
1612         return ret;
1613 }
1614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1615         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1616         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1617         int64_t ret_ref = 0;
1618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1620         return ret_ref;
1621 }
1622
1623 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1624 CHECK(!owner->result_ok);
1625         return DecodeError_clone(&*owner->contents.err);
1626 }
1627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1628         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1629         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1630         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1631         int64_t ret_ref = tag_ptr(ret_copy, true);
1632         return ret_ref;
1633 }
1634
1635 static jclass LDKCOption_u32Z_Some_class = NULL;
1636 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1637 static jclass LDKCOption_u32Z_None_class = NULL;
1638 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1640         LDKCOption_u32Z_Some_class =
1641                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1642         CHECK(LDKCOption_u32Z_Some_class != NULL);
1643         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1644         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1645         LDKCOption_u32Z_None_class =
1646                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1647         CHECK(LDKCOption_u32Z_None_class != NULL);
1648         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1649         CHECK(LDKCOption_u32Z_None_meth != NULL);
1650 }
1651 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1652         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1653         switch(obj->tag) {
1654                 case LDKCOption_u32Z_Some: {
1655                         int32_t some_conv = obj->some;
1656                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1657                 }
1658                 case LDKCOption_u32Z_None: {
1659                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1660                 }
1661                 default: abort();
1662         }
1663 }
1664 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1665         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1666         ret.is_owned = false;
1667         return ret;
1668 }
1669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1670         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1671         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1672         int64_t ret_ref = 0;
1673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1675         return ret_ref;
1676 }
1677
1678 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1679 CHECK(!owner->result_ok);
1680         return DecodeError_clone(&*owner->contents.err);
1681 }
1682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1683         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1684         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1685         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1686         int64_t ret_ref = tag_ptr(ret_copy, true);
1687         return ret_ref;
1688 }
1689
1690 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1691         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1692         ret.is_owned = false;
1693         return ret;
1694 }
1695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1696         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1697         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1698         int64_t ret_ref = 0;
1699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1701         return ret_ref;
1702 }
1703
1704 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1705 CHECK(!owner->result_ok);
1706         return DecodeError_clone(&*owner->contents.err);
1707 }
1708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1709         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1710         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1711         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1712         int64_t ret_ref = tag_ptr(ret_copy, true);
1713         return ret_ref;
1714 }
1715
1716 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1717         LDKChannelTransactionParameters ret = *owner->contents.result;
1718         ret.is_owned = false;
1719         return ret;
1720 }
1721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1722         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1723         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1724         int64_t ret_ref = 0;
1725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1727         return ret_ref;
1728 }
1729
1730 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1731 CHECK(!owner->result_ok);
1732         return DecodeError_clone(&*owner->contents.err);
1733 }
1734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1735         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1736         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1737         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1738         int64_t ret_ref = tag_ptr(ret_copy, true);
1739         return ret_ref;
1740 }
1741
1742 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1743         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1744         ret.is_owned = false;
1745         return ret;
1746 }
1747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1748         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1749         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1750         int64_t ret_ref = 0;
1751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1753         return ret_ref;
1754 }
1755
1756 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1757 CHECK(!owner->result_ok);
1758         return DecodeError_clone(&*owner->contents.err);
1759 }
1760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1761         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1762         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1763         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1764         int64_t ret_ref = tag_ptr(ret_copy, true);
1765         return ret_ref;
1766 }
1767
1768 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1769         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1770         ret.is_owned = false;
1771         return ret;
1772 }
1773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1774         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1775         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1776         int64_t ret_ref = 0;
1777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1779         return ret_ref;
1780 }
1781
1782 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1783 CHECK(!owner->result_ok);
1784         return DecodeError_clone(&*owner->contents.err);
1785 }
1786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1787         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1788         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1789         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1790         int64_t ret_ref = tag_ptr(ret_copy, true);
1791         return ret_ref;
1792 }
1793
1794 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1795         LDKTrustedClosingTransaction ret = *owner->contents.result;
1796         ret.is_owned = false;
1797         return ret;
1798 }
1799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1800         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1801         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1802         int64_t ret_ref = 0;
1803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1805         return ret_ref;
1806 }
1807
1808 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1809 CHECK(!owner->result_ok);
1810         return *owner->contents.err;
1811 }
1812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1813         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1814         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1815 }
1816
1817 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1818         LDKCommitmentTransaction ret = *owner->contents.result;
1819         ret.is_owned = false;
1820         return ret;
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1824         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1825         int64_t ret_ref = 0;
1826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1828         return ret_ref;
1829 }
1830
1831 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1832 CHECK(!owner->result_ok);
1833         return DecodeError_clone(&*owner->contents.err);
1834 }
1835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1836         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1837         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1838         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1839         int64_t ret_ref = tag_ptr(ret_copy, true);
1840         return ret_ref;
1841 }
1842
1843 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1844         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1845         ret.is_owned = false;
1846         return ret;
1847 }
1848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1849         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1850         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1851         int64_t ret_ref = 0;
1852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1853         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1854         return ret_ref;
1855 }
1856
1857 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1858 CHECK(!owner->result_ok);
1859         return *owner->contents.err;
1860 }
1861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1862         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1863         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1864 }
1865
1866 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1867 CHECK(owner->result_ok);
1868         return *owner->contents.result;
1869 }
1870 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1871         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1872         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1873         jobjectArray ret_arr = NULL;
1874         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1875         ;
1876         for (size_t i = 0; i < ret_var.datalen; i++) {
1877                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1878                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1879                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1880         }
1881         
1882         return ret_arr;
1883 }
1884
1885 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1886 CHECK(!owner->result_ok);
1887         return *owner->contents.err;
1888 }
1889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1890         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1891         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1892 }
1893
1894 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1895         LDKShutdownScript ret = *owner->contents.result;
1896         ret.is_owned = false;
1897         return ret;
1898 }
1899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1900         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1901         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1902         int64_t ret_ref = 0;
1903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1905         return ret_ref;
1906 }
1907
1908 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1909 CHECK(!owner->result_ok);
1910         return DecodeError_clone(&*owner->contents.err);
1911 }
1912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1913         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1914         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1915         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1916         int64_t ret_ref = tag_ptr(ret_copy, true);
1917         return ret_ref;
1918 }
1919
1920 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1921         LDKShutdownScript ret = *owner->contents.result;
1922         ret.is_owned = false;
1923         return ret;
1924 }
1925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1926         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1927         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1928         int64_t ret_ref = 0;
1929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1931         return ret_ref;
1932 }
1933
1934 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1935         LDKInvalidShutdownScript ret = *owner->contents.err;
1936         ret.is_owned = false;
1937         return ret;
1938 }
1939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1940         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1941         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1942         int64_t ret_ref = 0;
1943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1945         return ret_ref;
1946 }
1947
1948 static inline struct LDKBlindedPayInfo CResult_BlindedPayInfoDecodeErrorZ_get_ok(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1949         LDKBlindedPayInfo ret = *owner->contents.result;
1950         ret.is_owned = false;
1951         return ret;
1952 }
1953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1954         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1955         LDKBlindedPayInfo ret_var = CResult_BlindedPayInfoDecodeErrorZ_get_ok(owner_conv);
1956         int64_t ret_ref = 0;
1957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1959         return ret_ref;
1960 }
1961
1962 static inline struct LDKDecodeError CResult_BlindedPayInfoDecodeErrorZ_get_err(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1963 CHECK(!owner->result_ok);
1964         return DecodeError_clone(&*owner->contents.err);
1965 }
1966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1967         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1968         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1969         *ret_copy = CResult_BlindedPayInfoDecodeErrorZ_get_err(owner_conv);
1970         int64_t ret_ref = tag_ptr(ret_copy, true);
1971         return ret_ref;
1972 }
1973
1974 typedef struct LDKScore_JCalls {
1975         atomic_size_t refcnt;
1976         JavaVM *vm;
1977         jweak o;
1978         jmethodID channel_penalty_msat_meth;
1979         jmethodID payment_path_failed_meth;
1980         jmethodID payment_path_successful_meth;
1981         jmethodID probe_failed_meth;
1982         jmethodID probe_successful_meth;
1983         jmethodID write_meth;
1984 } LDKScore_JCalls;
1985 static void LDKScore_JCalls_free(void* this_arg) {
1986         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1987         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1988                 JNIEnv *env;
1989                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1990                 if (get_jenv_res == JNI_EDETACHED) {
1991                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1992                 } else {
1993                         DO_ASSERT(get_jenv_res == JNI_OK);
1994                 }
1995                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1996                 if (get_jenv_res == JNI_EDETACHED) {
1997                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1998                 }
1999                 FREE(j_calls);
2000         }
2001 }
2002 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
2003         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2004         JNIEnv *env;
2005         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2006         if (get_jenv_res == JNI_EDETACHED) {
2007                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2008         } else {
2009                 DO_ASSERT(get_jenv_res == JNI_OK);
2010         }
2011         int64_t short_channel_id_conv = short_channel_id;
2012         LDKNodeId source_var = *source;
2013         int64_t source_ref = 0;
2014         source_var = NodeId_clone(&source_var);
2015         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
2016         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
2017         LDKNodeId target_var = *target;
2018         int64_t target_ref = 0;
2019         target_var = NodeId_clone(&target_var);
2020         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
2021         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
2022         LDKChannelUsage usage_var = usage;
2023         int64_t usage_ref = 0;
2024         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
2025         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
2026         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2027         CHECK(obj != NULL);
2028         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
2029         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2030                 (*env)->ExceptionDescribe(env);
2031                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
2032         }
2033         if (get_jenv_res == JNI_EDETACHED) {
2034                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2035         }
2036         return ret;
2037 }
2038 void payment_path_failed_LDKScore_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2039         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2040         JNIEnv *env;
2041         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2042         if (get_jenv_res == JNI_EDETACHED) {
2043                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2044         } else {
2045                 DO_ASSERT(get_jenv_res == JNI_OK);
2046         }
2047         LDKPath path_var = *path;
2048         int64_t path_ref = 0;
2049         path_var = Path_clone(&path_var);
2050         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2051         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2052         int64_t short_channel_id_conv = short_channel_id;
2053         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2054         CHECK(obj != NULL);
2055         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_ref, short_channel_id_conv);
2056         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2057                 (*env)->ExceptionDescribe(env);
2058                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
2059         }
2060         if (get_jenv_res == JNI_EDETACHED) {
2061                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2062         }
2063 }
2064 void payment_path_successful_LDKScore_jcall(void* this_arg, const LDKPath * path) {
2065         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2066         JNIEnv *env;
2067         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2068         if (get_jenv_res == JNI_EDETACHED) {
2069                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2070         } else {
2071                 DO_ASSERT(get_jenv_res == JNI_OK);
2072         }
2073         LDKPath path_var = *path;
2074         int64_t path_ref = 0;
2075         path_var = Path_clone(&path_var);
2076         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2077         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2079         CHECK(obj != NULL);
2080         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_ref);
2081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2082                 (*env)->ExceptionDescribe(env);
2083                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
2084         }
2085         if (get_jenv_res == JNI_EDETACHED) {
2086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2087         }
2088 }
2089 void probe_failed_LDKScore_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2090         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2091         JNIEnv *env;
2092         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2093         if (get_jenv_res == JNI_EDETACHED) {
2094                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2095         } else {
2096                 DO_ASSERT(get_jenv_res == JNI_OK);
2097         }
2098         LDKPath path_var = *path;
2099         int64_t path_ref = 0;
2100         path_var = Path_clone(&path_var);
2101         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2102         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2103         int64_t short_channel_id_conv = short_channel_id;
2104         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2105         CHECK(obj != NULL);
2106         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_ref, short_channel_id_conv);
2107         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2108                 (*env)->ExceptionDescribe(env);
2109                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
2110         }
2111         if (get_jenv_res == JNI_EDETACHED) {
2112                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2113         }
2114 }
2115 void probe_successful_LDKScore_jcall(void* this_arg, const LDKPath * path) {
2116         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2117         JNIEnv *env;
2118         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2119         if (get_jenv_res == JNI_EDETACHED) {
2120                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2121         } else {
2122                 DO_ASSERT(get_jenv_res == JNI_OK);
2123         }
2124         LDKPath path_var = *path;
2125         int64_t path_ref = 0;
2126         path_var = Path_clone(&path_var);
2127         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2128         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2129         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2130         CHECK(obj != NULL);
2131         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_ref);
2132         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2133                 (*env)->ExceptionDescribe(env);
2134                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
2135         }
2136         if (get_jenv_res == JNI_EDETACHED) {
2137                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2138         }
2139 }
2140 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
2141         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2142         JNIEnv *env;
2143         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2144         if (get_jenv_res == JNI_EDETACHED) {
2145                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2146         } else {
2147                 DO_ASSERT(get_jenv_res == JNI_OK);
2148         }
2149         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2150         CHECK(obj != NULL);
2151         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2152         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2153                 (*env)->ExceptionDescribe(env);
2154                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
2155         }
2156         LDKCVec_u8Z ret_ref;
2157         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2158         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2159         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2160         if (get_jenv_res == JNI_EDETACHED) {
2161                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2162         }
2163         return ret_ref;
2164 }
2165 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
2166         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
2167         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2168 }
2169 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
2170         jclass c = (*env)->GetObjectClass(env, o);
2171         CHECK(c != NULL);
2172         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
2173         atomic_init(&calls->refcnt, 1);
2174         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2175         calls->o = (*env)->NewWeakGlobalRef(env, o);
2176         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
2177         CHECK(calls->channel_penalty_msat_meth != NULL);
2178         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "(JJ)V");
2179         CHECK(calls->payment_path_failed_meth != NULL);
2180         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "(J)V");
2181         CHECK(calls->payment_path_successful_meth != NULL);
2182         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "(JJ)V");
2183         CHECK(calls->probe_failed_meth != NULL);
2184         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "(J)V");
2185         CHECK(calls->probe_successful_meth != NULL);
2186         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2187         CHECK(calls->write_meth != NULL);
2188
2189         LDKScore ret = {
2190                 .this_arg = (void*) calls,
2191                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
2192                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
2193                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
2194                 .probe_failed = probe_failed_LDKScore_jcall,
2195                 .probe_successful = probe_successful_LDKScore_jcall,
2196                 .write = write_LDKScore_jcall,
2197                 .free = LDKScore_JCalls_free,
2198         };
2199         return ret;
2200 }
2201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
2202         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
2203         *res_ptr = LDKScore_init(env, clz, o);
2204         return tag_ptr(res_ptr, true);
2205 }
2206 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) {
2207         void* this_arg_ptr = untag_ptr(this_arg);
2208         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2209         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2210         LDKNodeId source_conv;
2211         source_conv.inner = untag_ptr(source);
2212         source_conv.is_owned = ptr_is_owned(source);
2213         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
2214         source_conv.is_owned = false;
2215         LDKNodeId target_conv;
2216         target_conv.inner = untag_ptr(target);
2217         target_conv.is_owned = ptr_is_owned(target);
2218         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
2219         target_conv.is_owned = false;
2220         LDKChannelUsage usage_conv;
2221         usage_conv.inner = untag_ptr(usage);
2222         usage_conv.is_owned = ptr_is_owned(usage);
2223         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
2224         usage_conv = ChannelUsage_clone(&usage_conv);
2225         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
2226         return ret_conv;
2227 }
2228
2229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int64_t short_channel_id) {
2230         void* this_arg_ptr = untag_ptr(this_arg);
2231         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2232         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2233         LDKPath path_conv;
2234         path_conv.inner = untag_ptr(path);
2235         path_conv.is_owned = ptr_is_owned(path);
2236         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2237         path_conv.is_owned = false;
2238         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2239 }
2240
2241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
2242         void* this_arg_ptr = untag_ptr(this_arg);
2243         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2244         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2245         LDKPath path_conv;
2246         path_conv.inner = untag_ptr(path);
2247         path_conv.is_owned = ptr_is_owned(path);
2248         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2249         path_conv.is_owned = false;
2250         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, &path_conv);
2251 }
2252
2253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int64_t short_channel_id) {
2254         void* this_arg_ptr = untag_ptr(this_arg);
2255         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2256         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2257         LDKPath path_conv;
2258         path_conv.inner = untag_ptr(path);
2259         path_conv.is_owned = ptr_is_owned(path);
2260         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2261         path_conv.is_owned = false;
2262         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2263 }
2264
2265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
2266         void* this_arg_ptr = untag_ptr(this_arg);
2267         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2268         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2269         LDKPath path_conv;
2270         path_conv.inner = untag_ptr(path);
2271         path_conv.is_owned = ptr_is_owned(path);
2272         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2273         path_conv.is_owned = false;
2274         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, &path_conv);
2275 }
2276
2277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2278         void* this_arg_ptr = untag_ptr(this_arg);
2279         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2280         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2281         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2282         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2283         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2284         CVec_u8Z_free(ret_var);
2285         return ret_arr;
2286 }
2287
2288 typedef struct LDKLockableScore_JCalls {
2289         atomic_size_t refcnt;
2290         JavaVM *vm;
2291         jweak o;
2292         jmethodID lock_meth;
2293 } LDKLockableScore_JCalls;
2294 static void LDKLockableScore_JCalls_free(void* this_arg) {
2295         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2296         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2297                 JNIEnv *env;
2298                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2299                 if (get_jenv_res == JNI_EDETACHED) {
2300                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2301                 } else {
2302                         DO_ASSERT(get_jenv_res == JNI_OK);
2303                 }
2304                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2305                 if (get_jenv_res == JNI_EDETACHED) {
2306                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2307                 }
2308                 FREE(j_calls);
2309         }
2310 }
2311 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2312         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2313         JNIEnv *env;
2314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2315         if (get_jenv_res == JNI_EDETACHED) {
2316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2317         } else {
2318                 DO_ASSERT(get_jenv_res == JNI_OK);
2319         }
2320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2321         CHECK(obj != NULL);
2322         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2323         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2324                 (*env)->ExceptionDescribe(env);
2325                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2326         }
2327         void* ret_ptr = untag_ptr(ret);
2328         CHECK_ACCESS(ret_ptr);
2329         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2330         if (ret_conv.free == LDKScore_JCalls_free) {
2331                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2332                 LDKScore_JCalls_cloned(&ret_conv);
2333         }// WARNING: we may need a move here but no clone is available for LDKScore
2334         
2335         if (get_jenv_res == JNI_EDETACHED) {
2336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2337         }
2338         return ret_conv;
2339 }
2340 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2341         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2342         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2343 }
2344 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2345         jclass c = (*env)->GetObjectClass(env, o);
2346         CHECK(c != NULL);
2347         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2348         atomic_init(&calls->refcnt, 1);
2349         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2350         calls->o = (*env)->NewWeakGlobalRef(env, o);
2351         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2352         CHECK(calls->lock_meth != NULL);
2353
2354         LDKLockableScore ret = {
2355                 .this_arg = (void*) calls,
2356                 .lock = lock_LDKLockableScore_jcall,
2357                 .free = LDKLockableScore_JCalls_free,
2358         };
2359         return ret;
2360 }
2361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2362         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2363         *res_ptr = LDKLockableScore_init(env, clz, o);
2364         return tag_ptr(res_ptr, true);
2365 }
2366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2367         void* this_arg_ptr = untag_ptr(this_arg);
2368         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2369         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2370         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2371         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2372         return tag_ptr(ret_ret, true);
2373 }
2374
2375 typedef struct LDKWriteableScore_JCalls {
2376         atomic_size_t refcnt;
2377         JavaVM *vm;
2378         jweak o;
2379         LDKLockableScore_JCalls* LockableScore;
2380         jmethodID write_meth;
2381 } LDKWriteableScore_JCalls;
2382 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2383         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2384         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2385                 JNIEnv *env;
2386                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2387                 if (get_jenv_res == JNI_EDETACHED) {
2388                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2389                 } else {
2390                         DO_ASSERT(get_jenv_res == JNI_OK);
2391                 }
2392                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2393                 if (get_jenv_res == JNI_EDETACHED) {
2394                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2395                 }
2396                 FREE(j_calls);
2397         }
2398 }
2399 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2400         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2401         JNIEnv *env;
2402         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2403         if (get_jenv_res == JNI_EDETACHED) {
2404                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2405         } else {
2406                 DO_ASSERT(get_jenv_res == JNI_OK);
2407         }
2408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2409         CHECK(obj != NULL);
2410         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2411         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2412                 (*env)->ExceptionDescribe(env);
2413                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2414         }
2415         LDKCVec_u8Z ret_ref;
2416         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2417         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2418         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2419         if (get_jenv_res == JNI_EDETACHED) {
2420                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2421         }
2422         return ret_ref;
2423 }
2424 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2425         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2426         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2427         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2428 }
2429 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2430         jclass c = (*env)->GetObjectClass(env, o);
2431         CHECK(c != NULL);
2432         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2433         atomic_init(&calls->refcnt, 1);
2434         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2435         calls->o = (*env)->NewWeakGlobalRef(env, o);
2436         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2437         CHECK(calls->write_meth != NULL);
2438
2439         LDKWriteableScore ret = {
2440                 .this_arg = (void*) calls,
2441                 .write = write_LDKWriteableScore_jcall,
2442                 .free = LDKWriteableScore_JCalls_free,
2443                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2444         };
2445         calls->LockableScore = ret.LockableScore.this_arg;
2446         return ret;
2447 }
2448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2449         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2450         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2451         return tag_ptr(res_ptr, true);
2452 }
2453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2454         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2455         return tag_ptr(&inp->LockableScore, false);
2456 }
2457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2458         void* this_arg_ptr = untag_ptr(this_arg);
2459         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2460         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2461         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2462         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2463         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2464         CVec_u8Z_free(ret_var);
2465         return ret_arr;
2466 }
2467
2468 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2469 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2470 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2471 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2473         LDKCOption_WriteableScoreZ_Some_class =
2474                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2475         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2476         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2477         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2478         LDKCOption_WriteableScoreZ_None_class =
2479                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2480         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2481         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2482         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2483 }
2484 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2485         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2486         switch(obj->tag) {
2487                 case LDKCOption_WriteableScoreZ_Some: {
2488                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2489                         *some_ret = obj->some;
2490                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2491                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2492                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2493                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2494                         }
2495                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2496                 }
2497                 case LDKCOption_WriteableScoreZ_None: {
2498                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2499                 }
2500                 default: abort();
2501         }
2502 }
2503 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2504 CHECK(owner->result_ok);
2505         return *owner->contents.result;
2506 }
2507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2508         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2509         CResult_NoneErrorZ_get_ok(owner_conv);
2510 }
2511
2512 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2513 CHECK(!owner->result_ok);
2514         return *owner->contents.err;
2515 }
2516 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2517         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2518         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2519         return ret_conv;
2520 }
2521
2522 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2523         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2524         for (size_t i = 0; i < ret.datalen; i++) {
2525                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2526         }
2527         return ret;
2528 }
2529 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2530         LDKRoute ret = *owner->contents.result;
2531         ret.is_owned = false;
2532         return ret;
2533 }
2534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2535         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2536         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2537         int64_t ret_ref = 0;
2538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2540         return ret_ref;
2541 }
2542
2543 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2544         LDKLightningError ret = *owner->contents.err;
2545         ret.is_owned = false;
2546         return ret;
2547 }
2548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2549         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2550         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2551         int64_t ret_ref = 0;
2552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2554         return ret_ref;
2555 }
2556
2557 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2558         LDKInFlightHtlcs ret = *owner->contents.result;
2559         ret.is_owned = false;
2560         return ret;
2561 }
2562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2563         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2564         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2565         int64_t ret_ref = 0;
2566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2568         return ret_ref;
2569 }
2570
2571 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2572 CHECK(!owner->result_ok);
2573         return DecodeError_clone(&*owner->contents.err);
2574 }
2575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2576         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2577         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2578         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2579         int64_t ret_ref = tag_ptr(ret_copy, true);
2580         return ret_ref;
2581 }
2582
2583 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2584         LDKRouteHop ret = *owner->contents.result;
2585         ret.is_owned = false;
2586         return ret;
2587 }
2588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2589         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2590         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2591         int64_t ret_ref = 0;
2592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2593         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2594         return ret_ref;
2595 }
2596
2597 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2598 CHECK(!owner->result_ok);
2599         return DecodeError_clone(&*owner->contents.err);
2600 }
2601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2602         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2603         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2604         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2605         int64_t ret_ref = tag_ptr(ret_copy, true);
2606         return ret_ref;
2607 }
2608
2609 static inline LDKCVec_BlindedHopZ CVec_BlindedHopZ_clone(const LDKCVec_BlindedHopZ *orig) {
2610         LDKCVec_BlindedHopZ ret = { .data = MALLOC(sizeof(LDKBlindedHop) * orig->datalen, "LDKCVec_BlindedHopZ clone bytes"), .datalen = orig->datalen };
2611         for (size_t i = 0; i < ret.datalen; i++) {
2612                 ret.data[i] = BlindedHop_clone(&orig->data[i]);
2613         }
2614         return ret;
2615 }
2616 static inline struct LDKBlindedTail CResult_BlindedTailDecodeErrorZ_get_ok(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2617         LDKBlindedTail ret = *owner->contents.result;
2618         ret.is_owned = false;
2619         return ret;
2620 }
2621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2622         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2623         LDKBlindedTail ret_var = CResult_BlindedTailDecodeErrorZ_get_ok(owner_conv);
2624         int64_t ret_ref = 0;
2625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2627         return ret_ref;
2628 }
2629
2630 static inline struct LDKDecodeError CResult_BlindedTailDecodeErrorZ_get_err(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2631 CHECK(!owner->result_ok);
2632         return DecodeError_clone(&*owner->contents.err);
2633 }
2634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2635         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2636         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2637         *ret_copy = CResult_BlindedTailDecodeErrorZ_get_err(owner_conv);
2638         int64_t ret_ref = tag_ptr(ret_copy, true);
2639         return ret_ref;
2640 }
2641
2642 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2643         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2644         for (size_t i = 0; i < ret.datalen; i++) {
2645                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2646         }
2647         return ret;
2648 }
2649 static inline LDKCVec_PathZ CVec_PathZ_clone(const LDKCVec_PathZ *orig) {
2650         LDKCVec_PathZ ret = { .data = MALLOC(sizeof(LDKPath) * orig->datalen, "LDKCVec_PathZ clone bytes"), .datalen = orig->datalen };
2651         for (size_t i = 0; i < ret.datalen; i++) {
2652                 ret.data[i] = Path_clone(&orig->data[i]);
2653         }
2654         return ret;
2655 }
2656 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2657         LDKRoute ret = *owner->contents.result;
2658         ret.is_owned = false;
2659         return ret;
2660 }
2661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2662         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2663         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2664         int64_t ret_ref = 0;
2665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2667         return ret_ref;
2668 }
2669
2670 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2671 CHECK(!owner->result_ok);
2672         return DecodeError_clone(&*owner->contents.err);
2673 }
2674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2675         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2676         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2677         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2678         int64_t ret_ref = tag_ptr(ret_copy, true);
2679         return ret_ref;
2680 }
2681
2682 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2683         LDKRouteParameters ret = *owner->contents.result;
2684         ret.is_owned = false;
2685         return ret;
2686 }
2687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2688         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2689         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2690         int64_t ret_ref = 0;
2691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2693         return ret_ref;
2694 }
2695
2696 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2697 CHECK(!owner->result_ok);
2698         return DecodeError_clone(&*owner->contents.err);
2699 }
2700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2701         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2702         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2703         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2704         int64_t ret_ref = tag_ptr(ret_copy, true);
2705         return ret_ref;
2706 }
2707
2708 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2709         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2710         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2711         return ret;
2712 }
2713 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2714         LDKPaymentParameters ret = *owner->contents.result;
2715         ret.is_owned = false;
2716         return ret;
2717 }
2718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2719         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2720         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2721         int64_t ret_ref = 0;
2722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2723         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2724         return ret_ref;
2725 }
2726
2727 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2728 CHECK(!owner->result_ok);
2729         return DecodeError_clone(&*owner->contents.err);
2730 }
2731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2732         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2733         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2734         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2735         int64_t ret_ref = tag_ptr(ret_copy, true);
2736         return ret_ref;
2737 }
2738
2739 static inline struct LDKBlindedPayInfo C2Tuple_BlindedPayInfoBlindedPathZ_get_a(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
2740         LDKBlindedPayInfo ret = owner->a;
2741         ret.is_owned = false;
2742         return ret;
2743 }
2744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2745         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
2746         LDKBlindedPayInfo ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_a(owner_conv);
2747         int64_t ret_ref = 0;
2748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2750         return ret_ref;
2751 }
2752
2753 static inline struct LDKBlindedPath C2Tuple_BlindedPayInfoBlindedPathZ_get_b(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
2754         LDKBlindedPath ret = owner->b;
2755         ret.is_owned = false;
2756         return ret;
2757 }
2758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2759         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
2760         LDKBlindedPath ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_b(owner_conv);
2761         int64_t ret_ref = 0;
2762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2764         return ret_ref;
2765 }
2766
2767 static inline LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_clone(const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *orig) {
2768         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ) * orig->datalen, "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ clone bytes"), .datalen = orig->datalen };
2769         for (size_t i = 0; i < ret.datalen; i++) {
2770                 ret.data[i] = C2Tuple_BlindedPayInfoBlindedPathZ_clone(&orig->data[i]);
2771         }
2772         return ret;
2773 }
2774 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2775         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2776         for (size_t i = 0; i < ret.datalen; i++) {
2777                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2778         }
2779         return ret;
2780 }
2781 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2782         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2783         for (size_t i = 0; i < ret.datalen; i++) {
2784                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2785         }
2786         return ret;
2787 }
2788 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2789         LDKRouteHint ret = *owner->contents.result;
2790         ret.is_owned = false;
2791         return ret;
2792 }
2793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2794         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2795         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2796         int64_t ret_ref = 0;
2797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2799         return ret_ref;
2800 }
2801
2802 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2803 CHECK(!owner->result_ok);
2804         return DecodeError_clone(&*owner->contents.err);
2805 }
2806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2807         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2808         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2809         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2810         int64_t ret_ref = tag_ptr(ret_copy, true);
2811         return ret_ref;
2812 }
2813
2814 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2815         LDKRouteHintHop ret = *owner->contents.result;
2816         ret.is_owned = false;
2817         return ret;
2818 }
2819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2820         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2821         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2822         int64_t ret_ref = 0;
2823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2825         return ret_ref;
2826 }
2827
2828 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2829 CHECK(!owner->result_ok);
2830         return DecodeError_clone(&*owner->contents.err);
2831 }
2832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2833         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2834         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2835         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2836         int64_t ret_ref = tag_ptr(ret_copy, true);
2837         return ret_ref;
2838 }
2839
2840 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2841         return owner->a;
2842 }
2843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2844         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2845         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2846         return ret_conv;
2847 }
2848
2849 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2850         return owner->b;
2851 }
2852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2853         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2854         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2855         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2856         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2857         return ret_arr;
2858 }
2859
2860 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2861         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2862         for (size_t i = 0; i < ret.datalen; i++) {
2863                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2864         }
2865         return ret;
2866 }
2867 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_a(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
2868         return ThirtyTwoBytes_clone(&owner->a);
2869 }
2870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2871         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
2872         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_a(owner_conv).data);
2874         return ret_arr;
2875 }
2876
2877 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_b(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
2878         return ThirtyTwoBytes_clone(&owner->b);
2879 }
2880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2881         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
2882         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_b(owner_conv).data);
2884         return ret_arr;
2885 }
2886
2887 static inline LDKCVec_C2Tuple_TxidBlockHashZZ CVec_C2Tuple_TxidBlockHashZZ_clone(const LDKCVec_C2Tuple_TxidBlockHashZZ *orig) {
2888         LDKCVec_C2Tuple_TxidBlockHashZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ) * orig->datalen, "LDKCVec_C2Tuple_TxidBlockHashZZ clone bytes"), .datalen = orig->datalen };
2889         for (size_t i = 0; i < ret.datalen; i++) {
2890                 ret.data[i] = C2Tuple_TxidBlockHashZ_clone(&orig->data[i]);
2891         }
2892         return ret;
2893 }
2894 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
2895 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
2896 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
2897 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
2898 static jclass LDKMonitorEvent_Completed_class = NULL;
2899 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
2900 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
2901 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
2902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
2903         LDKMonitorEvent_HTLCEvent_class =
2904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
2905         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
2906         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
2907         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
2908         LDKMonitorEvent_CommitmentTxConfirmed_class =
2909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
2910         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
2911         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
2912         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
2913         LDKMonitorEvent_Completed_class =
2914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
2915         CHECK(LDKMonitorEvent_Completed_class != NULL);
2916         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
2917         CHECK(LDKMonitorEvent_Completed_meth != NULL);
2918         LDKMonitorEvent_UpdateFailed_class =
2919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
2920         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
2921         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
2922         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
2923 }
2924 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2925         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2926         switch(obj->tag) {
2927                 case LDKMonitorEvent_HTLCEvent: {
2928                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2929                         int64_t htlc_event_ref = 0;
2930                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2931                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
2932                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
2933                 }
2934                 case LDKMonitorEvent_CommitmentTxConfirmed: {
2935                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2936                         int64_t commitment_tx_confirmed_ref = 0;
2937                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2938                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
2939                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
2940                 }
2941                 case LDKMonitorEvent_Completed: {
2942                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
2943                         int64_t funding_txo_ref = 0;
2944                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2945                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
2946                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
2947                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
2948                 }
2949                 case LDKMonitorEvent_UpdateFailed: {
2950                         LDKOutPoint update_failed_var = obj->update_failed;
2951                         int64_t update_failed_ref = 0;
2952                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2953                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
2954                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
2955                 }
2956                 default: abort();
2957         }
2958 }
2959 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2960         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2961         for (size_t i = 0; i < ret.datalen; i++) {
2962                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2963         }
2964         return ret;
2965 }
2966 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2967         LDKOutPoint ret = owner->a;
2968         ret.is_owned = false;
2969         return ret;
2970 }
2971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2972         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2973         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2974         int64_t ret_ref = 0;
2975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2977         return ret_ref;
2978 }
2979
2980 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2981         return CVec_MonitorEventZ_clone(&owner->b);
2982 }
2983 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2984         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2985         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2986         int64_tArray ret_arr = NULL;
2987         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
2988         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
2989         for (size_t o = 0; o < ret_var.datalen; o++) {
2990                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2991                 *ret_conv_14_copy = ret_var.data[o];
2992                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
2993                 ret_arr_ptr[o] = ret_conv_14_ref;
2994         }
2995         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
2996         FREE(ret_var.data);
2997         return ret_arr;
2998 }
2999
3000 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3001         return owner->c;
3002 }
3003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3004         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3005         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3007         return ret_arr;
3008 }
3009
3010 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3011         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3012         for (size_t i = 0; i < ret.datalen; i++) {
3013                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3014         }
3015         return ret;
3016 }
3017 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3018         LDKFixedPenaltyScorer ret = *owner->contents.result;
3019         ret.is_owned = false;
3020         return ret;
3021 }
3022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3023         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3024         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3025         int64_t ret_ref = 0;
3026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3028         return ret_ref;
3029 }
3030
3031 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3032 CHECK(!owner->result_ok);
3033         return DecodeError_clone(&*owner->contents.err);
3034 }
3035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3036         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3037         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3038         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3039         int64_t ret_ref = tag_ptr(ret_copy, true);
3040         return ret_ref;
3041 }
3042
3043 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3044         return owner->a;
3045 }
3046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3047         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3048         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3049         return ret_conv;
3050 }
3051
3052 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3053         return owner->b;
3054 }
3055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3056         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3057         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3058         return ret_conv;
3059 }
3060
3061 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3062 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3063 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3064 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3066         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3068         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3069         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3070         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3071         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3073         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3074         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3075         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3076 }
3077 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3078         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3079         switch(obj->tag) {
3080                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3081                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3082                         *some_conv = obj->some;
3083                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3084                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
3085                 }
3086                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3087                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3088                 }
3089                 default: abort();
3090         }
3091 }
3092 static inline struct LDKEightU16s C2Tuple_Z_get_a(LDKC2Tuple_Z *NONNULL_PTR owner){
3093         return owner->a;
3094 }
3095 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3096         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3097         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3098         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_a(owner_conv).data);
3099         return ret_arr;
3100 }
3101
3102 static inline struct LDKEightU16s C2Tuple_Z_get_b(LDKC2Tuple_Z *NONNULL_PTR owner){
3103         return owner->b;
3104 }
3105 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3106         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3107         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3108         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_b(owner_conv).data);
3109         return ret_arr;
3110 }
3111
3112 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_a(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
3113         return owner->a;
3114 }
3115 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3116         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
3117         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3118         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_a(owner_conv).data);
3119         return ret_arr;
3120 }
3121
3122 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_b(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
3123         return owner->b;
3124 }
3125 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3126         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
3127         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3128         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_b(owner_conv).data);
3129         return ret_arr;
3130 }
3131
3132 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class = NULL;
3133 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = NULL;
3134 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class = NULL;
3135 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = NULL;
3136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_init (JNIEnv *env, jclass clz) {
3137         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class =
3138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$Some"));
3139         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class != NULL);
3140         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, "<init>", "(J)V");
3141         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth != NULL);
3142         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class =
3143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$None"));
3144         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class != NULL);
3145         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, "<init>", "()V");
3146         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth != NULL);
3147 }
3148 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3149         LDKCOption_C2Tuple_EightU16sEightU16sZZ *obj = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(ptr);
3150         switch(obj->tag) {
3151                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some: {
3152                         LDKC2Tuple__u168_u168Z* some_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
3153                         *some_conv = obj->some;
3154                         *some_conv = C2Tuple__u168_u168Z_clone(some_conv);
3155                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth, tag_ptr(some_conv, true));
3156                 }
3157                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_None: {
3158                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth);
3159                 }
3160                 default: abort();
3161         }
3162 }
3163 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3164         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3165         for (size_t i = 0; i < ret.datalen; i++) {
3166                 ret.data[i] = NodeId_clone(&orig->data[i]);
3167         }
3168         return ret;
3169 }
3170 typedef struct LDKLogger_JCalls {
3171         atomic_size_t refcnt;
3172         JavaVM *vm;
3173         jweak o;
3174         jmethodID log_meth;
3175 } LDKLogger_JCalls;
3176 static void LDKLogger_JCalls_free(void* this_arg) {
3177         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3178         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3179                 JNIEnv *env;
3180                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3181                 if (get_jenv_res == JNI_EDETACHED) {
3182                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3183                 } else {
3184                         DO_ASSERT(get_jenv_res == JNI_OK);
3185                 }
3186                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3187                 if (get_jenv_res == JNI_EDETACHED) {
3188                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3189                 }
3190                 FREE(j_calls);
3191         }
3192 }
3193 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3194         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3195         JNIEnv *env;
3196         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3197         if (get_jenv_res == JNI_EDETACHED) {
3198                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3199         } else {
3200                 DO_ASSERT(get_jenv_res == JNI_OK);
3201         }
3202         LDKRecord record_var = *record;
3203         int64_t record_ref = 0;
3204         record_var = Record_clone(&record_var);
3205         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3206         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
3207         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3208         CHECK(obj != NULL);
3209         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3210         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3211                 (*env)->ExceptionDescribe(env);
3212                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3213         }
3214         if (get_jenv_res == JNI_EDETACHED) {
3215                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3216         }
3217 }
3218 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3219         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3220         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3221 }
3222 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3223         jclass c = (*env)->GetObjectClass(env, o);
3224         CHECK(c != NULL);
3225         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3226         atomic_init(&calls->refcnt, 1);
3227         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3228         calls->o = (*env)->NewWeakGlobalRef(env, o);
3229         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3230         CHECK(calls->log_meth != NULL);
3231
3232         LDKLogger ret = {
3233                 .this_arg = (void*) calls,
3234                 .log = log_LDKLogger_jcall,
3235                 .free = LDKLogger_JCalls_free,
3236         };
3237         return ret;
3238 }
3239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3240         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3241         *res_ptr = LDKLogger_init(env, clz, o);
3242         return tag_ptr(res_ptr, true);
3243 }
3244 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3245         LDKProbabilisticScorer ret = *owner->contents.result;
3246         ret.is_owned = false;
3247         return ret;
3248 }
3249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3250         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3251         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3252         int64_t ret_ref = 0;
3253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3255         return ret_ref;
3256 }
3257
3258 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3259 CHECK(!owner->result_ok);
3260         return DecodeError_clone(&*owner->contents.err);
3261 }
3262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3263         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3264         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3265         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3266         int64_t ret_ref = tag_ptr(ret_copy, true);
3267         return ret_ref;
3268 }
3269
3270 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3271         LDKInitFeatures ret = *owner->contents.result;
3272         ret.is_owned = false;
3273         return ret;
3274 }
3275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3276         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3277         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3278         int64_t ret_ref = 0;
3279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3281         return ret_ref;
3282 }
3283
3284 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3285 CHECK(!owner->result_ok);
3286         return DecodeError_clone(&*owner->contents.err);
3287 }
3288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3289         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3290         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3291         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3292         int64_t ret_ref = tag_ptr(ret_copy, true);
3293         return ret_ref;
3294 }
3295
3296 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3297         LDKChannelFeatures ret = *owner->contents.result;
3298         ret.is_owned = false;
3299         return ret;
3300 }
3301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3302         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3303         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3304         int64_t ret_ref = 0;
3305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3307         return ret_ref;
3308 }
3309
3310 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3311 CHECK(!owner->result_ok);
3312         return DecodeError_clone(&*owner->contents.err);
3313 }
3314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3315         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3316         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3317         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3318         int64_t ret_ref = tag_ptr(ret_copy, true);
3319         return ret_ref;
3320 }
3321
3322 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3323         LDKNodeFeatures ret = *owner->contents.result;
3324         ret.is_owned = false;
3325         return ret;
3326 }
3327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3328         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3329         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3330         int64_t ret_ref = 0;
3331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3332         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3333         return ret_ref;
3334 }
3335
3336 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3337 CHECK(!owner->result_ok);
3338         return DecodeError_clone(&*owner->contents.err);
3339 }
3340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3341         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3342         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3343         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3344         int64_t ret_ref = tag_ptr(ret_copy, true);
3345         return ret_ref;
3346 }
3347
3348 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3349         LDKInvoiceFeatures ret = *owner->contents.result;
3350         ret.is_owned = false;
3351         return ret;
3352 }
3353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3354         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3355         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3356         int64_t ret_ref = 0;
3357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3359         return ret_ref;
3360 }
3361
3362 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3363 CHECK(!owner->result_ok);
3364         return DecodeError_clone(&*owner->contents.err);
3365 }
3366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3367         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3368         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3369         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3370         int64_t ret_ref = tag_ptr(ret_copy, true);
3371         return ret_ref;
3372 }
3373
3374 static inline struct LDKBlindedHopFeatures CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3375         LDKBlindedHopFeatures ret = *owner->contents.result;
3376         ret.is_owned = false;
3377         return ret;
3378 }
3379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3380         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3381         LDKBlindedHopFeatures ret_var = CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(owner_conv);
3382         int64_t ret_ref = 0;
3383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3385         return ret_ref;
3386 }
3387
3388 static inline struct LDKDecodeError CResult_BlindedHopFeaturesDecodeErrorZ_get_err(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(!owner->result_ok);
3390         return DecodeError_clone(&*owner->contents.err);
3391 }
3392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3393         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3394         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3395         *ret_copy = CResult_BlindedHopFeaturesDecodeErrorZ_get_err(owner_conv);
3396         int64_t ret_ref = tag_ptr(ret_copy, true);
3397         return ret_ref;
3398 }
3399
3400 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3401         LDKChannelTypeFeatures ret = *owner->contents.result;
3402         ret.is_owned = false;
3403         return ret;
3404 }
3405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3406         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3407         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3408         int64_t ret_ref = 0;
3409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3410         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3411         return ret_ref;
3412 }
3413
3414 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3415 CHECK(!owner->result_ok);
3416         return DecodeError_clone(&*owner->contents.err);
3417 }
3418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3419         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3420         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3421         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3422         int64_t ret_ref = tag_ptr(ret_copy, true);
3423         return ret_ref;
3424 }
3425
3426 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
3427 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
3428 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
3429 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
3430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
3431         LDKPaymentPurpose_InvoicePayment_class =
3432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
3433         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
3434         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
3435         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
3436         LDKPaymentPurpose_SpontaneousPayment_class =
3437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
3438         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
3439         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
3440         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
3441 }
3442 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3443         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
3444         switch(obj->tag) {
3445                 case LDKPaymentPurpose_InvoicePayment: {
3446                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3447                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
3448                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
3449                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
3450                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
3451                 }
3452                 case LDKPaymentPurpose_SpontaneousPayment: {
3453                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
3454                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
3455                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
3456                 }
3457                 default: abort();
3458         }
3459 }
3460 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
3461 CHECK(owner->result_ok);
3462         return PaymentPurpose_clone(&*owner->contents.result);
3463 }
3464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3465         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
3466         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
3467         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
3468         int64_t ret_ref = tag_ptr(ret_copy, true);
3469         return ret_ref;
3470 }
3471
3472 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
3473 CHECK(!owner->result_ok);
3474         return DecodeError_clone(&*owner->contents.err);
3475 }
3476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3477         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
3478         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3479         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
3480         int64_t ret_ref = tag_ptr(ret_copy, true);
3481         return ret_ref;
3482 }
3483
3484 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
3485 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
3486 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
3487 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
3488 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
3489 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
3490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
3491         LDKNetworkUpdate_ChannelUpdateMessage_class =
3492                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
3493         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
3494         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
3495         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
3496         LDKNetworkUpdate_ChannelFailure_class =
3497                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
3498         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
3499         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
3500         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
3501         LDKNetworkUpdate_NodeFailure_class =
3502                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
3503         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
3504         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
3505         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
3506 }
3507 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3508         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3509         switch(obj->tag) {
3510                 case LDKNetworkUpdate_ChannelUpdateMessage: {
3511                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
3512                         int64_t msg_ref = 0;
3513                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3514                         msg_ref = tag_ptr(msg_var.inner, false);
3515                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
3516                 }
3517                 case LDKNetworkUpdate_ChannelFailure: {
3518                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
3519                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
3520                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
3521                 }
3522                 case LDKNetworkUpdate_NodeFailure: {
3523                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3524                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
3525                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
3526                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
3527                 }
3528                 default: abort();
3529         }
3530 }
3531 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
3532 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
3533 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
3534 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
3535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
3536         LDKCOption_NetworkUpdateZ_Some_class =
3537                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
3538         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
3539         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
3540         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
3541         LDKCOption_NetworkUpdateZ_None_class =
3542                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
3543         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
3544         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
3545         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
3546 }
3547 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3548         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3549         switch(obj->tag) {
3550                 case LDKCOption_NetworkUpdateZ_Some: {
3551                         int64_t some_ref = tag_ptr(&obj->some, false);
3552                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
3553                 }
3554                 case LDKCOption_NetworkUpdateZ_None: {
3555                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
3556                 }
3557                 default: abort();
3558         }
3559 }
3560 static jclass LDKPathFailure_InitialSend_class = NULL;
3561 static jmethodID LDKPathFailure_InitialSend_meth = NULL;
3562 static jclass LDKPathFailure_OnPath_class = NULL;
3563 static jmethodID LDKPathFailure_OnPath_meth = NULL;
3564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPathFailure_init (JNIEnv *env, jclass clz) {
3565         LDKPathFailure_InitialSend_class =
3566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$InitialSend"));
3567         CHECK(LDKPathFailure_InitialSend_class != NULL);
3568         LDKPathFailure_InitialSend_meth = (*env)->GetMethodID(env, LDKPathFailure_InitialSend_class, "<init>", "(J)V");
3569         CHECK(LDKPathFailure_InitialSend_meth != NULL);
3570         LDKPathFailure_OnPath_class =
3571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$OnPath"));
3572         CHECK(LDKPathFailure_OnPath_class != NULL);
3573         LDKPathFailure_OnPath_meth = (*env)->GetMethodID(env, LDKPathFailure_OnPath_class, "<init>", "(J)V");
3574         CHECK(LDKPathFailure_OnPath_meth != NULL);
3575 }
3576 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPathFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3577         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
3578         switch(obj->tag) {
3579                 case LDKPathFailure_InitialSend: {
3580                         int64_t err_ref = tag_ptr(&obj->initial_send.err, false);
3581                         return (*env)->NewObject(env, LDKPathFailure_InitialSend_class, LDKPathFailure_InitialSend_meth, err_ref);
3582                 }
3583                 case LDKPathFailure_OnPath: {
3584                         int64_t network_update_ref = tag_ptr(&obj->on_path.network_update, false);
3585                         return (*env)->NewObject(env, LDKPathFailure_OnPath_class, LDKPathFailure_OnPath_meth, network_update_ref);
3586                 }
3587                 default: abort();
3588         }
3589 }
3590 static jclass LDKCOption_PathFailureZ_Some_class = NULL;
3591 static jmethodID LDKCOption_PathFailureZ_Some_meth = NULL;
3592 static jclass LDKCOption_PathFailureZ_None_class = NULL;
3593 static jmethodID LDKCOption_PathFailureZ_None_meth = NULL;
3594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1PathFailureZ_init (JNIEnv *env, jclass clz) {
3595         LDKCOption_PathFailureZ_Some_class =
3596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$Some"));
3597         CHECK(LDKCOption_PathFailureZ_Some_class != NULL);
3598         LDKCOption_PathFailureZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_Some_class, "<init>", "(J)V");
3599         CHECK(LDKCOption_PathFailureZ_Some_meth != NULL);
3600         LDKCOption_PathFailureZ_None_class =
3601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$None"));
3602         CHECK(LDKCOption_PathFailureZ_None_class != NULL);
3603         LDKCOption_PathFailureZ_None_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_None_class, "<init>", "()V");
3604         CHECK(LDKCOption_PathFailureZ_None_meth != NULL);
3605 }
3606 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1PathFailureZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3607         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
3608         switch(obj->tag) {
3609                 case LDKCOption_PathFailureZ_Some: {
3610                         int64_t some_ref = tag_ptr(&obj->some, false);
3611                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_Some_class, LDKCOption_PathFailureZ_Some_meth, some_ref);
3612                 }
3613                 case LDKCOption_PathFailureZ_None: {
3614                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_None_class, LDKCOption_PathFailureZ_None_meth);
3615                 }
3616                 default: abort();
3617         }
3618 }
3619 static inline struct LDKCOption_PathFailureZ CResult_COption_PathFailureZDecodeErrorZ_get_ok(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
3620 CHECK(owner->result_ok);
3621         return COption_PathFailureZ_clone(&*owner->contents.result);
3622 }
3623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3624         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
3625         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
3626         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_ok(owner_conv);
3627         int64_t ret_ref = tag_ptr(ret_copy, true);
3628         return ret_ref;
3629 }
3630
3631 static inline struct LDKDecodeError CResult_COption_PathFailureZDecodeErrorZ_get_err(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
3632 CHECK(!owner->result_ok);
3633         return DecodeError_clone(&*owner->contents.err);
3634 }
3635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3636         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
3637         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3638         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_err(owner_conv);
3639         int64_t ret_ref = tag_ptr(ret_copy, true);
3640         return ret_ref;
3641 }
3642
3643 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
3644 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
3645 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
3646 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
3647 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
3648 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
3649 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
3650 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
3651 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
3652 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
3653 static jclass LDKClosureReason_ProcessingError_class = NULL;
3654 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
3655 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
3656 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
3657 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
3658 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
3659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
3660         LDKClosureReason_CounterpartyForceClosed_class =
3661                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
3662         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
3663         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(J)V");
3664         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
3665         LDKClosureReason_HolderForceClosed_class =
3666                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
3667         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
3668         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
3669         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
3670         LDKClosureReason_CooperativeClosure_class =
3671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
3672         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
3673         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
3674         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
3675         LDKClosureReason_CommitmentTxConfirmed_class =
3676                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
3677         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
3678         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
3679         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
3680         LDKClosureReason_FundingTimedOut_class =
3681                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
3682         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
3683         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
3684         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
3685         LDKClosureReason_ProcessingError_class =
3686                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
3687         CHECK(LDKClosureReason_ProcessingError_class != NULL);
3688         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
3689         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
3690         LDKClosureReason_DisconnectedPeer_class =
3691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
3692         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
3693         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
3694         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
3695         LDKClosureReason_OutdatedChannelManager_class =
3696                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
3697         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
3698         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
3699         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
3700 }
3701 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3702         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
3703         switch(obj->tag) {
3704                 case LDKClosureReason_CounterpartyForceClosed: {
3705                         LDKUntrustedString peer_msg_var = obj->counterparty_force_closed.peer_msg;
3706                         int64_t peer_msg_ref = 0;
3707                         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_var);
3708                         peer_msg_ref = tag_ptr(peer_msg_var.inner, false);
3709                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_ref);
3710                 }
3711                 case LDKClosureReason_HolderForceClosed: {
3712                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
3713                 }
3714                 case LDKClosureReason_CooperativeClosure: {
3715                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
3716                 }
3717                 case LDKClosureReason_CommitmentTxConfirmed: {
3718                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
3719                 }
3720                 case LDKClosureReason_FundingTimedOut: {
3721                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
3722                 }
3723                 case LDKClosureReason_ProcessingError: {
3724                         LDKStr err_str = obj->processing_error.err;
3725                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3726                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
3727                 }
3728                 case LDKClosureReason_DisconnectedPeer: {
3729                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
3730                 }
3731                 case LDKClosureReason_OutdatedChannelManager: {
3732                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
3733                 }
3734                 default: abort();
3735         }
3736 }
3737 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
3738 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
3739 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
3740 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
3741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
3742         LDKCOption_ClosureReasonZ_Some_class =
3743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
3744         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
3745         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
3746         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
3747         LDKCOption_ClosureReasonZ_None_class =
3748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
3749         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
3750         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
3751         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
3752 }
3753 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3754         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
3755         switch(obj->tag) {
3756                 case LDKCOption_ClosureReasonZ_Some: {
3757                         int64_t some_ref = tag_ptr(&obj->some, false);
3758                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
3759                 }
3760                 case LDKCOption_ClosureReasonZ_None: {
3761                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
3762                 }
3763                 default: abort();
3764         }
3765 }
3766 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3767 CHECK(owner->result_ok);
3768         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3769 }
3770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3771         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3772         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3773         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3774         int64_t ret_ref = tag_ptr(ret_copy, true);
3775         return ret_ref;
3776 }
3777
3778 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3779 CHECK(!owner->result_ok);
3780         return DecodeError_clone(&*owner->contents.err);
3781 }
3782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3783         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3784         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3785         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3786         int64_t ret_ref = tag_ptr(ret_copy, true);
3787         return ret_ref;
3788 }
3789
3790 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
3791 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
3792 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
3793 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
3794 static jclass LDKHTLCDestination_InvalidForward_class = NULL;
3795 static jmethodID LDKHTLCDestination_InvalidForward_meth = NULL;
3796 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
3797 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
3798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
3799         LDKHTLCDestination_NextHopChannel_class =
3800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
3801         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
3802         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
3803         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
3804         LDKHTLCDestination_UnknownNextHop_class =
3805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
3806         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
3807         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
3808         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
3809         LDKHTLCDestination_InvalidForward_class =
3810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$InvalidForward"));
3811         CHECK(LDKHTLCDestination_InvalidForward_class != NULL);
3812         LDKHTLCDestination_InvalidForward_meth = (*env)->GetMethodID(env, LDKHTLCDestination_InvalidForward_class, "<init>", "(J)V");
3813         CHECK(LDKHTLCDestination_InvalidForward_meth != NULL);
3814         LDKHTLCDestination_FailedPayment_class =
3815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
3816         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
3817         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
3818         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
3819 }
3820 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3821         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
3822         switch(obj->tag) {
3823                 case LDKHTLCDestination_NextHopChannel: {
3824                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3825                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
3826                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3827                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
3828                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
3829                 }
3830                 case LDKHTLCDestination_UnknownNextHop: {
3831                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
3832                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
3833                 }
3834                 case LDKHTLCDestination_InvalidForward: {
3835                         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
3836                         return (*env)->NewObject(env, LDKHTLCDestination_InvalidForward_class, LDKHTLCDestination_InvalidForward_meth, requested_forward_scid_conv);
3837                 }
3838                 case LDKHTLCDestination_FailedPayment: {
3839                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3840                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
3841                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
3842                 }
3843                 default: abort();
3844         }
3845 }
3846 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
3847 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
3848 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
3849 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
3850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
3851         LDKCOption_HTLCDestinationZ_Some_class =
3852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
3853         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
3854         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
3855         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
3856         LDKCOption_HTLCDestinationZ_None_class =
3857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
3858         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
3859         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
3860         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
3861 }
3862 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3863         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
3864         switch(obj->tag) {
3865                 case LDKCOption_HTLCDestinationZ_Some: {
3866                         int64_t some_ref = tag_ptr(&obj->some, false);
3867                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
3868                 }
3869                 case LDKCOption_HTLCDestinationZ_None: {
3870                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
3871                 }
3872                 default: abort();
3873         }
3874 }
3875 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3876 CHECK(owner->result_ok);
3877         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
3878 }
3879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3880         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3881         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
3882         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
3883         int64_t ret_ref = tag_ptr(ret_copy, true);
3884         return ret_ref;
3885 }
3886
3887 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3888 CHECK(!owner->result_ok);
3889         return DecodeError_clone(&*owner->contents.err);
3890 }
3891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3892         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3893         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3894         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
3895         int64_t ret_ref = tag_ptr(ret_copy, true);
3896         return ret_ref;
3897 }
3898
3899 static inline enum LDKPaymentFailureReason CResult_PaymentFailureReasonDecodeErrorZ_get_ok(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
3900 CHECK(owner->result_ok);
3901         return PaymentFailureReason_clone(&*owner->contents.result);
3902 }
3903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3904         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
3905         jclass ret_conv = LDKPaymentFailureReason_to_java(env, CResult_PaymentFailureReasonDecodeErrorZ_get_ok(owner_conv));
3906         return ret_conv;
3907 }
3908
3909 static inline struct LDKDecodeError CResult_PaymentFailureReasonDecodeErrorZ_get_err(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
3910 CHECK(!owner->result_ok);
3911         return DecodeError_clone(&*owner->contents.err);
3912 }
3913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3914         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
3915         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3916         *ret_copy = CResult_PaymentFailureReasonDecodeErrorZ_get_err(owner_conv);
3917         int64_t ret_ref = tag_ptr(ret_copy, true);
3918         return ret_ref;
3919 }
3920
3921 static jclass LDKCOption_u128Z_Some_class = NULL;
3922 static jmethodID LDKCOption_u128Z_Some_meth = NULL;
3923 static jclass LDKCOption_u128Z_None_class = NULL;
3924 static jmethodID LDKCOption_u128Z_None_meth = NULL;
3925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u128Z_init (JNIEnv *env, jclass clz) {
3926         LDKCOption_u128Z_Some_class =
3927                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$Some"));
3928         CHECK(LDKCOption_u128Z_Some_class != NULL);
3929         LDKCOption_u128Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_Some_class, "<init>", "([B)V");
3930         CHECK(LDKCOption_u128Z_Some_meth != NULL);
3931         LDKCOption_u128Z_None_class =
3932                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$None"));
3933         CHECK(LDKCOption_u128Z_None_class != NULL);
3934         LDKCOption_u128Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_None_class, "<init>", "()V");
3935         CHECK(LDKCOption_u128Z_None_meth != NULL);
3936 }
3937 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u128Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3938         LDKCOption_u128Z *obj = (LDKCOption_u128Z*)untag_ptr(ptr);
3939         switch(obj->tag) {
3940                 case LDKCOption_u128Z_Some: {
3941                         int8_tArray some_arr = (*env)->NewByteArray(env, 16);
3942                         (*env)->SetByteArrayRegion(env, some_arr, 0, 16, obj->some.le_bytes);
3943                         return (*env)->NewObject(env, LDKCOption_u128Z_Some_class, LDKCOption_u128Z_Some_meth, some_arr);
3944                 }
3945                 case LDKCOption_u128Z_None: {
3946                         return (*env)->NewObject(env, LDKCOption_u128Z_None_class, LDKCOption_u128Z_None_meth);
3947                 }
3948                 default: abort();
3949         }
3950 }
3951 static jclass LDKCOption_PaymentFailureReasonZ_Some_class = NULL;
3952 static jmethodID LDKCOption_PaymentFailureReasonZ_Some_meth = NULL;
3953 static jclass LDKCOption_PaymentFailureReasonZ_None_class = NULL;
3954 static jmethodID LDKCOption_PaymentFailureReasonZ_None_meth = NULL;
3955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1PaymentFailureReasonZ_init (JNIEnv *env, jclass clz) {
3956         LDKCOption_PaymentFailureReasonZ_Some_class =
3957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PaymentFailureReasonZ$Some"));
3958         CHECK(LDKCOption_PaymentFailureReasonZ_Some_class != NULL);
3959         LDKCOption_PaymentFailureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_PaymentFailureReasonZ_Some_class, "<init>", "(Lorg/ldk/enums/PaymentFailureReason;)V");
3960         CHECK(LDKCOption_PaymentFailureReasonZ_Some_meth != NULL);
3961         LDKCOption_PaymentFailureReasonZ_None_class =
3962                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PaymentFailureReasonZ$None"));
3963         CHECK(LDKCOption_PaymentFailureReasonZ_None_class != NULL);
3964         LDKCOption_PaymentFailureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_PaymentFailureReasonZ_None_class, "<init>", "()V");
3965         CHECK(LDKCOption_PaymentFailureReasonZ_None_meth != NULL);
3966 }
3967 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1PaymentFailureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3968         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
3969         switch(obj->tag) {
3970                 case LDKCOption_PaymentFailureReasonZ_Some: {
3971                         jclass some_conv = LDKPaymentFailureReason_to_java(env, obj->some);
3972                         return (*env)->NewObject(env, LDKCOption_PaymentFailureReasonZ_Some_class, LDKCOption_PaymentFailureReasonZ_Some_meth, some_conv);
3973                 }
3974                 case LDKCOption_PaymentFailureReasonZ_None: {
3975                         return (*env)->NewObject(env, LDKCOption_PaymentFailureReasonZ_None_class, LDKCOption_PaymentFailureReasonZ_None_meth);
3976                 }
3977                 default: abort();
3978         }
3979 }
3980 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
3981 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
3982 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
3983 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
3984 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
3985 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
3986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
3987         LDKSpendableOutputDescriptor_StaticOutput_class =
3988                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
3989         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
3990         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
3991         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
3992         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
3993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
3994         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
3995         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
3996         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
3997         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
3998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
3999         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
4000         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
4001         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
4002 }
4003 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4004         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
4005         switch(obj->tag) {
4006                 case LDKSpendableOutputDescriptor_StaticOutput: {
4007                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
4008                         int64_t outpoint_ref = 0;
4009                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
4010                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
4011                         LDKTxOut* output_ref = &obj->static_output.output;
4012                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
4013                 }
4014                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
4015                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
4016                         int64_t delayed_payment_output_ref = 0;
4017                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
4018                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
4019                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
4020                 }
4021                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
4022                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
4023                         int64_t static_payment_output_ref = 0;
4024                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
4025                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
4026                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
4027                 }
4028                 default: abort();
4029         }
4030 }
4031 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
4032         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
4033         for (size_t i = 0; i < ret.datalen; i++) {
4034                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
4035         }
4036         return ret;
4037 }
4038 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4039 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4040 static jclass LDKEvent_PaymentClaimable_class = NULL;
4041 static jmethodID LDKEvent_PaymentClaimable_meth = NULL;
4042 static jclass LDKEvent_PaymentClaimed_class = NULL;
4043 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
4044 static jclass LDKEvent_PaymentSent_class = NULL;
4045 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4046 static jclass LDKEvent_PaymentFailed_class = NULL;
4047 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4048 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
4049 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
4050 static jclass LDKEvent_PaymentPathFailed_class = NULL;
4051 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
4052 static jclass LDKEvent_ProbeSuccessful_class = NULL;
4053 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
4054 static jclass LDKEvent_ProbeFailed_class = NULL;
4055 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
4056 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4057 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4058 static jclass LDKEvent_HTLCIntercepted_class = NULL;
4059 static jmethodID LDKEvent_HTLCIntercepted_meth = NULL;
4060 static jclass LDKEvent_SpendableOutputs_class = NULL;
4061 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4062 static jclass LDKEvent_PaymentForwarded_class = NULL;
4063 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
4064 static jclass LDKEvent_ChannelPending_class = NULL;
4065 static jmethodID LDKEvent_ChannelPending_meth = NULL;
4066 static jclass LDKEvent_ChannelReady_class = NULL;
4067 static jmethodID LDKEvent_ChannelReady_meth = NULL;
4068 static jclass LDKEvent_ChannelClosed_class = NULL;
4069 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
4070 static jclass LDKEvent_DiscardFunding_class = NULL;
4071 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
4072 static jclass LDKEvent_OpenChannelRequest_class = NULL;
4073 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
4074 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
4075 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
4076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4077         LDKEvent_FundingGenerationReady_class =
4078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
4079         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4080         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[B[B)V");
4081         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4082         LDKEvent_PaymentClaimable_class =
4083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimable"));
4084         CHECK(LDKEvent_PaymentClaimable_class != NULL);
4085         LDKEvent_PaymentClaimable_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimable_class, "<init>", "([B[BJJJ[BJJ)V");
4086         CHECK(LDKEvent_PaymentClaimable_meth != NULL);
4087         LDKEvent_PaymentClaimed_class =
4088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
4089         CHECK(LDKEvent_PaymentClaimed_class != NULL);
4090         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([B[BJJ)V");
4091         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
4092         LDKEvent_PaymentSent_class =
4093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
4094         CHECK(LDKEvent_PaymentSent_class != NULL);
4095         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
4096         CHECK(LDKEvent_PaymentSent_meth != NULL);
4097         LDKEvent_PaymentFailed_class =
4098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
4099         CHECK(LDKEvent_PaymentFailed_class != NULL);
4100         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[BJ)V");
4101         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4102         LDKEvent_PaymentPathSuccessful_class =
4103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
4104         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
4105         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[BJ)V");
4106         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
4107         LDKEvent_PaymentPathFailed_class =
4108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
4109         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
4110         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJJJ)V");
4111         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
4112         LDKEvent_ProbeSuccessful_class =
4113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
4114         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
4115         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[BJ)V");
4116         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
4117         LDKEvent_ProbeFailed_class =
4118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
4119         CHECK(LDKEvent_ProbeFailed_class != NULL);
4120         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[BJJ)V");
4121         CHECK(LDKEvent_ProbeFailed_meth != NULL);
4122         LDKEvent_PendingHTLCsForwardable_class =
4123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
4124         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4125         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4126         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4127         LDKEvent_HTLCIntercepted_class =
4128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCIntercepted"));
4129         CHECK(LDKEvent_HTLCIntercepted_class != NULL);
4130         LDKEvent_HTLCIntercepted_meth = (*env)->GetMethodID(env, LDKEvent_HTLCIntercepted_class, "<init>", "([BJ[BJJ)V");
4131         CHECK(LDKEvent_HTLCIntercepted_meth != NULL);
4132         LDKEvent_SpendableOutputs_class =
4133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
4134         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4135         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4136         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4137         LDKEvent_PaymentForwarded_class =
4138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
4139         CHECK(LDKEvent_PaymentForwarded_class != NULL);
4140         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZJ)V");
4141         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
4142         LDKEvent_ChannelPending_class =
4143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelPending"));
4144         CHECK(LDKEvent_ChannelPending_class != NULL);
4145         LDKEvent_ChannelPending_meth = (*env)->GetMethodID(env, LDKEvent_ChannelPending_class, "<init>", "([B[B[B[BJ)V");
4146         CHECK(LDKEvent_ChannelPending_meth != NULL);
4147         LDKEvent_ChannelReady_class =
4148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelReady"));
4149         CHECK(LDKEvent_ChannelReady_class != NULL);
4150         LDKEvent_ChannelReady_meth = (*env)->GetMethodID(env, LDKEvent_ChannelReady_class, "<init>", "([B[B[BJ)V");
4151         CHECK(LDKEvent_ChannelReady_meth != NULL);
4152         LDKEvent_ChannelClosed_class =
4153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
4154         CHECK(LDKEvent_ChannelClosed_class != NULL);
4155         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([B[BJ)V");
4156         CHECK(LDKEvent_ChannelClosed_meth != NULL);
4157         LDKEvent_DiscardFunding_class =
4158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
4159         CHECK(LDKEvent_DiscardFunding_class != NULL);
4160         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
4161         CHECK(LDKEvent_DiscardFunding_meth != NULL);
4162         LDKEvent_OpenChannelRequest_class =
4163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
4164         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
4165         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
4166         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
4167         LDKEvent_HTLCHandlingFailed_class =
4168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
4169         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
4170         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
4171         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
4172 }
4173 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4174         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
4175         switch(obj->tag) {
4176                 case LDKEvent_FundingGenerationReady: {
4177                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4178                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4179                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4180                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
4181                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
4182                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4183                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4184                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4185                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4186                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->funding_generation_ready.user_channel_id.le_bytes);
4187                         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);
4188                 }
4189                 case LDKEvent_PaymentClaimable: {
4190                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
4191                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimable.receiver_node_id.compressed_form);
4192                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4193                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimable.payment_hash.data);
4194                         LDKRecipientOnionFields onion_fields_var = obj->payment_claimable.onion_fields;
4195                         int64_t onion_fields_ref = 0;
4196                         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_var);
4197                         onion_fields_ref = tag_ptr(onion_fields_var.inner, false);
4198                         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
4199                         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
4200                         int8_tArray via_channel_id_arr = (*env)->NewByteArray(env, 32);
4201                         (*env)->SetByteArrayRegion(env, via_channel_id_arr, 0, 32, obj->payment_claimable.via_channel_id.data);
4202                         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
4203                         int64_t claim_deadline_ref = tag_ptr(&obj->payment_claimable.claim_deadline, false);
4204                         return (*env)->NewObject(env, LDKEvent_PaymentClaimable_class, LDKEvent_PaymentClaimable_meth, receiver_node_id_arr, payment_hash_arr, onion_fields_ref, amount_msat_conv, purpose_ref, via_channel_id_arr, via_user_channel_id_ref, claim_deadline_ref);
4205                 }
4206                 case LDKEvent_PaymentClaimed: {
4207                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
4208                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimed.receiver_node_id.compressed_form);
4209                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4210                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
4211                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
4212                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
4213                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref);
4214                 }
4215                 case LDKEvent_PaymentSent: {
4216                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4217                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
4218                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4219                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4220                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4221                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
4222                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
4223                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
4224                 }
4225                 case LDKEvent_PaymentFailed: {
4226                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4227                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
4228                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4229                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4230                         int64_t reason_ref = tag_ptr(&obj->payment_failed.reason, false);
4231                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr, reason_ref);
4232                 }
4233                 case LDKEvent_PaymentPathSuccessful: {
4234                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4235                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
4236                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4237                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
4238                         LDKPath path_var = obj->payment_path_successful.path;
4239                         int64_t path_ref = 0;
4240                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4241                         path_ref = tag_ptr(path_var.inner, false);
4242                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_ref);
4243                 }
4244                 case LDKEvent_PaymentPathFailed: {
4245                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4246                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
4247                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4248                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
4249                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
4250                         int64_t failure_ref = tag_ptr(&obj->payment_path_failed.failure, false);
4251                         LDKPath path_var = obj->payment_path_failed.path;
4252                         int64_t path_ref = 0;
4253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4254                         path_ref = tag_ptr(path_var.inner, false);
4255                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
4256                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, failure_ref, path_ref, short_channel_id_ref);
4257                 }
4258                 case LDKEvent_ProbeSuccessful: {
4259                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4260                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
4261                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4262                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
4263                         LDKPath path_var = obj->probe_successful.path;
4264                         int64_t path_ref = 0;
4265                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4266                         path_ref = tag_ptr(path_var.inner, false);
4267                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_ref);
4268                 }
4269                 case LDKEvent_ProbeFailed: {
4270                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4271                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
4272                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4273                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
4274                         LDKPath path_var = obj->probe_failed.path;
4275                         int64_t path_ref = 0;
4276                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4277                         path_ref = tag_ptr(path_var.inner, false);
4278                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
4279                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_ref, short_channel_id_ref);
4280                 }
4281                 case LDKEvent_PendingHTLCsForwardable: {
4282                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
4283                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
4284                 }
4285                 case LDKEvent_HTLCIntercepted: {
4286                         int8_tArray intercept_id_arr = (*env)->NewByteArray(env, 32);
4287                         (*env)->SetByteArrayRegion(env, intercept_id_arr, 0, 32, obj->htlc_intercepted.intercept_id.data);
4288                         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
4289                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4290                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->htlc_intercepted.payment_hash.data);
4291                         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
4292                         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
4293                         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);
4294                 }
4295                 case LDKEvent_SpendableOutputs: {
4296                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4297                         int64_tArray outputs_arr = NULL;
4298                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4299                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4300                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4301                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
4302                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4303                         }
4304                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4305                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4306                 }
4307                 case LDKEvent_PaymentForwarded: {
4308                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
4309                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
4310                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
4311                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
4312                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
4313                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
4314                         int64_t outbound_amount_forwarded_msat_ref = tag_ptr(&obj->payment_forwarded.outbound_amount_forwarded_msat, false);
4315                         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, outbound_amount_forwarded_msat_ref);
4316                 }
4317                 case LDKEvent_ChannelPending: {
4318                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4319                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_pending.channel_id.data);
4320                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4321                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_pending.user_channel_id.le_bytes);
4322                         int8_tArray former_temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4323                         (*env)->SetByteArrayRegion(env, former_temporary_channel_id_arr, 0, 32, obj->channel_pending.former_temporary_channel_id.data);
4324                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4325                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_pending.counterparty_node_id.compressed_form);
4326                         LDKOutPoint funding_txo_var = obj->channel_pending.funding_txo;
4327                         int64_t funding_txo_ref = 0;
4328                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4329                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
4330                         return (*env)->NewObject(env, LDKEvent_ChannelPending_class, LDKEvent_ChannelPending_meth, channel_id_arr, user_channel_id_arr, former_temporary_channel_id_arr, counterparty_node_id_arr, funding_txo_ref);
4331                 }
4332                 case LDKEvent_ChannelReady: {
4333                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4334                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_ready.channel_id.data);
4335                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4336                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_ready.user_channel_id.le_bytes);
4337                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4338                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_ready.counterparty_node_id.compressed_form);
4339                         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
4340                         int64_t channel_type_ref = 0;
4341                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
4342                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
4343                         return (*env)->NewObject(env, LDKEvent_ChannelReady_class, LDKEvent_ChannelReady_meth, channel_id_arr, user_channel_id_arr, counterparty_node_id_arr, channel_type_ref);
4344                 }
4345                 case LDKEvent_ChannelClosed: {
4346                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4347                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
4348                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4349                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_closed.user_channel_id.le_bytes);
4350                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
4351                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_arr, reason_ref);
4352                 }
4353                 case LDKEvent_DiscardFunding: {
4354                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4355                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
4356                         LDKTransaction transaction_var = obj->discard_funding.transaction;
4357                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
4358                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
4359                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
4360                 }
4361                 case LDKEvent_OpenChannelRequest: {
4362                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4363                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
4364                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4365                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
4366                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
4367                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
4368                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
4369                         int64_t channel_type_ref = 0;
4370                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
4371                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
4372                         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);
4373                 }
4374                 case LDKEvent_HTLCHandlingFailed: {
4375                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
4376                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
4377                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
4378                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
4379                 }
4380                 default: abort();
4381         }
4382 }
4383 static jclass LDKCOption_EventZ_Some_class = NULL;
4384 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
4385 static jclass LDKCOption_EventZ_None_class = NULL;
4386 static jmethodID LDKCOption_EventZ_None_meth = NULL;
4387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
4388         LDKCOption_EventZ_Some_class =
4389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
4390         CHECK(LDKCOption_EventZ_Some_class != NULL);
4391         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
4392         CHECK(LDKCOption_EventZ_Some_meth != NULL);
4393         LDKCOption_EventZ_None_class =
4394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
4395         CHECK(LDKCOption_EventZ_None_class != NULL);
4396         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
4397         CHECK(LDKCOption_EventZ_None_meth != NULL);
4398 }
4399 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4400         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
4401         switch(obj->tag) {
4402                 case LDKCOption_EventZ_Some: {
4403                         int64_t some_ref = tag_ptr(&obj->some, false);
4404                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
4405                 }
4406                 case LDKCOption_EventZ_None: {
4407                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
4408                 }
4409                 default: abort();
4410         }
4411 }
4412 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
4413 CHECK(owner->result_ok);
4414         return COption_EventZ_clone(&*owner->contents.result);
4415 }
4416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4417         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
4418         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
4419         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
4420         int64_t ret_ref = tag_ptr(ret_copy, true);
4421         return ret_ref;
4422 }
4423
4424 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
4425 CHECK(!owner->result_ok);
4426         return DecodeError_clone(&*owner->contents.err);
4427 }
4428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4429         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
4430         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4431         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
4432         int64_t ret_ref = tag_ptr(ret_copy, true);
4433         return ret_ref;
4434 }
4435
4436 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
4437 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
4438 static jclass LDKErrorAction_IgnoreError_class = NULL;
4439 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
4440 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
4441 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
4442 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
4443 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
4444 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
4445 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
4446 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
4447 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
4448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
4449         LDKErrorAction_DisconnectPeer_class =
4450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
4451         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
4452         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
4453         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
4454         LDKErrorAction_IgnoreError_class =
4455                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
4456         CHECK(LDKErrorAction_IgnoreError_class != NULL);
4457         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
4458         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
4459         LDKErrorAction_IgnoreAndLog_class =
4460                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
4461         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
4462         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
4463         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
4464         LDKErrorAction_IgnoreDuplicateGossip_class =
4465                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
4466         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
4467         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
4468         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
4469         LDKErrorAction_SendErrorMessage_class =
4470                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
4471         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
4472         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
4473         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
4474         LDKErrorAction_SendWarningMessage_class =
4475                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
4476         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
4477         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
4478         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
4479 }
4480 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4481         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4482         switch(obj->tag) {
4483                 case LDKErrorAction_DisconnectPeer: {
4484                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
4485                         int64_t msg_ref = 0;
4486                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4487                         msg_ref = tag_ptr(msg_var.inner, false);
4488                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
4489                 }
4490                 case LDKErrorAction_IgnoreError: {
4491                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
4492                 }
4493                 case LDKErrorAction_IgnoreAndLog: {
4494                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
4495                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
4496                 }
4497                 case LDKErrorAction_IgnoreDuplicateGossip: {
4498                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
4499                 }
4500                 case LDKErrorAction_SendErrorMessage: {
4501                         LDKErrorMessage msg_var = obj->send_error_message.msg;
4502                         int64_t msg_ref = 0;
4503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4504                         msg_ref = tag_ptr(msg_var.inner, false);
4505                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
4506                 }
4507                 case LDKErrorAction_SendWarningMessage: {
4508                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
4509                         int64_t msg_ref = 0;
4510                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4511                         msg_ref = tag_ptr(msg_var.inner, false);
4512                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
4513                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
4514                 }
4515                 default: abort();
4516         }
4517 }
4518 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
4519 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
4520 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
4521 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
4522 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
4523 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
4524 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
4525 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
4526 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
4527 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
4528 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
4529 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
4530 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
4531 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
4532 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
4533 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
4534 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
4535 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
4536 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
4537 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
4538 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
4539 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
4540 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
4541 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
4542 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
4543 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
4544 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
4545 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
4546 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
4547 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
4548 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
4549 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
4550 static jclass LDKMessageSendEvent_HandleError_class = NULL;
4551 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
4552 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
4553 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
4554 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
4555 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
4556 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
4557 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
4558 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
4559 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
4560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
4561         LDKMessageSendEvent_SendAcceptChannel_class =
4562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
4563         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
4564         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
4565         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
4566         LDKMessageSendEvent_SendOpenChannel_class =
4567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
4568         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
4569         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
4570         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
4571         LDKMessageSendEvent_SendFundingCreated_class =
4572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
4573         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
4574         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
4575         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
4576         LDKMessageSendEvent_SendFundingSigned_class =
4577                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
4578         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
4579         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
4580         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
4581         LDKMessageSendEvent_SendChannelReady_class =
4582                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
4583         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
4584         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
4585         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
4586         LDKMessageSendEvent_SendAnnouncementSignatures_class =
4587                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
4588         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
4589         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
4590         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
4591         LDKMessageSendEvent_UpdateHTLCs_class =
4592                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
4593         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
4594         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
4595         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
4596         LDKMessageSendEvent_SendRevokeAndACK_class =
4597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
4598         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
4599         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
4600         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
4601         LDKMessageSendEvent_SendClosingSigned_class =
4602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
4603         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
4604         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
4605         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
4606         LDKMessageSendEvent_SendShutdown_class =
4607                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
4608         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
4609         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
4610         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
4611         LDKMessageSendEvent_SendChannelReestablish_class =
4612                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
4613         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
4614         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
4615         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
4616         LDKMessageSendEvent_SendChannelAnnouncement_class =
4617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
4618         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
4619         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
4620         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
4621         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
4622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
4623         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
4624         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
4625         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
4626         LDKMessageSendEvent_BroadcastChannelUpdate_class =
4627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
4628         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
4629         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
4630         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
4631         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
4632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
4633         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
4634         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
4635         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
4636         LDKMessageSendEvent_SendChannelUpdate_class =
4637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
4638         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
4639         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
4640         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
4641         LDKMessageSendEvent_HandleError_class =
4642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
4643         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
4644         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
4645         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
4646         LDKMessageSendEvent_SendChannelRangeQuery_class =
4647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
4648         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
4649         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
4650         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
4651         LDKMessageSendEvent_SendShortIdsQuery_class =
4652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
4653         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
4654         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
4655         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
4656         LDKMessageSendEvent_SendReplyChannelRange_class =
4657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
4658         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
4659         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
4660         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
4661         LDKMessageSendEvent_SendGossipTimestampFilter_class =
4662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
4663         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
4664         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
4665         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
4666 }
4667 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4668         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4669         switch(obj->tag) {
4670                 case LDKMessageSendEvent_SendAcceptChannel: {
4671                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4672                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
4673                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
4674                         int64_t msg_ref = 0;
4675                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4676                         msg_ref = tag_ptr(msg_var.inner, false);
4677                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
4678                 }
4679                 case LDKMessageSendEvent_SendOpenChannel: {
4680                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4681                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
4682                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
4683                         int64_t msg_ref = 0;
4684                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4685                         msg_ref = tag_ptr(msg_var.inner, false);
4686                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
4687                 }
4688                 case LDKMessageSendEvent_SendFundingCreated: {
4689                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4690                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
4691                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
4692                         int64_t msg_ref = 0;
4693                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4694                         msg_ref = tag_ptr(msg_var.inner, false);
4695                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
4696                 }
4697                 case LDKMessageSendEvent_SendFundingSigned: {
4698                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4699                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
4700                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
4701                         int64_t msg_ref = 0;
4702                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4703                         msg_ref = tag_ptr(msg_var.inner, false);
4704                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
4705                 }
4706                 case LDKMessageSendEvent_SendChannelReady: {
4707                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4708                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
4709                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
4710                         int64_t msg_ref = 0;
4711                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4712                         msg_ref = tag_ptr(msg_var.inner, false);
4713                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
4714                 }
4715                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
4716                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4717                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
4718                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
4719                         int64_t msg_ref = 0;
4720                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4721                         msg_ref = tag_ptr(msg_var.inner, false);
4722                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
4723                 }
4724                 case LDKMessageSendEvent_UpdateHTLCs: {
4725                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4726                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
4727                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
4728                         int64_t updates_ref = 0;
4729                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
4730                         updates_ref = tag_ptr(updates_var.inner, false);
4731                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
4732                 }
4733                 case LDKMessageSendEvent_SendRevokeAndACK: {
4734                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4735                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
4736                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
4737                         int64_t msg_ref = 0;
4738                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4739                         msg_ref = tag_ptr(msg_var.inner, false);
4740                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
4741                 }
4742                 case LDKMessageSendEvent_SendClosingSigned: {
4743                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4744                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
4745                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
4746                         int64_t msg_ref = 0;
4747                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4748                         msg_ref = tag_ptr(msg_var.inner, false);
4749                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
4750                 }
4751                 case LDKMessageSendEvent_SendShutdown: {
4752                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4753                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
4754                         LDKShutdown msg_var = obj->send_shutdown.msg;
4755                         int64_t msg_ref = 0;
4756                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4757                         msg_ref = tag_ptr(msg_var.inner, false);
4758                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
4759                 }
4760                 case LDKMessageSendEvent_SendChannelReestablish: {
4761                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4762                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
4763                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
4764                         int64_t msg_ref = 0;
4765                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4766                         msg_ref = tag_ptr(msg_var.inner, false);
4767                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
4768                 }
4769                 case LDKMessageSendEvent_SendChannelAnnouncement: {
4770                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4771                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
4772                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
4773                         int64_t msg_ref = 0;
4774                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4775                         msg_ref = tag_ptr(msg_var.inner, false);
4776                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
4777                         int64_t update_msg_ref = 0;
4778                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4779                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4780                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
4781                 }
4782                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
4783                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
4784                         int64_t msg_ref = 0;
4785                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4786                         msg_ref = tag_ptr(msg_var.inner, false);
4787                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
4788                         int64_t update_msg_ref = 0;
4789                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4790                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4791                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
4792                 }
4793                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
4794                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
4795                         int64_t msg_ref = 0;
4796                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4797                         msg_ref = tag_ptr(msg_var.inner, false);
4798                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
4799                 }
4800                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
4801                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
4802                         int64_t msg_ref = 0;
4803                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4804                         msg_ref = tag_ptr(msg_var.inner, false);
4805                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
4806                 }
4807                 case LDKMessageSendEvent_SendChannelUpdate: {
4808                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4809                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
4810                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
4811                         int64_t msg_ref = 0;
4812                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4813                         msg_ref = tag_ptr(msg_var.inner, false);
4814                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
4815                 }
4816                 case LDKMessageSendEvent_HandleError: {
4817                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4818                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
4819                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
4820                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
4821                 }
4822                 case LDKMessageSendEvent_SendChannelRangeQuery: {
4823                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4824                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
4825                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
4826                         int64_t msg_ref = 0;
4827                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4828                         msg_ref = tag_ptr(msg_var.inner, false);
4829                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
4830                 }
4831                 case LDKMessageSendEvent_SendShortIdsQuery: {
4832                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4833                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
4834                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
4835                         int64_t msg_ref = 0;
4836                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4837                         msg_ref = tag_ptr(msg_var.inner, false);
4838                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
4839                 }
4840                 case LDKMessageSendEvent_SendReplyChannelRange: {
4841                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4842                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
4843                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
4844                         int64_t msg_ref = 0;
4845                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4846                         msg_ref = tag_ptr(msg_var.inner, false);
4847                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
4848                 }
4849                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
4850                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4851                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
4852                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
4853                         int64_t msg_ref = 0;
4854                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4855                         msg_ref = tag_ptr(msg_var.inner, false);
4856                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
4857                 }
4858                 default: abort();
4859         }
4860 }
4861 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
4862         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
4863         for (size_t i = 0; i < ret.datalen; i++) {
4864                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
4865         }
4866         return ret;
4867 }
4868 static inline LDKCVec_ChainHashZ CVec_ChainHashZ_clone(const LDKCVec_ChainHashZ *orig) {
4869         LDKCVec_ChainHashZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ChainHashZ clone bytes"), .datalen = orig->datalen };
4870         for (size_t i = 0; i < ret.datalen; i++) {
4871                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4872         }
4873         return ret;
4874 }
4875 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
4876 CHECK(owner->result_ok);
4877         return *owner->contents.result;
4878 }
4879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4880         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
4881         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
4883         return ret_arr;
4884 }
4885
4886 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
4887 CHECK(!owner->result_ok);
4888         return *owner->contents.err;
4889 }
4890 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4891         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
4892         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
4893         return ret_conv;
4894 }
4895
4896 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4897         LDKNodeId ret = *owner->contents.result;
4898         ret.is_owned = false;
4899         return ret;
4900 }
4901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4902         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4903         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4904         int64_t ret_ref = 0;
4905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4907         return ret_ref;
4908 }
4909
4910 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4911 CHECK(!owner->result_ok);
4912         return DecodeError_clone(&*owner->contents.err);
4913 }
4914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4915         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4916         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4917         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4918         int64_t ret_ref = tag_ptr(ret_copy, true);
4919         return ret_ref;
4920 }
4921
4922 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4923 CHECK(owner->result_ok);
4924         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4925 }
4926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4927         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4928         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4929         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4930         int64_t ret_ref = tag_ptr(ret_copy, true);
4931         return ret_ref;
4932 }
4933
4934 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4935 CHECK(!owner->result_ok);
4936         return DecodeError_clone(&*owner->contents.err);
4937 }
4938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4939         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4940         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4941         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4942         int64_t ret_ref = tag_ptr(ret_copy, true);
4943         return ret_ref;
4944 }
4945
4946 static inline struct LDKTxOut CResult_TxOutUtxoLookupErrorZ_get_ok(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4947 CHECK(owner->result_ok);
4948         return TxOut_clone(&*owner->contents.result);
4949 }
4950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4951         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4952         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4953         *ret_ref = CResult_TxOutUtxoLookupErrorZ_get_ok(owner_conv);
4954         return tag_ptr(ret_ref, true);
4955 }
4956
4957 static inline enum LDKUtxoLookupError CResult_TxOutUtxoLookupErrorZ_get_err(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4958 CHECK(!owner->result_ok);
4959         return UtxoLookupError_clone(&*owner->contents.err);
4960 }
4961 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4962         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4963         jclass ret_conv = LDKUtxoLookupError_to_java(env, CResult_TxOutUtxoLookupErrorZ_get_err(owner_conv));
4964         return ret_conv;
4965 }
4966
4967 static jclass LDKUtxoResult_Sync_class = NULL;
4968 static jmethodID LDKUtxoResult_Sync_meth = NULL;
4969 static jclass LDKUtxoResult_Async_class = NULL;
4970 static jmethodID LDKUtxoResult_Async_meth = NULL;
4971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUtxoResult_init (JNIEnv *env, jclass clz) {
4972         LDKUtxoResult_Sync_class =
4973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Sync"));
4974         CHECK(LDKUtxoResult_Sync_class != NULL);
4975         LDKUtxoResult_Sync_meth = (*env)->GetMethodID(env, LDKUtxoResult_Sync_class, "<init>", "(J)V");
4976         CHECK(LDKUtxoResult_Sync_meth != NULL);
4977         LDKUtxoResult_Async_class =
4978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Async"));
4979         CHECK(LDKUtxoResult_Async_class != NULL);
4980         LDKUtxoResult_Async_meth = (*env)->GetMethodID(env, LDKUtxoResult_Async_class, "<init>", "(J)V");
4981         CHECK(LDKUtxoResult_Async_meth != NULL);
4982 }
4983 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUtxoResult_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4984         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
4985         switch(obj->tag) {
4986                 case LDKUtxoResult_Sync: {
4987                         LDKCResult_TxOutUtxoLookupErrorZ* sync_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
4988                         *sync_conv = obj->sync;
4989                         *sync_conv = CResult_TxOutUtxoLookupErrorZ_clone(sync_conv);
4990                         return (*env)->NewObject(env, LDKUtxoResult_Sync_class, LDKUtxoResult_Sync_meth, tag_ptr(sync_conv, true));
4991                 }
4992                 case LDKUtxoResult_Async: {
4993                         LDKUtxoFuture async_var = obj->async;
4994                         int64_t async_ref = 0;
4995                         CHECK_INNER_FIELD_ACCESS_OR_NULL(async_var);
4996                         async_ref = tag_ptr(async_var.inner, false);
4997                         return (*env)->NewObject(env, LDKUtxoResult_Async_class, LDKUtxoResult_Async_meth, async_ref);
4998                 }
4999                 default: abort();
5000         }
5001 }
5002 typedef struct LDKUtxoLookup_JCalls {
5003         atomic_size_t refcnt;
5004         JavaVM *vm;
5005         jweak o;
5006         jmethodID get_utxo_meth;
5007 } LDKUtxoLookup_JCalls;
5008 static void LDKUtxoLookup_JCalls_free(void* this_arg) {
5009         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
5010         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5011                 JNIEnv *env;
5012                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5013                 if (get_jenv_res == JNI_EDETACHED) {
5014                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5015                 } else {
5016                         DO_ASSERT(get_jenv_res == JNI_OK);
5017                 }
5018                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5019                 if (get_jenv_res == JNI_EDETACHED) {
5020                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5021                 }
5022                 FREE(j_calls);
5023         }
5024 }
5025 LDKUtxoResult get_utxo_LDKUtxoLookup_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5026         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
5027         JNIEnv *env;
5028         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5029         if (get_jenv_res == JNI_EDETACHED) {
5030                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5031         } else {
5032                 DO_ASSERT(get_jenv_res == JNI_OK);
5033         }
5034         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
5035         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
5036         int64_t short_channel_id_conv = short_channel_id;
5037         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5038         CHECK(obj != NULL);
5039         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
5040         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5041                 (*env)->ExceptionDescribe(env);
5042                 (*env)->FatalError(env, "A call to get_utxo in LDKUtxoLookup from rust threw an exception.");
5043         }
5044         void* ret_ptr = untag_ptr(ret);
5045         CHECK_ACCESS(ret_ptr);
5046         LDKUtxoResult ret_conv = *(LDKUtxoResult*)(ret_ptr);
5047         FREE(untag_ptr(ret));
5048         if (get_jenv_res == JNI_EDETACHED) {
5049                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5050         }
5051         return ret_conv;
5052 }
5053 static void LDKUtxoLookup_JCalls_cloned(LDKUtxoLookup* new_obj) {
5054         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) new_obj->this_arg;
5055         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5056 }
5057 static inline LDKUtxoLookup LDKUtxoLookup_init (JNIEnv *env, jclass clz, jobject o) {
5058         jclass c = (*env)->GetObjectClass(env, o);
5059         CHECK(c != NULL);
5060         LDKUtxoLookup_JCalls *calls = MALLOC(sizeof(LDKUtxoLookup_JCalls), "LDKUtxoLookup_JCalls");
5061         atomic_init(&calls->refcnt, 1);
5062         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5063         calls->o = (*env)->NewWeakGlobalRef(env, o);
5064         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
5065         CHECK(calls->get_utxo_meth != NULL);
5066
5067         LDKUtxoLookup ret = {
5068                 .this_arg = (void*) calls,
5069                 .get_utxo = get_utxo_LDKUtxoLookup_jcall,
5070                 .free = LDKUtxoLookup_JCalls_free,
5071         };
5072         return ret;
5073 }
5074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKUtxoLookup_1new(JNIEnv *env, jclass clz, jobject o) {
5075         LDKUtxoLookup *res_ptr = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
5076         *res_ptr = LDKUtxoLookup_init(env, clz, o);
5077         return tag_ptr(res_ptr, true);
5078 }
5079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
5080         void* this_arg_ptr = untag_ptr(this_arg);
5081         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5082         LDKUtxoLookup* this_arg_conv = (LDKUtxoLookup*)this_arg_ptr;
5083         uint8_t genesis_hash_arr[32];
5084         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
5085         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
5086         uint8_t (*genesis_hash_ref)[32] = &genesis_hash_arr;
5087         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
5088         *ret_copy = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
5089         int64_t ret_ref = tag_ptr(ret_copy, true);
5090         return ret_ref;
5091 }
5092
5093 static jclass LDKCOption_UtxoLookupZ_Some_class = NULL;
5094 static jmethodID LDKCOption_UtxoLookupZ_Some_meth = NULL;
5095 static jclass LDKCOption_UtxoLookupZ_None_class = NULL;
5096 static jmethodID LDKCOption_UtxoLookupZ_None_meth = NULL;
5097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1UtxoLookupZ_init (JNIEnv *env, jclass clz) {
5098         LDKCOption_UtxoLookupZ_Some_class =
5099                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$Some"));
5100         CHECK(LDKCOption_UtxoLookupZ_Some_class != NULL);
5101         LDKCOption_UtxoLookupZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_Some_class, "<init>", "(J)V");
5102         CHECK(LDKCOption_UtxoLookupZ_Some_meth != NULL);
5103         LDKCOption_UtxoLookupZ_None_class =
5104                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$None"));
5105         CHECK(LDKCOption_UtxoLookupZ_None_class != NULL);
5106         LDKCOption_UtxoLookupZ_None_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_None_class, "<init>", "()V");
5107         CHECK(LDKCOption_UtxoLookupZ_None_meth != NULL);
5108 }
5109 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1UtxoLookupZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5110         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
5111         switch(obj->tag) {
5112                 case LDKCOption_UtxoLookupZ_Some: {
5113                         LDKUtxoLookup* some_ret = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
5114                         *some_ret = obj->some;
5115                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
5116                         if ((*some_ret).free == LDKUtxoLookup_JCalls_free) {
5117                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5118                                 LDKUtxoLookup_JCalls_cloned(&(*some_ret));
5119                         }
5120                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_Some_class, LDKCOption_UtxoLookupZ_Some_meth, tag_ptr(some_ret, true));
5121                 }
5122                 case LDKCOption_UtxoLookupZ_None: {
5123                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_None_class, LDKCOption_UtxoLookupZ_None_meth);
5124                 }
5125                 default: abort();
5126         }
5127 }
5128 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5129 CHECK(owner->result_ok);
5130         return *owner->contents.result;
5131 }
5132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5133         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
5134         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
5135         return ret_conv;
5136 }
5137
5138 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5139         LDKLightningError ret = *owner->contents.err;
5140         ret.is_owned = false;
5141         return ret;
5142 }
5143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5144         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
5145         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5146         int64_t ret_ref = 0;
5147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5149         return ret_ref;
5150 }
5151
5152 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5153         LDKChannelAnnouncement ret = owner->a;
5154         ret.is_owned = false;
5155         return ret;
5156 }
5157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5158         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5159         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
5160         int64_t ret_ref = 0;
5161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5163         return ret_ref;
5164 }
5165
5166 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5167         LDKChannelUpdate ret = owner->b;
5168         ret.is_owned = false;
5169         return ret;
5170 }
5171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5172         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5173         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5174         int64_t ret_ref = 0;
5175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5177         return ret_ref;
5178 }
5179
5180 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5181         LDKChannelUpdate ret = owner->c;
5182         ret.is_owned = false;
5183         return ret;
5184 }
5185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
5186         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5187         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5188         int64_t ret_ref = 0;
5189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5191         return ret_ref;
5192 }
5193
5194 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
5195 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
5196 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
5197 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
5198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
5199         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
5200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
5201         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
5202         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
5203         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
5204         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
5205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
5206         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
5207         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
5208         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
5209 }
5210 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5211         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
5212         switch(obj->tag) {
5213                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
5214                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5215                         *some_conv = obj->some;
5216                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
5217                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
5218                 }
5219                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
5220                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
5221                 }
5222                 default: abort();
5223         }
5224 }
5225 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5226 CHECK(owner->result_ok);
5227         return *owner->contents.result;
5228 }
5229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5230         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5231         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5232 }
5233
5234 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5235         LDKLightningError ret = *owner->contents.err;
5236         ret.is_owned = false;
5237         return ret;
5238 }
5239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5240         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5241         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5242         int64_t ret_ref = 0;
5243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5245         return ret_ref;
5246 }
5247
5248 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5249         LDKChannelUpdateInfo ret = *owner->contents.result;
5250         ret.is_owned = false;
5251         return ret;
5252 }
5253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5254         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5255         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
5256         int64_t ret_ref = 0;
5257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5259         return ret_ref;
5260 }
5261
5262 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5263 CHECK(!owner->result_ok);
5264         return DecodeError_clone(&*owner->contents.err);
5265 }
5266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5267         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5268         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5269         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
5270         int64_t ret_ref = tag_ptr(ret_copy, true);
5271         return ret_ref;
5272 }
5273
5274 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5275         LDKChannelInfo ret = *owner->contents.result;
5276         ret.is_owned = false;
5277         return ret;
5278 }
5279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5280         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5281         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
5282         int64_t ret_ref = 0;
5283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5285         return ret_ref;
5286 }
5287
5288 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5289 CHECK(!owner->result_ok);
5290         return DecodeError_clone(&*owner->contents.err);
5291 }
5292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5293         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5294         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5295         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
5296         int64_t ret_ref = tag_ptr(ret_copy, true);
5297         return ret_ref;
5298 }
5299
5300 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5301         LDKRoutingFees ret = *owner->contents.result;
5302         ret.is_owned = false;
5303         return ret;
5304 }
5305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5306         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5307         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
5308         int64_t ret_ref = 0;
5309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5311         return ret_ref;
5312 }
5313
5314 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5315 CHECK(!owner->result_ok);
5316         return DecodeError_clone(&*owner->contents.err);
5317 }
5318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5319         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5320         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5321         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
5322         int64_t ret_ref = tag_ptr(ret_copy, true);
5323         return ret_ref;
5324 }
5325
5326 static jclass LDKNetAddress_IPv4_class = NULL;
5327 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5328 static jclass LDKNetAddress_IPv6_class = NULL;
5329 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5330 static jclass LDKNetAddress_OnionV2_class = NULL;
5331 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5332 static jclass LDKNetAddress_OnionV3_class = NULL;
5333 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5334 static jclass LDKNetAddress_Hostname_class = NULL;
5335 static jmethodID LDKNetAddress_Hostname_meth = NULL;
5336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5337         LDKNetAddress_IPv4_class =
5338                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5339         CHECK(LDKNetAddress_IPv4_class != NULL);
5340         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5341         CHECK(LDKNetAddress_IPv4_meth != NULL);
5342         LDKNetAddress_IPv6_class =
5343                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5344         CHECK(LDKNetAddress_IPv6_class != NULL);
5345         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5346         CHECK(LDKNetAddress_IPv6_meth != NULL);
5347         LDKNetAddress_OnionV2_class =
5348                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5349         CHECK(LDKNetAddress_OnionV2_class != NULL);
5350         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5351         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5352         LDKNetAddress_OnionV3_class =
5353                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5354         CHECK(LDKNetAddress_OnionV3_class != NULL);
5355         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5356         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5357         LDKNetAddress_Hostname_class =
5358                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
5359         CHECK(LDKNetAddress_Hostname_class != NULL);
5360         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
5361         CHECK(LDKNetAddress_Hostname_meth != NULL);
5362 }
5363 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5364         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
5365         switch(obj->tag) {
5366                 case LDKNetAddress_IPv4: {
5367                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5368                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5369                         int16_t port_conv = obj->i_pv4.port;
5370                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
5371                 }
5372                 case LDKNetAddress_IPv6: {
5373                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5374                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5375                         int16_t port_conv = obj->i_pv6.port;
5376                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
5377                 }
5378                 case LDKNetAddress_OnionV2: {
5379                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5380                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5381                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5382                 }
5383                 case LDKNetAddress_OnionV3: {
5384                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5385                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5386                         int16_t checksum_conv = obj->onion_v3.checksum;
5387                         int8_t version_conv = obj->onion_v3.version;
5388                         int16_t port_conv = obj->onion_v3.port;
5389                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
5390                 }
5391                 case LDKNetAddress_Hostname: {
5392                         LDKHostname hostname_var = obj->hostname.hostname;
5393                         int64_t hostname_ref = 0;
5394                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
5395                         hostname_ref = tag_ptr(hostname_var.inner, false);
5396                         int16_t port_conv = obj->hostname.port;
5397                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
5398                 }
5399                 default: abort();
5400         }
5401 }
5402 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5403         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5404         for (size_t i = 0; i < ret.datalen; i++) {
5405                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5406         }
5407         return ret;
5408 }
5409 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5410         LDKNodeAnnouncementInfo ret = *owner->contents.result;
5411         ret.is_owned = false;
5412         return ret;
5413 }
5414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5415         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5416         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
5417         int64_t ret_ref = 0;
5418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5420         return ret_ref;
5421 }
5422
5423 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5424 CHECK(!owner->result_ok);
5425         return DecodeError_clone(&*owner->contents.err);
5426 }
5427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5428         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5429         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5430         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
5431         int64_t ret_ref = tag_ptr(ret_copy, true);
5432         return ret_ref;
5433 }
5434
5435 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5436         LDKNodeAlias ret = *owner->contents.result;
5437         ret.is_owned = false;
5438         return ret;
5439 }
5440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5441         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5442         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
5443         int64_t ret_ref = 0;
5444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5446         return ret_ref;
5447 }
5448
5449 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5450 CHECK(!owner->result_ok);
5451         return DecodeError_clone(&*owner->contents.err);
5452 }
5453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5454         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5455         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5456         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
5457         int64_t ret_ref = tag_ptr(ret_copy, true);
5458         return ret_ref;
5459 }
5460
5461 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5462         LDKNodeInfo ret = *owner->contents.result;
5463         ret.is_owned = false;
5464         return ret;
5465 }
5466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5467         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5468         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
5469         int64_t ret_ref = 0;
5470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5472         return ret_ref;
5473 }
5474
5475 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5476 CHECK(!owner->result_ok);
5477         return DecodeError_clone(&*owner->contents.err);
5478 }
5479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5480         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5481         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5482         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
5483         int64_t ret_ref = tag_ptr(ret_copy, true);
5484         return ret_ref;
5485 }
5486
5487 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5488         LDKNetworkGraph ret = *owner->contents.result;
5489         ret.is_owned = false;
5490         return ret;
5491 }
5492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5493         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5494         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
5495         int64_t ret_ref = 0;
5496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5498         return ret_ref;
5499 }
5500
5501 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5502 CHECK(!owner->result_ok);
5503         return DecodeError_clone(&*owner->contents.err);
5504 }
5505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5506         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5507         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5508         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
5509         int64_t ret_ref = tag_ptr(ret_copy, true);
5510         return ret_ref;
5511 }
5512
5513 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
5514 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
5515 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
5516 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
5517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
5518         LDKCOption_CVec_NetAddressZZ_Some_class =
5519                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
5520         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
5521         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
5522         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
5523         LDKCOption_CVec_NetAddressZZ_None_class =
5524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
5525         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
5526         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
5527         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
5528 }
5529 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5530         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
5531         switch(obj->tag) {
5532                 case LDKCOption_CVec_NetAddressZZ_Some: {
5533                         LDKCVec_NetAddressZ some_var = obj->some;
5534                         int64_tArray some_arr = NULL;
5535                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
5536                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
5537                         for (size_t m = 0; m < some_var.datalen; m++) {
5538                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
5539                                 some_arr_ptr[m] = some_conv_12_ref;
5540                         }
5541                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
5542                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
5543                 }
5544                 case LDKCOption_CVec_NetAddressZZ_None: {
5545                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
5546                 }
5547                 default: abort();
5548         }
5549 }
5550 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5551         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
5552         ret.is_owned = false;
5553         return ret;
5554 }
5555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5556         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5557         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5558         int64_t ret_ref = 0;
5559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5561         return ret_ref;
5562 }
5563
5564 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5565 CHECK(!owner->result_ok);
5566         return DecodeError_clone(&*owner->contents.err);
5567 }
5568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5569         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5570         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5571         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5572         int64_t ret_ref = tag_ptr(ret_copy, true);
5573         return ret_ref;
5574 }
5575
5576 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5577         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
5578         ret.is_owned = false;
5579         return ret;
5580 }
5581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5582         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5583         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5584         int64_t ret_ref = 0;
5585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5587         return ret_ref;
5588 }
5589
5590 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5591 CHECK(!owner->result_ok);
5592         return DecodeError_clone(&*owner->contents.err);
5593 }
5594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5595         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5596         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5597         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5598         int64_t ret_ref = tag_ptr(ret_copy, true);
5599         return ret_ref;
5600 }
5601
5602 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5603 CHECK(owner->result_ok);
5604         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5605 }
5606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5607         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5608         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5609         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5610         int64_t ret_ref = tag_ptr(ret_copy, true);
5611         return ret_ref;
5612 }
5613
5614 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5615 CHECK(!owner->result_ok);
5616         return DecodeError_clone(&*owner->contents.err);
5617 }
5618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5619         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5620         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5621         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5622         int64_t ret_ref = tag_ptr(ret_copy, true);
5623         return ret_ref;
5624 }
5625
5626 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
5627         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
5628         for (size_t i = 0; i < ret.datalen; i++) {
5629                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5630         }
5631         return ret;
5632 }
5633 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5634         return owner->a;
5635 }
5636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5637         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5638         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5639         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
5640         return ret_arr;
5641 }
5642
5643 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5644         return owner->b;
5645 }
5646 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5647         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5648         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
5649         jobjectArray ret_arr = NULL;
5650         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5651         ;
5652         for (size_t i = 0; i < ret_var.datalen; i++) {
5653                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5654                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5655                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5656         }
5657         
5658         return ret_arr;
5659 }
5660
5661 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5662 CHECK(owner->result_ok);
5663         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5664 }
5665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5666         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5667         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5668         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5669         return tag_ptr(ret_conv, true);
5670 }
5671
5672 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5673 CHECK(!owner->result_ok);
5674         return *owner->contents.err;
5675 }
5676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5677         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5678         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5679 }
5680
5681 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5682 CHECK(owner->result_ok);
5683         return *owner->contents.result;
5684 }
5685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5686         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5687         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5689         return ret_arr;
5690 }
5691
5692 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5693 CHECK(!owner->result_ok);
5694         return *owner->contents.err;
5695 }
5696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5697         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5698         CResult_SignatureNoneZ_get_err(owner_conv);
5699 }
5700
5701 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5702 CHECK(owner->result_ok);
5703         return *owner->contents.result;
5704 }
5705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5706         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5707         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5709         return ret_arr;
5710 }
5711
5712 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5713 CHECK(!owner->result_ok);
5714         return *owner->contents.err;
5715 }
5716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5717         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5718         CResult_PublicKeyNoneZ_get_err(owner_conv);
5719 }
5720
5721 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5722 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5723 static jclass LDKCOption_ScalarZ_None_class = NULL;
5724 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5726         LDKCOption_ScalarZ_Some_class =
5727                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5728         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5729         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5730         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5731         LDKCOption_ScalarZ_None_class =
5732                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5733         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5734         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5735         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5736 }
5737 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5738         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5739         switch(obj->tag) {
5740                 case LDKCOption_ScalarZ_Some: {
5741                         LDKBigEndianScalar* some_ref = &obj->some;
5742                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5743                 }
5744                 case LDKCOption_ScalarZ_None: {
5745                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5746                 }
5747                 default: abort();
5748         }
5749 }
5750 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5751 CHECK(owner->result_ok);
5752         return ThirtyTwoBytes_clone(&*owner->contents.result);
5753 }
5754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5755         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5756         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5758         return ret_arr;
5759 }
5760
5761 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5762 CHECK(!owner->result_ok);
5763         return *owner->contents.err;
5764 }
5765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5766         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5767         CResult_SharedSecretNoneZ_get_err(owner_conv);
5768 }
5769
5770 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5771 CHECK(owner->result_ok);
5772         return *owner->contents.result;
5773 }
5774 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5775         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5776         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5778         return ret_arr;
5779 }
5780
5781 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5782 CHECK(!owner->result_ok);
5783         return *owner->contents.err;
5784 }
5785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5786         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5787         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5788 }
5789
5790 typedef struct LDKChannelSigner_JCalls {
5791         atomic_size_t refcnt;
5792         JavaVM *vm;
5793         jweak o;
5794         jmethodID get_per_commitment_point_meth;
5795         jmethodID release_commitment_secret_meth;
5796         jmethodID validate_holder_commitment_meth;
5797         jmethodID channel_keys_id_meth;
5798         jmethodID provide_channel_parameters_meth;
5799 } LDKChannelSigner_JCalls;
5800 static void LDKChannelSigner_JCalls_free(void* this_arg) {
5801         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5802         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5803                 JNIEnv *env;
5804                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5805                 if (get_jenv_res == JNI_EDETACHED) {
5806                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5807                 } else {
5808                         DO_ASSERT(get_jenv_res == JNI_OK);
5809                 }
5810                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5811                 if (get_jenv_res == JNI_EDETACHED) {
5812                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5813                 }
5814                 FREE(j_calls);
5815         }
5816 }
5817 LDKPublicKey get_per_commitment_point_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5818         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5819         JNIEnv *env;
5820         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5821         if (get_jenv_res == JNI_EDETACHED) {
5822                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5823         } else {
5824                 DO_ASSERT(get_jenv_res == JNI_OK);
5825         }
5826         int64_t idx_conv = idx;
5827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5828         CHECK(obj != NULL);
5829         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5831                 (*env)->ExceptionDescribe(env);
5832                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKChannelSigner from rust threw an exception.");
5833         }
5834         LDKPublicKey ret_ref;
5835         CHECK((*env)->GetArrayLength(env, ret) == 33);
5836         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5837         if (get_jenv_res == JNI_EDETACHED) {
5838                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5839         }
5840         return ret_ref;
5841 }
5842 LDKThirtyTwoBytes release_commitment_secret_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5843         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5844         JNIEnv *env;
5845         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5846         if (get_jenv_res == JNI_EDETACHED) {
5847                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5848         } else {
5849                 DO_ASSERT(get_jenv_res == JNI_OK);
5850         }
5851         int64_t idx_conv = idx;
5852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5853         CHECK(obj != NULL);
5854         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5855         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5856                 (*env)->ExceptionDescribe(env);
5857                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKChannelSigner from rust threw an exception.");
5858         }
5859         LDKThirtyTwoBytes ret_ref;
5860         CHECK((*env)->GetArrayLength(env, ret) == 32);
5861         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5862         if (get_jenv_res == JNI_EDETACHED) {
5863                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5864         }
5865         return ret_ref;
5866 }
5867 LDKCResult_NoneNoneZ validate_holder_commitment_LDKChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5868         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5869         JNIEnv *env;
5870         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5871         if (get_jenv_res == JNI_EDETACHED) {
5872                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5873         } else {
5874                 DO_ASSERT(get_jenv_res == JNI_OK);
5875         }
5876         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5877         int64_t holder_tx_ref = 0;
5878         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5879         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5880         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5881         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5882         jobjectArray preimages_arr = NULL;
5883         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5884         ;
5885         for (size_t i = 0; i < preimages_var.datalen; i++) {
5886                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5887                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5888                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5889         }
5890         
5891         FREE(preimages_var.data);
5892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5893         CHECK(obj != NULL);
5894         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5895         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5896                 (*env)->ExceptionDescribe(env);
5897                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKChannelSigner from rust threw an exception.");
5898         }
5899         void* ret_ptr = untag_ptr(ret);
5900         CHECK_ACCESS(ret_ptr);
5901         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5902         FREE(untag_ptr(ret));
5903         if (get_jenv_res == JNI_EDETACHED) {
5904                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5905         }
5906         return ret_conv;
5907 }
5908 LDKThirtyTwoBytes channel_keys_id_LDKChannelSigner_jcall(const void* this_arg) {
5909         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5910         JNIEnv *env;
5911         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5912         if (get_jenv_res == JNI_EDETACHED) {
5913                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5914         } else {
5915                 DO_ASSERT(get_jenv_res == JNI_OK);
5916         }
5917         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5918         CHECK(obj != NULL);
5919         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5920         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5921                 (*env)->ExceptionDescribe(env);
5922                 (*env)->FatalError(env, "A call to channel_keys_id in LDKChannelSigner from rust threw an exception.");
5923         }
5924         LDKThirtyTwoBytes ret_ref;
5925         CHECK((*env)->GetArrayLength(env, ret) == 32);
5926         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5927         if (get_jenv_res == JNI_EDETACHED) {
5928                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5929         }
5930         return ret_ref;
5931 }
5932 void provide_channel_parameters_LDKChannelSigner_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5933         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5934         JNIEnv *env;
5935         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5936         if (get_jenv_res == JNI_EDETACHED) {
5937                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5938         } else {
5939                 DO_ASSERT(get_jenv_res == JNI_OK);
5940         }
5941         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5942         int64_t channel_parameters_ref = 0;
5943         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5944         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5945         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5946         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5947         CHECK(obj != NULL);
5948         (*env)->CallVoidMethod(env, obj, j_calls->provide_channel_parameters_meth, channel_parameters_ref);
5949         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5950                 (*env)->ExceptionDescribe(env);
5951                 (*env)->FatalError(env, "A call to provide_channel_parameters in LDKChannelSigner from rust threw an exception.");
5952         }
5953         if (get_jenv_res == JNI_EDETACHED) {
5954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5955         }
5956 }
5957 static inline LDKChannelSigner LDKChannelSigner_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5958         jclass c = (*env)->GetObjectClass(env, o);
5959         CHECK(c != NULL);
5960         LDKChannelSigner_JCalls *calls = MALLOC(sizeof(LDKChannelSigner_JCalls), "LDKChannelSigner_JCalls");
5961         atomic_init(&calls->refcnt, 1);
5962         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5963         calls->o = (*env)->NewWeakGlobalRef(env, o);
5964         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5965         CHECK(calls->get_per_commitment_point_meth != NULL);
5966         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5967         CHECK(calls->release_commitment_secret_meth != NULL);
5968         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5969         CHECK(calls->validate_holder_commitment_meth != NULL);
5970         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5971         CHECK(calls->channel_keys_id_meth != NULL);
5972         calls->provide_channel_parameters_meth = (*env)->GetMethodID(env, c, "provide_channel_parameters", "(J)V");
5973         CHECK(calls->provide_channel_parameters_meth != NULL);
5974
5975         LDKChannelPublicKeys pubkeys_conv;
5976         pubkeys_conv.inner = untag_ptr(pubkeys);
5977         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5978         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5979
5980         LDKChannelSigner ret = {
5981                 .this_arg = (void*) calls,
5982                 .get_per_commitment_point = get_per_commitment_point_LDKChannelSigner_jcall,
5983                 .release_commitment_secret = release_commitment_secret_LDKChannelSigner_jcall,
5984                 .validate_holder_commitment = validate_holder_commitment_LDKChannelSigner_jcall,
5985                 .channel_keys_id = channel_keys_id_LDKChannelSigner_jcall,
5986                 .provide_channel_parameters = provide_channel_parameters_LDKChannelSigner_jcall,
5987                 .free = LDKChannelSigner_JCalls_free,
5988                 .pubkeys = pubkeys_conv,
5989                 .set_pubkeys = NULL,
5990         };
5991         return ret;
5992 }
5993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5994         LDKChannelSigner *res_ptr = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
5995         *res_ptr = LDKChannelSigner_init(env, clz, o, pubkeys);
5996         return tag_ptr(res_ptr, true);
5997 }
5998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5999         void* this_arg_ptr = untag_ptr(this_arg);
6000         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6001         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6002         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
6003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
6004         return ret_arr;
6005 }
6006
6007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
6008         void* this_arg_ptr = untag_ptr(this_arg);
6009         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6010         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6011         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
6013         return ret_arr;
6014 }
6015
6016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx, jobjectArray preimages) {
6017         void* this_arg_ptr = untag_ptr(this_arg);
6018         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6019         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6020         LDKHolderCommitmentTransaction holder_tx_conv;
6021         holder_tx_conv.inner = untag_ptr(holder_tx);
6022         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
6023         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
6024         holder_tx_conv.is_owned = false;
6025         LDKCVec_PaymentPreimageZ preimages_constr;
6026         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
6027         if (preimages_constr.datalen > 0)
6028                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
6029         else
6030                 preimages_constr.data = NULL;
6031         for (size_t i = 0; i < preimages_constr.datalen; i++) {
6032                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
6033                 LDKThirtyTwoBytes preimages_conv_8_ref;
6034                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
6035                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
6036                 preimages_constr.data[i] = preimages_conv_8_ref;
6037         }
6038         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
6039         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
6040         return tag_ptr(ret_conv, true);
6041 }
6042
6043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6044         void* this_arg_ptr = untag_ptr(this_arg);
6045         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6046         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6047         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
6049         return ret_arr;
6050 }
6051
6052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1provide_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
6053         void* this_arg_ptr = untag_ptr(this_arg);
6054         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6055         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6056         LDKChannelTransactionParameters channel_parameters_conv;
6057         channel_parameters_conv.inner = untag_ptr(channel_parameters);
6058         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
6059         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
6060         channel_parameters_conv.is_owned = false;
6061         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
6062 }
6063
6064 LDKChannelPublicKeys LDKChannelSigner_set_get_pubkeys(LDKChannelSigner* this_arg) {
6065         if (this_arg->set_pubkeys != NULL)
6066                 this_arg->set_pubkeys(this_arg);
6067         return this_arg->pubkeys;
6068 }
6069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
6070         void* this_arg_ptr = untag_ptr(this_arg);
6071         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6072         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6073         LDKChannelPublicKeys ret_var = LDKChannelSigner_set_get_pubkeys(this_arg_conv);
6074         int64_t ret_ref = 0;
6075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6077         return ret_ref;
6078 }
6079
6080 typedef struct LDKEcdsaChannelSigner_JCalls {
6081         atomic_size_t refcnt;
6082         JavaVM *vm;
6083         jweak o;
6084         LDKChannelSigner_JCalls* ChannelSigner;
6085         jmethodID sign_counterparty_commitment_meth;
6086         jmethodID validate_counterparty_revocation_meth;
6087         jmethodID sign_holder_commitment_and_htlcs_meth;
6088         jmethodID sign_justice_revoked_output_meth;
6089         jmethodID sign_justice_revoked_htlc_meth;
6090         jmethodID sign_counterparty_htlc_transaction_meth;
6091         jmethodID sign_closing_transaction_meth;
6092         jmethodID sign_holder_anchor_input_meth;
6093         jmethodID sign_channel_announcement_with_funding_key_meth;
6094 } LDKEcdsaChannelSigner_JCalls;
6095 static void LDKEcdsaChannelSigner_JCalls_free(void* this_arg) {
6096         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6098                 JNIEnv *env;
6099                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6100                 if (get_jenv_res == JNI_EDETACHED) {
6101                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6102                 } else {
6103                         DO_ASSERT(get_jenv_res == JNI_OK);
6104                 }
6105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6106                 if (get_jenv_res == JNI_EDETACHED) {
6107                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6108                 }
6109                 FREE(j_calls);
6110         }
6111 }
6112 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
6113         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6114         JNIEnv *env;
6115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6116         if (get_jenv_res == JNI_EDETACHED) {
6117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6118         } else {
6119                 DO_ASSERT(get_jenv_res == JNI_OK);
6120         }
6121         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
6122         int64_t commitment_tx_ref = 0;
6123         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
6124         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
6125         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
6126         LDKCVec_PaymentPreimageZ preimages_var = preimages;
6127         jobjectArray preimages_arr = NULL;
6128         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
6129         ;
6130         for (size_t i = 0; i < preimages_var.datalen; i++) {
6131                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
6132                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
6133                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
6134         }
6135         
6136         FREE(preimages_var.data);
6137         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6138         CHECK(obj != NULL);
6139         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
6140         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6141                 (*env)->ExceptionDescribe(env);
6142                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKEcdsaChannelSigner from rust threw an exception.");
6143         }
6144         void* ret_ptr = untag_ptr(ret);
6145         CHECK_ACCESS(ret_ptr);
6146         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
6147         FREE(untag_ptr(ret));
6148         if (get_jenv_res == JNI_EDETACHED) {
6149                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6150         }
6151         return ret_conv;
6152 }
6153 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
6154         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6155         JNIEnv *env;
6156         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6157         if (get_jenv_res == JNI_EDETACHED) {
6158                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6159         } else {
6160                 DO_ASSERT(get_jenv_res == JNI_OK);
6161         }
6162         int64_t idx_conv = idx;
6163         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
6164         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
6165         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6166         CHECK(obj != NULL);
6167         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
6168         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6169                 (*env)->ExceptionDescribe(env);
6170                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKEcdsaChannelSigner from rust threw an exception.");
6171         }
6172         void* ret_ptr = untag_ptr(ret);
6173         CHECK_ACCESS(ret_ptr);
6174         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
6175         FREE(untag_ptr(ret));
6176         if (get_jenv_res == JNI_EDETACHED) {
6177                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6178         }
6179         return ret_conv;
6180 }
6181 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
6182         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6183         JNIEnv *env;
6184         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6185         if (get_jenv_res == JNI_EDETACHED) {
6186                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6187         } else {
6188                 DO_ASSERT(get_jenv_res == JNI_OK);
6189         }
6190         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
6191         int64_t commitment_tx_ref = 0;
6192         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
6193         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
6194         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
6195         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6196         CHECK(obj != NULL);
6197         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
6198         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6199                 (*env)->ExceptionDescribe(env);
6200                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKEcdsaChannelSigner from rust threw an exception.");
6201         }
6202         void* ret_ptr = untag_ptr(ret);
6203         CHECK_ACCESS(ret_ptr);
6204         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
6205         FREE(untag_ptr(ret));
6206         if (get_jenv_res == JNI_EDETACHED) {
6207                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6208         }
6209         return ret_conv;
6210 }
6211 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
6212         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6213         JNIEnv *env;
6214         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6215         if (get_jenv_res == JNI_EDETACHED) {
6216                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6217         } else {
6218                 DO_ASSERT(get_jenv_res == JNI_OK);
6219         }
6220         LDKTransaction justice_tx_var = justice_tx;
6221         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6222         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6223         Transaction_free(justice_tx_var);
6224         int64_t input_conv = input;
6225         int64_t amount_conv = amount;
6226         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6227         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6228         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6229         CHECK(obj != NULL);
6230         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);
6231         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6232                 (*env)->ExceptionDescribe(env);
6233                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKEcdsaChannelSigner from rust threw an exception.");
6234         }
6235         void* ret_ptr = untag_ptr(ret);
6236         CHECK_ACCESS(ret_ptr);
6237         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6238         FREE(untag_ptr(ret));
6239         if (get_jenv_res == JNI_EDETACHED) {
6240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6241         }
6242         return ret_conv;
6243 }
6244 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
6245         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6246         JNIEnv *env;
6247         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6248         if (get_jenv_res == JNI_EDETACHED) {
6249                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6250         } else {
6251                 DO_ASSERT(get_jenv_res == JNI_OK);
6252         }
6253         LDKTransaction justice_tx_var = justice_tx;
6254         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6255         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6256         Transaction_free(justice_tx_var);
6257         int64_t input_conv = input;
6258         int64_t amount_conv = amount;
6259         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6260         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6261         LDKHTLCOutputInCommitment htlc_var = *htlc;
6262         int64_t htlc_ref = 0;
6263         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6264         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6265         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6266         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6267         CHECK(obj != NULL);
6268         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);
6269         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6270                 (*env)->ExceptionDescribe(env);
6271                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKEcdsaChannelSigner from rust threw an exception.");
6272         }
6273         void* ret_ptr = untag_ptr(ret);
6274         CHECK_ACCESS(ret_ptr);
6275         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6276         FREE(untag_ptr(ret));
6277         if (get_jenv_res == JNI_EDETACHED) {
6278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6279         }
6280         return ret_conv;
6281 }
6282 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
6283         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6284         JNIEnv *env;
6285         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6286         if (get_jenv_res == JNI_EDETACHED) {
6287                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6288         } else {
6289                 DO_ASSERT(get_jenv_res == JNI_OK);
6290         }
6291         LDKTransaction htlc_tx_var = htlc_tx;
6292         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
6293         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
6294         Transaction_free(htlc_tx_var);
6295         int64_t input_conv = input;
6296         int64_t amount_conv = amount;
6297         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
6298         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
6299         LDKHTLCOutputInCommitment htlc_var = *htlc;
6300         int64_t htlc_ref = 0;
6301         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6302         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6303         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6305         CHECK(obj != NULL);
6306         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);
6307         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6308                 (*env)->ExceptionDescribe(env);
6309                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6310         }
6311         void* ret_ptr = untag_ptr(ret);
6312         CHECK_ACCESS(ret_ptr);
6313         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6314         FREE(untag_ptr(ret));
6315         if (get_jenv_res == JNI_EDETACHED) {
6316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6317         }
6318         return ret_conv;
6319 }
6320 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
6321         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6322         JNIEnv *env;
6323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6324         if (get_jenv_res == JNI_EDETACHED) {
6325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6326         } else {
6327                 DO_ASSERT(get_jenv_res == JNI_OK);
6328         }
6329         LDKClosingTransaction closing_tx_var = *closing_tx;
6330         int64_t closing_tx_ref = 0;
6331         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
6332         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
6333         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
6334         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6335         CHECK(obj != NULL);
6336         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
6337         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6338                 (*env)->ExceptionDescribe(env);
6339                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6340         }
6341         void* ret_ptr = untag_ptr(ret);
6342         CHECK_ACCESS(ret_ptr);
6343         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6344         FREE(untag_ptr(ret));
6345         if (get_jenv_res == JNI_EDETACHED) {
6346                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6347         }
6348         return ret_conv;
6349 }
6350 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
6351         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6352         JNIEnv *env;
6353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6354         if (get_jenv_res == JNI_EDETACHED) {
6355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6356         } else {
6357                 DO_ASSERT(get_jenv_res == JNI_OK);
6358         }
6359         LDKTransaction anchor_tx_var = anchor_tx;
6360         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
6361         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
6362         Transaction_free(anchor_tx_var);
6363         int64_t input_conv = input;
6364         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6365         CHECK(obj != NULL);
6366         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
6367         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6368                 (*env)->ExceptionDescribe(env);
6369                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKEcdsaChannelSigner from rust threw an exception.");
6370         }
6371         void* ret_ptr = untag_ptr(ret);
6372         CHECK_ACCESS(ret_ptr);
6373         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6374         FREE(untag_ptr(ret));
6375         if (get_jenv_res == JNI_EDETACHED) {
6376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6377         }
6378         return ret_conv;
6379 }
6380 LDKCResult_SignatureNoneZ sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
6381         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6382         JNIEnv *env;
6383         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6384         if (get_jenv_res == JNI_EDETACHED) {
6385                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6386         } else {
6387                 DO_ASSERT(get_jenv_res == JNI_OK);
6388         }
6389         LDKUnsignedChannelAnnouncement msg_var = *msg;
6390         int64_t msg_ref = 0;
6391         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
6392         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6393         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
6394         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6395         CHECK(obj != NULL);
6396         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_with_funding_key_meth, msg_ref);
6397         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6398                 (*env)->ExceptionDescribe(env);
6399                 (*env)->FatalError(env, "A call to sign_channel_announcement_with_funding_key in LDKEcdsaChannelSigner from rust threw an exception.");
6400         }
6401         void* ret_ptr = untag_ptr(ret);
6402         CHECK_ACCESS(ret_ptr);
6403         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6404         FREE(untag_ptr(ret));
6405         if (get_jenv_res == JNI_EDETACHED) {
6406                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6407         }
6408         return ret_conv;
6409 }
6410 static void LDKEcdsaChannelSigner_JCalls_cloned(LDKEcdsaChannelSigner* new_obj) {
6411         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6412         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6413         atomic_fetch_add_explicit(&j_calls->ChannelSigner->refcnt, 1, memory_order_release);
6414 }
6415 static inline LDKEcdsaChannelSigner LDKEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6416         jclass c = (*env)->GetObjectClass(env, o);
6417         CHECK(c != NULL);
6418         LDKEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKEcdsaChannelSigner_JCalls), "LDKEcdsaChannelSigner_JCalls");
6419         atomic_init(&calls->refcnt, 1);
6420         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6421         calls->o = (*env)->NewWeakGlobalRef(env, o);
6422         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
6423         CHECK(calls->sign_counterparty_commitment_meth != NULL);
6424         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
6425         CHECK(calls->validate_counterparty_revocation_meth != NULL);
6426         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
6427         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
6428         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
6429         CHECK(calls->sign_justice_revoked_output_meth != NULL);
6430         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
6431         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
6432         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
6433         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
6434         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
6435         CHECK(calls->sign_closing_transaction_meth != NULL);
6436         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
6437         CHECK(calls->sign_holder_anchor_input_meth != NULL);
6438         calls->sign_channel_announcement_with_funding_key_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement_with_funding_key", "(J)J");
6439         CHECK(calls->sign_channel_announcement_with_funding_key_meth != NULL);
6440
6441         LDKChannelPublicKeys pubkeys_conv;
6442         pubkeys_conv.inner = untag_ptr(pubkeys);
6443         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6444         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6445
6446         LDKEcdsaChannelSigner ret = {
6447                 .this_arg = (void*) calls,
6448                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall,
6449                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall,
6450                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall,
6451                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall,
6452                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall,
6453                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall,
6454                 .sign_closing_transaction = sign_closing_transaction_LDKEcdsaChannelSigner_jcall,
6455                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall,
6456                 .sign_channel_announcement_with_funding_key = sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall,
6457                 .free = LDKEcdsaChannelSigner_JCalls_free,
6458                 .ChannelSigner = LDKChannelSigner_init(env, clz, ChannelSigner, pubkeys),
6459         };
6460         calls->ChannelSigner = ret.ChannelSigner.this_arg;
6461         return ret;
6462 }
6463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6464         LDKEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
6465         *res_ptr = LDKEcdsaChannelSigner_init(env, clz, o, ChannelSigner, pubkeys);
6466         return tag_ptr(res_ptr, true);
6467 }
6468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6469         LDKEcdsaChannelSigner *inp = (LDKEcdsaChannelSigner *)untag_ptr(arg);
6470         return tag_ptr(&inp->ChannelSigner, false);
6471 }
6472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx, jobjectArray preimages) {
6473         void* this_arg_ptr = untag_ptr(this_arg);
6474         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6475         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6476         LDKCommitmentTransaction commitment_tx_conv;
6477         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6478         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6479         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6480         commitment_tx_conv.is_owned = false;
6481         LDKCVec_PaymentPreimageZ preimages_constr;
6482         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
6483         if (preimages_constr.datalen > 0)
6484                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
6485         else
6486                 preimages_constr.data = NULL;
6487         for (size_t i = 0; i < preimages_constr.datalen; i++) {
6488                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
6489                 LDKThirtyTwoBytes preimages_conv_8_ref;
6490                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
6491                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
6492                 preimages_constr.data[i] = preimages_conv_8_ref;
6493         }
6494         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6495         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
6496         return tag_ptr(ret_conv, true);
6497 }
6498
6499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
6500         void* this_arg_ptr = untag_ptr(this_arg);
6501         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6502         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6503         uint8_t secret_arr[32];
6504         CHECK((*env)->GetArrayLength(env, secret) == 32);
6505         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
6506         uint8_t (*secret_ref)[32] = &secret_arr;
6507         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
6508         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
6509         return tag_ptr(ret_conv, true);
6510 }
6511
6512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
6513         void* this_arg_ptr = untag_ptr(this_arg);
6514         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6515         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6516         LDKHolderCommitmentTransaction commitment_tx_conv;
6517         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6518         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6519         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6520         commitment_tx_conv.is_owned = false;
6521         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6522         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
6523         return tag_ptr(ret_conv, true);
6524 }
6525
6526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_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) {
6527         void* this_arg_ptr = untag_ptr(this_arg);
6528         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6529         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6530         LDKTransaction justice_tx_ref;
6531         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6532         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6533         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6534         justice_tx_ref.data_is_owned = true;
6535         uint8_t per_commitment_key_arr[32];
6536         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6537         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6538         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6539         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6540         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
6541         return tag_ptr(ret_conv, true);
6542 }
6543
6544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_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) {
6545         void* this_arg_ptr = untag_ptr(this_arg);
6546         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6547         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6548         LDKTransaction justice_tx_ref;
6549         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6550         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6551         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6552         justice_tx_ref.data_is_owned = true;
6553         uint8_t per_commitment_key_arr[32];
6554         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6555         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6556         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6557         LDKHTLCOutputInCommitment htlc_conv;
6558         htlc_conv.inner = untag_ptr(htlc);
6559         htlc_conv.is_owned = ptr_is_owned(htlc);
6560         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6561         htlc_conv.is_owned = false;
6562         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6563         *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);
6564         return tag_ptr(ret_conv, true);
6565 }
6566
6567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_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) {
6568         void* this_arg_ptr = untag_ptr(this_arg);
6569         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6570         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6571         LDKTransaction htlc_tx_ref;
6572         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
6573         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
6574         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
6575         htlc_tx_ref.data_is_owned = true;
6576         LDKPublicKey per_commitment_point_ref;
6577         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
6578         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
6579         LDKHTLCOutputInCommitment htlc_conv;
6580         htlc_conv.inner = untag_ptr(htlc);
6581         htlc_conv.is_owned = ptr_is_owned(htlc);
6582         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6583         htlc_conv.is_owned = false;
6584         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6585         *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);
6586         return tag_ptr(ret_conv, true);
6587 }
6588
6589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
6590         void* this_arg_ptr = untag_ptr(this_arg);
6591         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6592         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6593         LDKClosingTransaction closing_tx_conv;
6594         closing_tx_conv.inner = untag_ptr(closing_tx);
6595         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
6596         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
6597         closing_tx_conv.is_owned = false;
6598         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6599         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
6600         return tag_ptr(ret_conv, true);
6601 }
6602
6603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1sign_1holder_1anchor_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray anchor_tx, int64_t input) {
6604         void* this_arg_ptr = untag_ptr(this_arg);
6605         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6606         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6607         LDKTransaction anchor_tx_ref;
6608         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
6609         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
6610         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
6611         anchor_tx_ref.data_is_owned = true;
6612         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6613         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
6614         return tag_ptr(ret_conv, true);
6615 }
6616
6617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1sign_1channel_1announcement_1with_1funding_1key(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6618         void* this_arg_ptr = untag_ptr(this_arg);
6619         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6620         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6621         LDKUnsignedChannelAnnouncement msg_conv;
6622         msg_conv.inner = untag_ptr(msg);
6623         msg_conv.is_owned = ptr_is_owned(msg);
6624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6625         msg_conv.is_owned = false;
6626         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6627         *ret_conv = (this_arg_conv->sign_channel_announcement_with_funding_key)(this_arg_conv->this_arg, &msg_conv);
6628         return tag_ptr(ret_conv, true);
6629 }
6630
6631 typedef struct LDKWriteableEcdsaChannelSigner_JCalls {
6632         atomic_size_t refcnt;
6633         JavaVM *vm;
6634         jweak o;
6635         LDKEcdsaChannelSigner_JCalls* EcdsaChannelSigner;
6636         LDKChannelSigner_JCalls* ChannelSigner;
6637         jmethodID write_meth;
6638 } LDKWriteableEcdsaChannelSigner_JCalls;
6639 static void LDKWriteableEcdsaChannelSigner_JCalls_free(void* this_arg) {
6640         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6641         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6642                 JNIEnv *env;
6643                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6644                 if (get_jenv_res == JNI_EDETACHED) {
6645                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6646                 } else {
6647                         DO_ASSERT(get_jenv_res == JNI_OK);
6648                 }
6649                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6650                 if (get_jenv_res == JNI_EDETACHED) {
6651                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6652                 }
6653                 FREE(j_calls);
6654         }
6655 }
6656 LDKCVec_u8Z write_LDKWriteableEcdsaChannelSigner_jcall(const void* this_arg) {
6657         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6658         JNIEnv *env;
6659         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6660         if (get_jenv_res == JNI_EDETACHED) {
6661                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6662         } else {
6663                 DO_ASSERT(get_jenv_res == JNI_OK);
6664         }
6665         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6666         CHECK(obj != NULL);
6667         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6668         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6669                 (*env)->ExceptionDescribe(env);
6670                 (*env)->FatalError(env, "A call to write in LDKWriteableEcdsaChannelSigner from rust threw an exception.");
6671         }
6672         LDKCVec_u8Z ret_ref;
6673         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6674         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6675         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6676         if (get_jenv_res == JNI_EDETACHED) {
6677                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6678         }
6679         return ret_ref;
6680 }
6681 static void LDKWriteableEcdsaChannelSigner_JCalls_cloned(LDKWriteableEcdsaChannelSigner* new_obj) {
6682         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6683         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6684         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->refcnt, 1, memory_order_release);
6685         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->ChannelSigner->refcnt, 1, memory_order_release);
6686 }
6687 static inline LDKWriteableEcdsaChannelSigner LDKWriteableEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6688         jclass c = (*env)->GetObjectClass(env, o);
6689         CHECK(c != NULL);
6690         LDKWriteableEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner_JCalls), "LDKWriteableEcdsaChannelSigner_JCalls");
6691         atomic_init(&calls->refcnt, 1);
6692         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6693         calls->o = (*env)->NewWeakGlobalRef(env, o);
6694         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6695         CHECK(calls->write_meth != NULL);
6696
6697         LDKChannelPublicKeys pubkeys_conv;
6698         pubkeys_conv.inner = untag_ptr(pubkeys);
6699         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6700         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6701
6702         LDKWriteableEcdsaChannelSigner ret = {
6703                 .this_arg = (void*) calls,
6704                 .write = write_LDKWriteableEcdsaChannelSigner_jcall,
6705                 .cloned = LDKWriteableEcdsaChannelSigner_JCalls_cloned,
6706                 .free = LDKWriteableEcdsaChannelSigner_JCalls_free,
6707                 .EcdsaChannelSigner = LDKEcdsaChannelSigner_init(env, clz, EcdsaChannelSigner, ChannelSigner, pubkeys),
6708         };
6709         calls->EcdsaChannelSigner = ret.EcdsaChannelSigner.this_arg;
6710         calls->ChannelSigner = ret.EcdsaChannelSigner.ChannelSigner.this_arg;
6711         return ret;
6712 }
6713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6714         LDKWriteableEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6715         *res_ptr = LDKWriteableEcdsaChannelSigner_init(env, clz, o, EcdsaChannelSigner, ChannelSigner, pubkeys);
6716         return tag_ptr(res_ptr, true);
6717 }
6718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6719         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6720         return tag_ptr(&inp->EcdsaChannelSigner, false);
6721 }
6722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6723         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6724         return tag_ptr(&inp->EcdsaChannelSigner.ChannelSigner, false);
6725 }
6726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6727         void* this_arg_ptr = untag_ptr(this_arg);
6728         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6729         LDKWriteableEcdsaChannelSigner* this_arg_conv = (LDKWriteableEcdsaChannelSigner*)this_arg_ptr;
6730         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6733         CVec_u8Z_free(ret_var);
6734         return ret_arr;
6735 }
6736
6737 static inline struct LDKWriteableEcdsaChannelSigner CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6738 CHECK(owner->result_ok);
6739         return WriteableEcdsaChannelSigner_clone(&*owner->contents.result);
6740 }
6741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6742         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6743         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6744         *ret_ret = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(owner_conv);
6745         return tag_ptr(ret_ret, true);
6746 }
6747
6748 static inline struct LDKDecodeError CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6749 CHECK(!owner->result_ok);
6750         return DecodeError_clone(&*owner->contents.err);
6751 }
6752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6753         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6754         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6755         *ret_copy = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(owner_conv);
6756         int64_t ret_ref = tag_ptr(ret_copy, true);
6757         return ret_ref;
6758 }
6759
6760 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6761         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6762         for (size_t i = 0; i < ret.datalen; i++) {
6763                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6764         }
6765         return ret;
6766 }
6767 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6768 CHECK(owner->result_ok);
6769         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6770 }
6771 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6772         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6773         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6774         jobjectArray ret_arr = NULL;
6775         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6776         ;
6777         for (size_t i = 0; i < ret_var.datalen; i++) {
6778                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6779                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6780                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6781                 CVec_u8Z_free(ret_conv_8_var);
6782                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6783         }
6784         
6785         FREE(ret_var.data);
6786         return ret_arr;
6787 }
6788
6789 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6790 CHECK(!owner->result_ok);
6791         return *owner->contents.err;
6792 }
6793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6794         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6795         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6796 }
6797
6798 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6799         LDKInMemorySigner ret = *owner->contents.result;
6800         ret.is_owned = false;
6801         return ret;
6802 }
6803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6804         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6805         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6806         int64_t ret_ref = 0;
6807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6809         return ret_ref;
6810 }
6811
6812 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6813 CHECK(!owner->result_ok);
6814         return DecodeError_clone(&*owner->contents.err);
6815 }
6816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6817         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6818         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6819         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6820         int64_t ret_ref = tag_ptr(ret_copy, true);
6821         return ret_ref;
6822 }
6823
6824 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6825         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6826         for (size_t i = 0; i < ret.datalen; i++) {
6827                 ret.data[i] = TxOut_clone(&orig->data[i]);
6828         }
6829         return ret;
6830 }
6831 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6832 CHECK(owner->result_ok);
6833         return *owner->contents.result;
6834 }
6835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6836         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6837         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6838         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6839         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6840         return ret_arr;
6841 }
6842
6843 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6844 CHECK(!owner->result_ok);
6845         return *owner->contents.err;
6846 }
6847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6848         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6849         CResult_TransactionNoneZ_get_err(owner_conv);
6850 }
6851
6852 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6853         return ThirtyTwoBytes_clone(&owner->a);
6854 }
6855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6856         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6857         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6859         return ret_arr;
6860 }
6861
6862 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6863         LDKChannelMonitor ret = owner->b;
6864         ret.is_owned = false;
6865         return ret;
6866 }
6867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6868         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6869         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6870         int64_t ret_ref = 0;
6871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6873         return ret_ref;
6874 }
6875
6876 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6877         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6878         for (size_t i = 0; i < ret.datalen; i++) {
6879                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6880         }
6881         return ret;
6882 }
6883 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6884 CHECK(owner->result_ok);
6885         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6886 }
6887 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6888         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6889         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6890         int64_tArray ret_arr = NULL;
6891         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6892         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6893         for (size_t j = 0; j < ret_var.datalen; j++) {
6894                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6895                 *ret_conv_35_conv = ret_var.data[j];
6896                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6897         }
6898         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6899         FREE(ret_var.data);
6900         return ret_arr;
6901 }
6902
6903 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6904 CHECK(!owner->result_ok);
6905         return *owner->contents.err;
6906 }
6907 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6908         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6909         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6910         return ret_conv;
6911 }
6912
6913 static jclass LDKCOption_u16Z_Some_class = NULL;
6914 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6915 static jclass LDKCOption_u16Z_None_class = NULL;
6916 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6918         LDKCOption_u16Z_Some_class =
6919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6920         CHECK(LDKCOption_u16Z_Some_class != NULL);
6921         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6922         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6923         LDKCOption_u16Z_None_class =
6924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6925         CHECK(LDKCOption_u16Z_None_class != NULL);
6926         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6927         CHECK(LDKCOption_u16Z_None_meth != NULL);
6928 }
6929 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6930         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6931         switch(obj->tag) {
6932                 case LDKCOption_u16Z_Some: {
6933                         int16_t some_conv = obj->some;
6934                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6935                 }
6936                 case LDKCOption_u16Z_None: {
6937                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6938                 }
6939                 default: abort();
6940         }
6941 }
6942 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6943 CHECK(owner->result_ok);
6944         return ThirtyTwoBytes_clone(&*owner->contents.result);
6945 }
6946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6947         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6948         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6950         return ret_arr;
6951 }
6952
6953 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6954 CHECK(!owner->result_ok);
6955         return APIError_clone(&*owner->contents.err);
6956 }
6957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6958         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6959         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6960         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6961         int64_t ret_ref = tag_ptr(ret_copy, true);
6962         return ret_ref;
6963 }
6964
6965 static jclass LDKRecentPaymentDetails_Pending_class = NULL;
6966 static jmethodID LDKRecentPaymentDetails_Pending_meth = NULL;
6967 static jclass LDKRecentPaymentDetails_Fulfilled_class = NULL;
6968 static jmethodID LDKRecentPaymentDetails_Fulfilled_meth = NULL;
6969 static jclass LDKRecentPaymentDetails_Abandoned_class = NULL;
6970 static jmethodID LDKRecentPaymentDetails_Abandoned_meth = NULL;
6971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRecentPaymentDetails_init (JNIEnv *env, jclass clz) {
6972         LDKRecentPaymentDetails_Pending_class =
6973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Pending"));
6974         CHECK(LDKRecentPaymentDetails_Pending_class != NULL);
6975         LDKRecentPaymentDetails_Pending_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Pending_class, "<init>", "([BJ)V");
6976         CHECK(LDKRecentPaymentDetails_Pending_meth != NULL);
6977         LDKRecentPaymentDetails_Fulfilled_class =
6978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Fulfilled"));
6979         CHECK(LDKRecentPaymentDetails_Fulfilled_class != NULL);
6980         LDKRecentPaymentDetails_Fulfilled_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Fulfilled_class, "<init>", "([B)V");
6981         CHECK(LDKRecentPaymentDetails_Fulfilled_meth != NULL);
6982         LDKRecentPaymentDetails_Abandoned_class =
6983                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Abandoned"));
6984         CHECK(LDKRecentPaymentDetails_Abandoned_class != NULL);
6985         LDKRecentPaymentDetails_Abandoned_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Abandoned_class, "<init>", "([B)V");
6986         CHECK(LDKRecentPaymentDetails_Abandoned_meth != NULL);
6987 }
6988 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRecentPaymentDetails_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6989         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
6990         switch(obj->tag) {
6991                 case LDKRecentPaymentDetails_Pending: {
6992                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6993                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->pending.payment_hash.data);
6994                         int64_t total_msat_conv = obj->pending.total_msat;
6995                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Pending_class, LDKRecentPaymentDetails_Pending_meth, payment_hash_arr, total_msat_conv);
6996                 }
6997                 case LDKRecentPaymentDetails_Fulfilled: {
6998                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6999                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->fulfilled.payment_hash.data);
7000                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Fulfilled_class, LDKRecentPaymentDetails_Fulfilled_meth, payment_hash_arr);
7001                 }
7002                 case LDKRecentPaymentDetails_Abandoned: {
7003                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
7004                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->abandoned.payment_hash.data);
7005                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Abandoned_class, LDKRecentPaymentDetails_Abandoned_meth, payment_hash_arr);
7006                 }
7007                 default: abort();
7008         }
7009 }
7010 static inline LDKCVec_RecentPaymentDetailsZ CVec_RecentPaymentDetailsZ_clone(const LDKCVec_RecentPaymentDetailsZ *orig) {
7011         LDKCVec_RecentPaymentDetailsZ ret = { .data = MALLOC(sizeof(LDKRecentPaymentDetails) * orig->datalen, "LDKCVec_RecentPaymentDetailsZ clone bytes"), .datalen = orig->datalen };
7012         for (size_t i = 0; i < ret.datalen; i++) {
7013                 ret.data[i] = RecentPaymentDetails_clone(&orig->data[i]);
7014         }
7015         return ret;
7016 }
7017 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
7018 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
7019 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
7020 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
7021 static jclass LDKPaymentSendFailure_AllFailedResendSafe_class = NULL;
7022 static jmethodID LDKPaymentSendFailure_AllFailedResendSafe_meth = NULL;
7023 static jclass LDKPaymentSendFailure_DuplicatePayment_class = NULL;
7024 static jmethodID LDKPaymentSendFailure_DuplicatePayment_meth = NULL;
7025 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
7026 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
7027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
7028         LDKPaymentSendFailure_ParameterError_class =
7029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
7030         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
7031         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
7032         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
7033         LDKPaymentSendFailure_PathParameterError_class =
7034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
7035         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
7036         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
7037         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
7038         LDKPaymentSendFailure_AllFailedResendSafe_class =
7039                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedResendSafe"));
7040         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_class != NULL);
7041         LDKPaymentSendFailure_AllFailedResendSafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedResendSafe_class, "<init>", "([J)V");
7042         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_meth != NULL);
7043         LDKPaymentSendFailure_DuplicatePayment_class =
7044                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$DuplicatePayment"));
7045         CHECK(LDKPaymentSendFailure_DuplicatePayment_class != NULL);
7046         LDKPaymentSendFailure_DuplicatePayment_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_DuplicatePayment_class, "<init>", "()V");
7047         CHECK(LDKPaymentSendFailure_DuplicatePayment_meth != NULL);
7048         LDKPaymentSendFailure_PartialFailure_class =
7049                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
7050         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
7051         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
7052         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
7053 }
7054 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7055         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
7056         switch(obj->tag) {
7057                 case LDKPaymentSendFailure_ParameterError: {
7058                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
7059                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
7060                 }
7061                 case LDKPaymentSendFailure_PathParameterError: {
7062                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
7063                         int64_tArray path_parameter_error_arr = NULL;
7064                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
7065                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
7066                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
7067                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7068                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
7069                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
7070                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
7071                         }
7072                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
7073                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
7074                 }
7075                 case LDKPaymentSendFailure_AllFailedResendSafe: {
7076                         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
7077                         int64_tArray all_failed_resend_safe_arr = NULL;
7078                         all_failed_resend_safe_arr = (*env)->NewLongArray(env, all_failed_resend_safe_var.datalen);
7079                         int64_t *all_failed_resend_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_resend_safe_arr, NULL);
7080                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
7081                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
7082                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
7083                         }
7084                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_resend_safe_arr, all_failed_resend_safe_arr_ptr, 0);
7085                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedResendSafe_class, LDKPaymentSendFailure_AllFailedResendSafe_meth, all_failed_resend_safe_arr);
7086                 }
7087                 case LDKPaymentSendFailure_DuplicatePayment: {
7088                         return (*env)->NewObject(env, LDKPaymentSendFailure_DuplicatePayment_class, LDKPaymentSendFailure_DuplicatePayment_meth);
7089                 }
7090                 case LDKPaymentSendFailure_PartialFailure: {
7091                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
7092                         int64_tArray results_arr = NULL;
7093                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
7094                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
7095                         for (size_t w = 0; w < results_var.datalen; w++) {
7096                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7097                                 *results_conv_22_conv = results_var.data[w];
7098                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
7099                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
7100                         }
7101                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
7102                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
7103                         int64_t failed_paths_retry_ref = 0;
7104                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
7105                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
7106                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
7107                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
7108                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
7109                 }
7110                 default: abort();
7111         }
7112 }
7113 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
7114 CHECK(owner->result_ok);
7115         return *owner->contents.result;
7116 }
7117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7118         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
7119         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
7120 }
7121
7122 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
7123 CHECK(!owner->result_ok);
7124         return PaymentSendFailure_clone(&*owner->contents.err);
7125 }
7126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7127         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
7128         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7129         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
7130         int64_t ret_ref = tag_ptr(ret_copy, true);
7131         return ret_ref;
7132 }
7133
7134 static inline void CResult_NoneRetryableSendFailureZ_get_ok(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
7135 CHECK(owner->result_ok);
7136         return *owner->contents.result;
7137 }
7138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7139         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
7140         CResult_NoneRetryableSendFailureZ_get_ok(owner_conv);
7141 }
7142
7143 static inline enum LDKRetryableSendFailure CResult_NoneRetryableSendFailureZ_get_err(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
7144 CHECK(!owner->result_ok);
7145         return RetryableSendFailure_clone(&*owner->contents.err);
7146 }
7147 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7148         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
7149         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_NoneRetryableSendFailureZ_get_err(owner_conv));
7150         return ret_conv;
7151 }
7152
7153 static inline struct LDKThirtyTwoBytes CResult_PaymentHashPaymentSendFailureZ_get_ok(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
7154 CHECK(owner->result_ok);
7155         return ThirtyTwoBytes_clone(&*owner->contents.result);
7156 }
7157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7158         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
7159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashPaymentSendFailureZ_get_ok(owner_conv).data);
7161         return ret_arr;
7162 }
7163
7164 static inline struct LDKPaymentSendFailure CResult_PaymentHashPaymentSendFailureZ_get_err(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
7165 CHECK(!owner->result_ok);
7166         return PaymentSendFailure_clone(&*owner->contents.err);
7167 }
7168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7169         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
7170         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7171         *ret_copy = CResult_PaymentHashPaymentSendFailureZ_get_err(owner_conv);
7172         int64_t ret_ref = tag_ptr(ret_copy, true);
7173         return ret_ref;
7174 }
7175
7176 static inline struct LDKThirtyTwoBytes CResult_PaymentHashRetryableSendFailureZ_get_ok(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7177 CHECK(owner->result_ok);
7178         return ThirtyTwoBytes_clone(&*owner->contents.result);
7179 }
7180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7181         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7182         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7183         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashRetryableSendFailureZ_get_ok(owner_conv).data);
7184         return ret_arr;
7185 }
7186
7187 static inline enum LDKRetryableSendFailure CResult_PaymentHashRetryableSendFailureZ_get_err(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7188 CHECK(!owner->result_ok);
7189         return RetryableSendFailure_clone(&*owner->contents.err);
7190 }
7191 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7192         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7193         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_PaymentHashRetryableSendFailureZ_get_err(owner_conv));
7194         return ret_conv;
7195 }
7196
7197 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7198         return ThirtyTwoBytes_clone(&owner->a);
7199 }
7200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7201         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
7204         return ret_arr;
7205 }
7206
7207 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7208         return ThirtyTwoBytes_clone(&owner->b);
7209 }
7210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7211         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7212         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7213         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
7214         return ret_arr;
7215 }
7216
7217 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7218 CHECK(owner->result_ok);
7219         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
7220 }
7221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7222         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7223         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
7224         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
7225         return tag_ptr(ret_conv, true);
7226 }
7227
7228 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7229 CHECK(!owner->result_ok);
7230         return PaymentSendFailure_clone(&*owner->contents.err);
7231 }
7232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7233         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7234         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7235         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
7236         int64_t ret_ref = tag_ptr(ret_copy, true);
7237         return ret_ref;
7238 }
7239
7240 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
7241         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
7242         for (size_t i = 0; i < ret.datalen; i++) {
7243                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
7244         }
7245         return ret;
7246 }
7247 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7248         return ThirtyTwoBytes_clone(&owner->a);
7249 }
7250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7251         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7252         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
7254         return ret_arr;
7255 }
7256
7257 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7258         return ThirtyTwoBytes_clone(&owner->b);
7259 }
7260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7261         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7262         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
7264         return ret_arr;
7265 }
7266
7267 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7268 CHECK(owner->result_ok);
7269         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7270 }
7271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7272         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7273         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7274         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
7275         return tag_ptr(ret_conv, true);
7276 }
7277
7278 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7279 CHECK(!owner->result_ok);
7280         return *owner->contents.err;
7281 }
7282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7283         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7284         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
7285 }
7286
7287 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7288 CHECK(owner->result_ok);
7289         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7290 }
7291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7292         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7293         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7294         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
7295         return tag_ptr(ret_conv, true);
7296 }
7297
7298 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7299 CHECK(!owner->result_ok);
7300         return APIError_clone(&*owner->contents.err);
7301 }
7302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7303         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7304         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7305         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
7306         int64_t ret_ref = tag_ptr(ret_copy, true);
7307         return ret_ref;
7308 }
7309
7310 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7311 CHECK(owner->result_ok);
7312         return ThirtyTwoBytes_clone(&*owner->contents.result);
7313 }
7314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7315         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7316         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7317         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
7318         return ret_arr;
7319 }
7320
7321 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7322 CHECK(!owner->result_ok);
7323         return *owner->contents.err;
7324 }
7325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7326         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7327         CResult_PaymentSecretNoneZ_get_err(owner_conv);
7328 }
7329
7330 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7331 CHECK(owner->result_ok);
7332         return ThirtyTwoBytes_clone(&*owner->contents.result);
7333 }
7334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7335         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7336         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7337         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
7338         return ret_arr;
7339 }
7340
7341 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7342 CHECK(!owner->result_ok);
7343         return APIError_clone(&*owner->contents.err);
7344 }
7345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7346         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7347         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7348         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
7349         int64_t ret_ref = tag_ptr(ret_copy, true);
7350         return ret_ref;
7351 }
7352
7353 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7354 CHECK(owner->result_ok);
7355         return ThirtyTwoBytes_clone(&*owner->contents.result);
7356 }
7357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7358         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7359         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7360         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
7361         return ret_arr;
7362 }
7363
7364 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7365 CHECK(!owner->result_ok);
7366         return APIError_clone(&*owner->contents.err);
7367 }
7368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7369         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7370         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7371         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
7372         int64_t ret_ref = tag_ptr(ret_copy, true);
7373         return ret_ref;
7374 }
7375
7376 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7377         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
7378         ret.is_owned = false;
7379         return ret;
7380 }
7381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7382         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7383         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
7384         int64_t ret_ref = 0;
7385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7387         return ret_ref;
7388 }
7389
7390 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7391 CHECK(!owner->result_ok);
7392         return DecodeError_clone(&*owner->contents.err);
7393 }
7394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7395         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7396         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7397         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
7398         int64_t ret_ref = tag_ptr(ret_copy, true);
7399         return ret_ref;
7400 }
7401
7402 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7403         LDKChannelCounterparty ret = *owner->contents.result;
7404         ret.is_owned = false;
7405         return ret;
7406 }
7407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7408         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7409         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
7410         int64_t ret_ref = 0;
7411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7412         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7413         return ret_ref;
7414 }
7415
7416 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7417 CHECK(!owner->result_ok);
7418         return DecodeError_clone(&*owner->contents.err);
7419 }
7420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7421         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7422         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7423         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
7424         int64_t ret_ref = tag_ptr(ret_copy, true);
7425         return ret_ref;
7426 }
7427
7428 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7429         LDKChannelDetails ret = *owner->contents.result;
7430         ret.is_owned = false;
7431         return ret;
7432 }
7433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7434         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7435         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
7436         int64_t ret_ref = 0;
7437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7439         return ret_ref;
7440 }
7441
7442 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7443 CHECK(!owner->result_ok);
7444         return DecodeError_clone(&*owner->contents.err);
7445 }
7446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7447         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7448         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7449         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
7450         int64_t ret_ref = tag_ptr(ret_copy, true);
7451         return ret_ref;
7452 }
7453
7454 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7455         LDKPhantomRouteHints ret = *owner->contents.result;
7456         ret.is_owned = false;
7457         return ret;
7458 }
7459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7460         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7461         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
7462         int64_t ret_ref = 0;
7463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7465         return ret_ref;
7466 }
7467
7468 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7469 CHECK(!owner->result_ok);
7470         return DecodeError_clone(&*owner->contents.err);
7471 }
7472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7473         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7474         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7475         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
7476         int64_t ret_ref = tag_ptr(ret_copy, true);
7477         return ret_ref;
7478 }
7479
7480 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
7481         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
7482         for (size_t i = 0; i < ret.datalen; i++) {
7483                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
7484         }
7485         return ret;
7486 }
7487 typedef struct LDKWatch_JCalls {
7488         atomic_size_t refcnt;
7489         JavaVM *vm;
7490         jweak o;
7491         jmethodID watch_channel_meth;
7492         jmethodID update_channel_meth;
7493         jmethodID release_pending_monitor_events_meth;
7494 } LDKWatch_JCalls;
7495 static void LDKWatch_JCalls_free(void* this_arg) {
7496         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7497         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7498                 JNIEnv *env;
7499                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7500                 if (get_jenv_res == JNI_EDETACHED) {
7501                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7502                 } else {
7503                         DO_ASSERT(get_jenv_res == JNI_OK);
7504                 }
7505                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7506                 if (get_jenv_res == JNI_EDETACHED) {
7507                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7508                 }
7509                 FREE(j_calls);
7510         }
7511 }
7512 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
7513         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7514         JNIEnv *env;
7515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7516         if (get_jenv_res == JNI_EDETACHED) {
7517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7518         } else {
7519                 DO_ASSERT(get_jenv_res == JNI_OK);
7520         }
7521         LDKOutPoint funding_txo_var = funding_txo;
7522         int64_t funding_txo_ref = 0;
7523         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7524         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7525         LDKChannelMonitor monitor_var = monitor;
7526         int64_t monitor_ref = 0;
7527         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
7528         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
7529         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7530         CHECK(obj != NULL);
7531         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
7532         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7533                 (*env)->ExceptionDescribe(env);
7534                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
7535         }
7536         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7537         if (get_jenv_res == JNI_EDETACHED) {
7538                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7539         }
7540         return ret_conv;
7541 }
7542 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate * update) {
7543         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7544         JNIEnv *env;
7545         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7546         if (get_jenv_res == JNI_EDETACHED) {
7547                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7548         } else {
7549                 DO_ASSERT(get_jenv_res == JNI_OK);
7550         }
7551         LDKOutPoint funding_txo_var = funding_txo;
7552         int64_t funding_txo_ref = 0;
7553         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7554         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7555         LDKChannelMonitorUpdate update_var = *update;
7556         int64_t update_ref = 0;
7557         update_var = ChannelMonitorUpdate_clone(&update_var);
7558         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7559         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
7560         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7561         CHECK(obj != NULL);
7562         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
7563         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7564                 (*env)->ExceptionDescribe(env);
7565                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
7566         }
7567         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7568         if (get_jenv_res == JNI_EDETACHED) {
7569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7570         }
7571         return ret_conv;
7572 }
7573 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
7574         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7575         JNIEnv *env;
7576         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7577         if (get_jenv_res == JNI_EDETACHED) {
7578                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7579         } else {
7580                 DO_ASSERT(get_jenv_res == JNI_OK);
7581         }
7582         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7583         CHECK(obj != NULL);
7584         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
7585         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7586                 (*env)->ExceptionDescribe(env);
7587                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
7588         }
7589         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
7590         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7591         if (ret_constr.datalen > 0)
7592                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
7593         else
7594                 ret_constr.data = NULL;
7595         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7596         for (size_t x = 0; x < ret_constr.datalen; x++) {
7597                 int64_t ret_conv_49 = ret_vals[x];
7598                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
7599                 CHECK_ACCESS(ret_conv_49_ptr);
7600                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
7601                 FREE(untag_ptr(ret_conv_49));
7602                 ret_constr.data[x] = ret_conv_49_conv;
7603         }
7604         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7605         if (get_jenv_res == JNI_EDETACHED) {
7606                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7607         }
7608         return ret_constr;
7609 }
7610 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
7611         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
7612         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7613 }
7614 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
7615         jclass c = (*env)->GetObjectClass(env, o);
7616         CHECK(c != NULL);
7617         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
7618         atomic_init(&calls->refcnt, 1);
7619         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7620         calls->o = (*env)->NewWeakGlobalRef(env, o);
7621         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7622         CHECK(calls->watch_channel_meth != NULL);
7623         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7624         CHECK(calls->update_channel_meth != NULL);
7625         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
7626         CHECK(calls->release_pending_monitor_events_meth != NULL);
7627
7628         LDKWatch ret = {
7629                 .this_arg = (void*) calls,
7630                 .watch_channel = watch_channel_LDKWatch_jcall,
7631                 .update_channel = update_channel_LDKWatch_jcall,
7632                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
7633                 .free = LDKWatch_JCalls_free,
7634         };
7635         return ret;
7636 }
7637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
7638         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
7639         *res_ptr = LDKWatch_init(env, clz, o);
7640         return tag_ptr(res_ptr, true);
7641 }
7642 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) {
7643         void* this_arg_ptr = untag_ptr(this_arg);
7644         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7645         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7646         LDKOutPoint funding_txo_conv;
7647         funding_txo_conv.inner = untag_ptr(funding_txo);
7648         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7649         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7650         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7651         LDKChannelMonitor monitor_conv;
7652         monitor_conv.inner = untag_ptr(monitor);
7653         monitor_conv.is_owned = ptr_is_owned(monitor);
7654         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
7655         monitor_conv = ChannelMonitor_clone(&monitor_conv);
7656         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
7657         return ret_conv;
7658 }
7659
7660 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) {
7661         void* this_arg_ptr = untag_ptr(this_arg);
7662         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7663         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7664         LDKOutPoint funding_txo_conv;
7665         funding_txo_conv.inner = untag_ptr(funding_txo);
7666         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7667         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7668         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7669         LDKChannelMonitorUpdate update_conv;
7670         update_conv.inner = untag_ptr(update);
7671         update_conv.is_owned = ptr_is_owned(update);
7672         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7673         update_conv.is_owned = false;
7674         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, &update_conv));
7675         return ret_conv;
7676 }
7677
7678 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7679         void* this_arg_ptr = untag_ptr(this_arg);
7680         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7681         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7682         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7683         int64_tArray ret_arr = NULL;
7684         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7685         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7686         for (size_t x = 0; x < ret_var.datalen; x++) {
7687                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7688                 *ret_conv_49_conv = ret_var.data[x];
7689                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7690         }
7691         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7692         FREE(ret_var.data);
7693         return ret_arr;
7694 }
7695
7696 typedef struct LDKBroadcasterInterface_JCalls {
7697         atomic_size_t refcnt;
7698         JavaVM *vm;
7699         jweak o;
7700         jmethodID broadcast_transaction_meth;
7701 } LDKBroadcasterInterface_JCalls;
7702 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7703         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7704         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7705                 JNIEnv *env;
7706                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7707                 if (get_jenv_res == JNI_EDETACHED) {
7708                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7709                 } else {
7710                         DO_ASSERT(get_jenv_res == JNI_OK);
7711                 }
7712                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7713                 if (get_jenv_res == JNI_EDETACHED) {
7714                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7715                 }
7716                 FREE(j_calls);
7717         }
7718 }
7719 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7720         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7721         JNIEnv *env;
7722         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7723         if (get_jenv_res == JNI_EDETACHED) {
7724                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7725         } else {
7726                 DO_ASSERT(get_jenv_res == JNI_OK);
7727         }
7728         LDKTransaction tx_var = tx;
7729         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7730         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7731         Transaction_free(tx_var);
7732         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7733         CHECK(obj != NULL);
7734         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7735         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7736                 (*env)->ExceptionDescribe(env);
7737                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7738         }
7739         if (get_jenv_res == JNI_EDETACHED) {
7740                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7741         }
7742 }
7743 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7744         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7745         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7746 }
7747 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7748         jclass c = (*env)->GetObjectClass(env, o);
7749         CHECK(c != NULL);
7750         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7751         atomic_init(&calls->refcnt, 1);
7752         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7753         calls->o = (*env)->NewWeakGlobalRef(env, o);
7754         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7755         CHECK(calls->broadcast_transaction_meth != NULL);
7756
7757         LDKBroadcasterInterface ret = {
7758                 .this_arg = (void*) calls,
7759                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7760                 .free = LDKBroadcasterInterface_JCalls_free,
7761         };
7762         return ret;
7763 }
7764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7765         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7766         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7767         return tag_ptr(res_ptr, true);
7768 }
7769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7770         void* this_arg_ptr = untag_ptr(this_arg);
7771         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7772         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7773         LDKTransaction tx_ref;
7774         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7775         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7776         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7777         tx_ref.data_is_owned = true;
7778         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7779 }
7780
7781 typedef struct LDKEntropySource_JCalls {
7782         atomic_size_t refcnt;
7783         JavaVM *vm;
7784         jweak o;
7785         jmethodID get_secure_random_bytes_meth;
7786 } LDKEntropySource_JCalls;
7787 static void LDKEntropySource_JCalls_free(void* this_arg) {
7788         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7789         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7790                 JNIEnv *env;
7791                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7792                 if (get_jenv_res == JNI_EDETACHED) {
7793                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7794                 } else {
7795                         DO_ASSERT(get_jenv_res == JNI_OK);
7796                 }
7797                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7798                 if (get_jenv_res == JNI_EDETACHED) {
7799                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7800                 }
7801                 FREE(j_calls);
7802         }
7803 }
7804 LDKThirtyTwoBytes get_secure_random_bytes_LDKEntropySource_jcall(const void* this_arg) {
7805         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7806         JNIEnv *env;
7807         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7808         if (get_jenv_res == JNI_EDETACHED) {
7809                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7810         } else {
7811                 DO_ASSERT(get_jenv_res == JNI_OK);
7812         }
7813         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7814         CHECK(obj != NULL);
7815         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7816         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7817                 (*env)->ExceptionDescribe(env);
7818                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKEntropySource from rust threw an exception.");
7819         }
7820         LDKThirtyTwoBytes ret_ref;
7821         CHECK((*env)->GetArrayLength(env, ret) == 32);
7822         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7823         if (get_jenv_res == JNI_EDETACHED) {
7824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7825         }
7826         return ret_ref;
7827 }
7828 static void LDKEntropySource_JCalls_cloned(LDKEntropySource* new_obj) {
7829         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) new_obj->this_arg;
7830         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7831 }
7832 static inline LDKEntropySource LDKEntropySource_init (JNIEnv *env, jclass clz, jobject o) {
7833         jclass c = (*env)->GetObjectClass(env, o);
7834         CHECK(c != NULL);
7835         LDKEntropySource_JCalls *calls = MALLOC(sizeof(LDKEntropySource_JCalls), "LDKEntropySource_JCalls");
7836         atomic_init(&calls->refcnt, 1);
7837         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7838         calls->o = (*env)->NewWeakGlobalRef(env, o);
7839         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7840         CHECK(calls->get_secure_random_bytes_meth != NULL);
7841
7842         LDKEntropySource ret = {
7843                 .this_arg = (void*) calls,
7844                 .get_secure_random_bytes = get_secure_random_bytes_LDKEntropySource_jcall,
7845                 .free = LDKEntropySource_JCalls_free,
7846         };
7847         return ret;
7848 }
7849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEntropySource_1new(JNIEnv *env, jclass clz, jobject o) {
7850         LDKEntropySource *res_ptr = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
7851         *res_ptr = LDKEntropySource_init(env, clz, o);
7852         return tag_ptr(res_ptr, true);
7853 }
7854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_EntropySource_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7855         void* this_arg_ptr = untag_ptr(this_arg);
7856         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7857         LDKEntropySource* this_arg_conv = (LDKEntropySource*)this_arg_ptr;
7858         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7859         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7860         return ret_arr;
7861 }
7862
7863 static jclass LDKUnsignedGossipMessage_ChannelAnnouncement_class = NULL;
7864 static jmethodID LDKUnsignedGossipMessage_ChannelAnnouncement_meth = NULL;
7865 static jclass LDKUnsignedGossipMessage_ChannelUpdate_class = NULL;
7866 static jmethodID LDKUnsignedGossipMessage_ChannelUpdate_meth = NULL;
7867 static jclass LDKUnsignedGossipMessage_NodeAnnouncement_class = NULL;
7868 static jmethodID LDKUnsignedGossipMessage_NodeAnnouncement_meth = NULL;
7869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUnsignedGossipMessage_init (JNIEnv *env, jclass clz) {
7870         LDKUnsignedGossipMessage_ChannelAnnouncement_class =
7871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelAnnouncement"));
7872         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_class != NULL);
7873         LDKUnsignedGossipMessage_ChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, "<init>", "(J)V");
7874         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_meth != NULL);
7875         LDKUnsignedGossipMessage_ChannelUpdate_class =
7876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelUpdate"));
7877         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_class != NULL);
7878         LDKUnsignedGossipMessage_ChannelUpdate_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelUpdate_class, "<init>", "(J)V");
7879         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_meth != NULL);
7880         LDKUnsignedGossipMessage_NodeAnnouncement_class =
7881                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$NodeAnnouncement"));
7882         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_class != NULL);
7883         LDKUnsignedGossipMessage_NodeAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, "<init>", "(J)V");
7884         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_meth != NULL);
7885 }
7886 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUnsignedGossipMessage_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7887         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
7888         switch(obj->tag) {
7889                 case LDKUnsignedGossipMessage_ChannelAnnouncement: {
7890                         LDKUnsignedChannelAnnouncement channel_announcement_var = obj->channel_announcement;
7891                         int64_t channel_announcement_ref = 0;
7892                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_announcement_var);
7893                         channel_announcement_ref = tag_ptr(channel_announcement_var.inner, false);
7894                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, LDKUnsignedGossipMessage_ChannelAnnouncement_meth, channel_announcement_ref);
7895                 }
7896                 case LDKUnsignedGossipMessage_ChannelUpdate: {
7897                         LDKUnsignedChannelUpdate channel_update_var = obj->channel_update;
7898                         int64_t channel_update_ref = 0;
7899                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_update_var);
7900                         channel_update_ref = tag_ptr(channel_update_var.inner, false);
7901                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelUpdate_class, LDKUnsignedGossipMessage_ChannelUpdate_meth, channel_update_ref);
7902                 }
7903                 case LDKUnsignedGossipMessage_NodeAnnouncement: {
7904                         LDKUnsignedNodeAnnouncement node_announcement_var = obj->node_announcement;
7905                         int64_t node_announcement_ref = 0;
7906                         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_announcement_var);
7907                         node_announcement_ref = tag_ptr(node_announcement_var.inner, false);
7908                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, LDKUnsignedGossipMessage_NodeAnnouncement_meth, node_announcement_ref);
7909                 }
7910                 default: abort();
7911         }
7912 }
7913 typedef struct LDKNodeSigner_JCalls {
7914         atomic_size_t refcnt;
7915         JavaVM *vm;
7916         jweak o;
7917         jmethodID get_inbound_payment_key_material_meth;
7918         jmethodID get_node_id_meth;
7919         jmethodID ecdh_meth;
7920         jmethodID sign_invoice_meth;
7921         jmethodID sign_gossip_message_meth;
7922 } LDKNodeSigner_JCalls;
7923 static void LDKNodeSigner_JCalls_free(void* this_arg) {
7924         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7925         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7926                 JNIEnv *env;
7927                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7928                 if (get_jenv_res == JNI_EDETACHED) {
7929                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7930                 } else {
7931                         DO_ASSERT(get_jenv_res == JNI_OK);
7932                 }
7933                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7934                 if (get_jenv_res == JNI_EDETACHED) {
7935                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7936                 }
7937                 FREE(j_calls);
7938         }
7939 }
7940 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKNodeSigner_jcall(const void* this_arg) {
7941         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7942         JNIEnv *env;
7943         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7944         if (get_jenv_res == JNI_EDETACHED) {
7945                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7946         } else {
7947                 DO_ASSERT(get_jenv_res == JNI_OK);
7948         }
7949         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7950         CHECK(obj != NULL);
7951         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7952         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7953                 (*env)->ExceptionDescribe(env);
7954                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKNodeSigner from rust threw an exception.");
7955         }
7956         LDKThirtyTwoBytes ret_ref;
7957         CHECK((*env)->GetArrayLength(env, ret) == 32);
7958         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7959         if (get_jenv_res == JNI_EDETACHED) {
7960                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7961         }
7962         return ret_ref;
7963 }
7964 LDKCResult_PublicKeyNoneZ get_node_id_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient) {
7965         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7966         JNIEnv *env;
7967         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7968         if (get_jenv_res == JNI_EDETACHED) {
7969                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7970         } else {
7971                 DO_ASSERT(get_jenv_res == JNI_OK);
7972         }
7973         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7974         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7975         CHECK(obj != NULL);
7976         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7977         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7978                 (*env)->ExceptionDescribe(env);
7979                 (*env)->FatalError(env, "A call to get_node_id in LDKNodeSigner from rust threw an exception.");
7980         }
7981         void* ret_ptr = untag_ptr(ret);
7982         CHECK_ACCESS(ret_ptr);
7983         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7984         FREE(untag_ptr(ret));
7985         if (get_jenv_res == JNI_EDETACHED) {
7986                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7987         }
7988         return ret_conv;
7989 }
7990 LDKCResult_SharedSecretNoneZ ecdh_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7991         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_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         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
8000         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
8001         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
8002         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
8003         *tweak_copy = tweak;
8004         int64_t tweak_ref = tag_ptr(tweak_copy, true);
8005         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8006         CHECK(obj != NULL);
8007         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
8008         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8009                 (*env)->ExceptionDescribe(env);
8010                 (*env)->FatalError(env, "A call to ecdh in LDKNodeSigner from rust threw an exception.");
8011         }
8012         void* ret_ptr = untag_ptr(ret);
8013         CHECK_ACCESS(ret_ptr);
8014         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
8015         FREE(untag_ptr(ret));
8016         if (get_jenv_res == JNI_EDETACHED) {
8017                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8018         }
8019         return ret_conv;
8020 }
8021 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKNodeSigner_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient recipient) {
8022         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
8023         JNIEnv *env;
8024         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8025         if (get_jenv_res == JNI_EDETACHED) {
8026                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8027         } else {
8028                 DO_ASSERT(get_jenv_res == JNI_OK);
8029         }
8030         LDKu8slice hrp_bytes_var = hrp_bytes;
8031         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
8032         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
8033         LDKCVec_U5Z invoice_data_var = invoice_data;
8034         jobjectArray invoice_data_arr = NULL;
8035         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
8036         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
8037         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
8038                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
8039                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
8040         }
8041         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
8042         FREE(invoice_data_var.data);
8043         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
8044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8045         CHECK(obj != NULL);
8046         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, recipient_conv);
8047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8048                 (*env)->ExceptionDescribe(env);
8049                 (*env)->FatalError(env, "A call to sign_invoice in LDKNodeSigner from rust threw an exception.");
8050         }
8051         void* ret_ptr = untag_ptr(ret);
8052         CHECK_ACCESS(ret_ptr);
8053         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
8054         FREE(untag_ptr(ret));
8055         if (get_jenv_res == JNI_EDETACHED) {
8056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8057         }
8058         return ret_conv;
8059 }
8060 LDKCResult_SignatureNoneZ sign_gossip_message_LDKNodeSigner_jcall(const void* this_arg, LDKUnsignedGossipMessage msg) {
8061         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
8062         JNIEnv *env;
8063         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8064         if (get_jenv_res == JNI_EDETACHED) {
8065                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8066         } else {
8067                 DO_ASSERT(get_jenv_res == JNI_OK);
8068         }
8069         LDKUnsignedGossipMessage *msg_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
8070         *msg_copy = msg;
8071         int64_t msg_ref = tag_ptr(msg_copy, true);
8072         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8073         CHECK(obj != NULL);
8074         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_gossip_message_meth, msg_ref);
8075         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8076                 (*env)->ExceptionDescribe(env);
8077                 (*env)->FatalError(env, "A call to sign_gossip_message in LDKNodeSigner from rust threw an exception.");
8078         }
8079         void* ret_ptr = untag_ptr(ret);
8080         CHECK_ACCESS(ret_ptr);
8081         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
8082         FREE(untag_ptr(ret));
8083         if (get_jenv_res == JNI_EDETACHED) {
8084                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8085         }
8086         return ret_conv;
8087 }
8088 static void LDKNodeSigner_JCalls_cloned(LDKNodeSigner* new_obj) {
8089         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) new_obj->this_arg;
8090         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8091 }
8092 static inline LDKNodeSigner LDKNodeSigner_init (JNIEnv *env, jclass clz, jobject o) {
8093         jclass c = (*env)->GetObjectClass(env, o);
8094         CHECK(c != NULL);
8095         LDKNodeSigner_JCalls *calls = MALLOC(sizeof(LDKNodeSigner_JCalls), "LDKNodeSigner_JCalls");
8096         atomic_init(&calls->refcnt, 1);
8097         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8098         calls->o = (*env)->NewWeakGlobalRef(env, o);
8099         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
8100         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
8101         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
8102         CHECK(calls->get_node_id_meth != NULL);
8103         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
8104         CHECK(calls->ecdh_meth != NULL);
8105         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
8106         CHECK(calls->sign_invoice_meth != NULL);
8107         calls->sign_gossip_message_meth = (*env)->GetMethodID(env, c, "sign_gossip_message", "(J)J");
8108         CHECK(calls->sign_gossip_message_meth != NULL);
8109
8110         LDKNodeSigner ret = {
8111                 .this_arg = (void*) calls,
8112                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKNodeSigner_jcall,
8113                 .get_node_id = get_node_id_LDKNodeSigner_jcall,
8114                 .ecdh = ecdh_LDKNodeSigner_jcall,
8115                 .sign_invoice = sign_invoice_LDKNodeSigner_jcall,
8116                 .sign_gossip_message = sign_gossip_message_LDKNodeSigner_jcall,
8117                 .free = LDKNodeSigner_JCalls_free,
8118         };
8119         return ret;
8120 }
8121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKNodeSigner_1new(JNIEnv *env, jclass clz, jobject o) {
8122         LDKNodeSigner *res_ptr = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
8123         *res_ptr = LDKNodeSigner_init(env, clz, o);
8124         return tag_ptr(res_ptr, true);
8125 }
8126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
8127         void* this_arg_ptr = untag_ptr(this_arg);
8128         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8129         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8130         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8131         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
8132         return ret_arr;
8133 }
8134
8135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
8136         void* this_arg_ptr = untag_ptr(this_arg);
8137         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8138         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8139         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8140         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
8141         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
8142         return tag_ptr(ret_conv, true);
8143 }
8144
8145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1ecdh(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient, int8_tArray other_key, int64_t tweak) {
8146         void* this_arg_ptr = untag_ptr(this_arg);
8147         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8148         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8149         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8150         LDKPublicKey other_key_ref;
8151         CHECK((*env)->GetArrayLength(env, other_key) == 33);
8152         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
8153         void* tweak_ptr = untag_ptr(tweak);
8154         CHECK_ACCESS(tweak_ptr);
8155         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
8156         tweak_conv = COption_ScalarZ_clone((LDKCOption_ScalarZ*)untag_ptr(tweak));
8157         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
8158         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
8159         return tag_ptr(ret_conv, true);
8160 }
8161
8162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray hrp_bytes, jobjectArray invoice_data, jclass recipient) {
8163         void* this_arg_ptr = untag_ptr(this_arg);
8164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8165         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8166         LDKu8slice hrp_bytes_ref;
8167         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
8168         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
8169         LDKCVec_U5Z invoice_data_constr;
8170         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
8171         if (invoice_data_constr.datalen > 0)
8172                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
8173         else
8174                 invoice_data_constr.data = NULL;
8175         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
8176         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
8177                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
8178                 
8179                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
8180         }
8181         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
8182         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8183         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8184         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, recipient_conv);
8185         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
8186         return tag_ptr(ret_conv, true);
8187 }
8188
8189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1sign_1gossip_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8190         void* this_arg_ptr = untag_ptr(this_arg);
8191         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8192         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8193         void* msg_ptr = untag_ptr(msg);
8194         CHECK_ACCESS(msg_ptr);
8195         LDKUnsignedGossipMessage msg_conv = *(LDKUnsignedGossipMessage*)(msg_ptr);
8196         msg_conv = UnsignedGossipMessage_clone((LDKUnsignedGossipMessage*)untag_ptr(msg));
8197         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8198         *ret_conv = (this_arg_conv->sign_gossip_message)(this_arg_conv->this_arg, msg_conv);
8199         return tag_ptr(ret_conv, true);
8200 }
8201
8202 typedef struct LDKSignerProvider_JCalls {
8203         atomic_size_t refcnt;
8204         JavaVM *vm;
8205         jweak o;
8206         jmethodID generate_channel_keys_id_meth;
8207         jmethodID derive_channel_signer_meth;
8208         jmethodID read_chan_signer_meth;
8209         jmethodID get_destination_script_meth;
8210         jmethodID get_shutdown_scriptpubkey_meth;
8211 } LDKSignerProvider_JCalls;
8212 static void LDKSignerProvider_JCalls_free(void* this_arg) {
8213         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8214         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8215                 JNIEnv *env;
8216                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8217                 if (get_jenv_res == JNI_EDETACHED) {
8218                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8219                 } else {
8220                         DO_ASSERT(get_jenv_res == JNI_OK);
8221                 }
8222                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8223                 if (get_jenv_res == JNI_EDETACHED) {
8224                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8225                 }
8226                 FREE(j_calls);
8227         }
8228 }
8229 LDKThirtyTwoBytes generate_channel_keys_id_LDKSignerProvider_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
8230         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8231         JNIEnv *env;
8232         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8233         if (get_jenv_res == JNI_EDETACHED) {
8234                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8235         } else {
8236                 DO_ASSERT(get_jenv_res == JNI_OK);
8237         }
8238         jboolean inbound_conv = inbound;
8239         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8240         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
8241         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, user_channel_id.le_bytes);
8242         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8243         CHECK(obj != NULL);
8244         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->generate_channel_keys_id_meth, inbound_conv, channel_value_satoshis_conv, user_channel_id_arr);
8245         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8246                 (*env)->ExceptionDescribe(env);
8247                 (*env)->FatalError(env, "A call to generate_channel_keys_id in LDKSignerProvider from rust threw an exception.");
8248         }
8249         LDKThirtyTwoBytes ret_ref;
8250         CHECK((*env)->GetArrayLength(env, ret) == 32);
8251         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
8252         if (get_jenv_res == JNI_EDETACHED) {
8253                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8254         }
8255         return ret_ref;
8256 }
8257 LDKWriteableEcdsaChannelSigner derive_channel_signer_LDKSignerProvider_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
8258         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8259         JNIEnv *env;
8260         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8261         if (get_jenv_res == JNI_EDETACHED) {
8262                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8263         } else {
8264                 DO_ASSERT(get_jenv_res == JNI_OK);
8265         }
8266         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8267         int8_tArray channel_keys_id_arr = (*env)->NewByteArray(env, 32);
8268         (*env)->SetByteArrayRegion(env, channel_keys_id_arr, 0, 32, channel_keys_id.data);
8269         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8270         CHECK(obj != NULL);
8271         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->derive_channel_signer_meth, channel_value_satoshis_conv, channel_keys_id_arr);
8272         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8273                 (*env)->ExceptionDescribe(env);
8274                 (*env)->FatalError(env, "A call to derive_channel_signer in LDKSignerProvider from rust threw an exception.");
8275         }
8276         void* ret_ptr = untag_ptr(ret);
8277         CHECK_ACCESS(ret_ptr);
8278         LDKWriteableEcdsaChannelSigner ret_conv = *(LDKWriteableEcdsaChannelSigner*)(ret_ptr);
8279         FREE(untag_ptr(ret));
8280         if (get_jenv_res == JNI_EDETACHED) {
8281                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8282         }
8283         return ret_conv;
8284 }
8285 LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer_LDKSignerProvider_jcall(const void* this_arg, LDKu8slice reader) {
8286         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8287         JNIEnv *env;
8288         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8289         if (get_jenv_res == JNI_EDETACHED) {
8290                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8291         } else {
8292                 DO_ASSERT(get_jenv_res == JNI_OK);
8293         }
8294         LDKu8slice reader_var = reader;
8295         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
8296         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
8297         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8298         CHECK(obj != NULL);
8299         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
8300         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8301                 (*env)->ExceptionDescribe(env);
8302                 (*env)->FatalError(env, "A call to read_chan_signer in LDKSignerProvider from rust threw an exception.");
8303         }
8304         void* ret_ptr = untag_ptr(ret);
8305         CHECK_ACCESS(ret_ptr);
8306         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ ret_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(ret_ptr);
8307         FREE(untag_ptr(ret));
8308         if (get_jenv_res == JNI_EDETACHED) {
8309                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8310         }
8311         return ret_conv;
8312 }
8313 LDKCVec_u8Z get_destination_script_LDKSignerProvider_jcall(const void* this_arg) {
8314         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8315         JNIEnv *env;
8316         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8317         if (get_jenv_res == JNI_EDETACHED) {
8318                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8319         } else {
8320                 DO_ASSERT(get_jenv_res == JNI_OK);
8321         }
8322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8323         CHECK(obj != NULL);
8324         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
8325         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8326                 (*env)->ExceptionDescribe(env);
8327                 (*env)->FatalError(env, "A call to get_destination_script in LDKSignerProvider from rust threw an exception.");
8328         }
8329         LDKCVec_u8Z ret_ref;
8330         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8331         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8332         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8333         if (get_jenv_res == JNI_EDETACHED) {
8334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8335         }
8336         return ret_ref;
8337 }
8338 LDKShutdownScript get_shutdown_scriptpubkey_LDKSignerProvider_jcall(const void* this_arg) {
8339         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8340         JNIEnv *env;
8341         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8342         if (get_jenv_res == JNI_EDETACHED) {
8343                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8344         } else {
8345                 DO_ASSERT(get_jenv_res == JNI_OK);
8346         }
8347         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8348         CHECK(obj != NULL);
8349         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
8350         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8351                 (*env)->ExceptionDescribe(env);
8352                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKSignerProvider from rust threw an exception.");
8353         }
8354         LDKShutdownScript ret_conv;
8355         ret_conv.inner = untag_ptr(ret);
8356         ret_conv.is_owned = ptr_is_owned(ret);
8357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
8358         if (get_jenv_res == JNI_EDETACHED) {
8359                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8360         }
8361         return ret_conv;
8362 }
8363 static void LDKSignerProvider_JCalls_cloned(LDKSignerProvider* new_obj) {
8364         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) new_obj->this_arg;
8365         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8366 }
8367 static inline LDKSignerProvider LDKSignerProvider_init (JNIEnv *env, jclass clz, jobject o) {
8368         jclass c = (*env)->GetObjectClass(env, o);
8369         CHECK(c != NULL);
8370         LDKSignerProvider_JCalls *calls = MALLOC(sizeof(LDKSignerProvider_JCalls), "LDKSignerProvider_JCalls");
8371         atomic_init(&calls->refcnt, 1);
8372         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8373         calls->o = (*env)->NewWeakGlobalRef(env, o);
8374         calls->generate_channel_keys_id_meth = (*env)->GetMethodID(env, c, "generate_channel_keys_id", "(ZJ[B)[B");
8375         CHECK(calls->generate_channel_keys_id_meth != NULL);
8376         calls->derive_channel_signer_meth = (*env)->GetMethodID(env, c, "derive_channel_signer", "(J[B)J");
8377         CHECK(calls->derive_channel_signer_meth != NULL);
8378         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
8379         CHECK(calls->read_chan_signer_meth != NULL);
8380         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
8381         CHECK(calls->get_destination_script_meth != NULL);
8382         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
8383         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
8384
8385         LDKSignerProvider ret = {
8386                 .this_arg = (void*) calls,
8387                 .generate_channel_keys_id = generate_channel_keys_id_LDKSignerProvider_jcall,
8388                 .derive_channel_signer = derive_channel_signer_LDKSignerProvider_jcall,
8389                 .read_chan_signer = read_chan_signer_LDKSignerProvider_jcall,
8390                 .get_destination_script = get_destination_script_LDKSignerProvider_jcall,
8391                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKSignerProvider_jcall,
8392                 .free = LDKSignerProvider_JCalls_free,
8393         };
8394         return ret;
8395 }
8396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSignerProvider_1new(JNIEnv *env, jclass clz, jobject o) {
8397         LDKSignerProvider *res_ptr = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
8398         *res_ptr = LDKSignerProvider_init(env, clz, o);
8399         return tag_ptr(res_ptr, true);
8400 }
8401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignerProvider_1generate_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis, int8_tArray user_channel_id) {
8402         void* this_arg_ptr = untag_ptr(this_arg);
8403         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8404         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8405         LDKU128 user_channel_id_ref;
8406         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
8407         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
8408         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8409         (*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);
8410         return ret_arr;
8411 }
8412
8413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1derive_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
8414         void* this_arg_ptr = untag_ptr(this_arg);
8415         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8416         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8417         LDKThirtyTwoBytes channel_keys_id_ref;
8418         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
8419         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
8420         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
8421         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
8422         return tag_ptr(ret_ret, true);
8423 }
8424
8425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
8426         void* this_arg_ptr = untag_ptr(this_arg);
8427         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8428         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8429         LDKu8slice reader_ref;
8430         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
8431         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
8432         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
8433         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
8434         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
8435         return tag_ptr(ret_conv, true);
8436 }
8437
8438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
8439         void* this_arg_ptr = untag_ptr(this_arg);
8440         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8441         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8442         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
8443         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8444         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8445         CVec_u8Z_free(ret_var);
8446         return ret_arr;
8447 }
8448
8449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
8450         void* this_arg_ptr = untag_ptr(this_arg);
8451         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8452         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8453         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
8454         int64_t ret_ref = 0;
8455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8456         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8457         return ret_ref;
8458 }
8459
8460 typedef struct LDKFeeEstimator_JCalls {
8461         atomic_size_t refcnt;
8462         JavaVM *vm;
8463         jweak o;
8464         jmethodID get_est_sat_per_1000_weight_meth;
8465 } LDKFeeEstimator_JCalls;
8466 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
8467         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8468         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8469                 JNIEnv *env;
8470                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8471                 if (get_jenv_res == JNI_EDETACHED) {
8472                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8473                 } else {
8474                         DO_ASSERT(get_jenv_res == JNI_OK);
8475                 }
8476                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8477                 if (get_jenv_res == JNI_EDETACHED) {
8478                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8479                 }
8480                 FREE(j_calls);
8481         }
8482 }
8483 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
8484         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8485         JNIEnv *env;
8486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8487         if (get_jenv_res == JNI_EDETACHED) {
8488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8489         } else {
8490                 DO_ASSERT(get_jenv_res == JNI_OK);
8491         }
8492         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
8493         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8494         CHECK(obj != NULL);
8495         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
8496         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8497                 (*env)->ExceptionDescribe(env);
8498                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
8499         }
8500         if (get_jenv_res == JNI_EDETACHED) {
8501                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8502         }
8503         return ret;
8504 }
8505 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
8506         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
8507         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8508 }
8509 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
8510         jclass c = (*env)->GetObjectClass(env, o);
8511         CHECK(c != NULL);
8512         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
8513         atomic_init(&calls->refcnt, 1);
8514         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8515         calls->o = (*env)->NewWeakGlobalRef(env, o);
8516         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
8517         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
8518
8519         LDKFeeEstimator ret = {
8520                 .this_arg = (void*) calls,
8521                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
8522                 .free = LDKFeeEstimator_JCalls_free,
8523         };
8524         return ret;
8525 }
8526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
8527         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
8528         *res_ptr = LDKFeeEstimator_init(env, clz, o);
8529         return tag_ptr(res_ptr, true);
8530 }
8531 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) {
8532         void* this_arg_ptr = untag_ptr(this_arg);
8533         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8534         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
8535         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
8536         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
8537         return ret_conv;
8538 }
8539
8540 typedef struct LDKRouter_JCalls {
8541         atomic_size_t refcnt;
8542         JavaVM *vm;
8543         jweak o;
8544         jmethodID find_route_meth;
8545         jmethodID find_route_with_id_meth;
8546 } LDKRouter_JCalls;
8547 static void LDKRouter_JCalls_free(void* this_arg) {
8548         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8549         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8550                 JNIEnv *env;
8551                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8552                 if (get_jenv_res == JNI_EDETACHED) {
8553                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8554                 } else {
8555                         DO_ASSERT(get_jenv_res == JNI_OK);
8556                 }
8557                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8558                 if (get_jenv_res == JNI_EDETACHED) {
8559                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8560                 }
8561                 FREE(j_calls);
8562         }
8563 }
8564 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, const LDKInFlightHtlcs * inflight_htlcs) {
8565         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8566         JNIEnv *env;
8567         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8568         if (get_jenv_res == JNI_EDETACHED) {
8569                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8570         } else {
8571                 DO_ASSERT(get_jenv_res == JNI_OK);
8572         }
8573         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8574         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8575         LDKRouteParameters route_params_var = *route_params;
8576         int64_t route_params_ref = 0;
8577         route_params_var = RouteParameters_clone(&route_params_var);
8578         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8579         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8580         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8581         int64_tArray first_hops_arr = NULL;
8582         if (first_hops != NULL) {
8583                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8584                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8585                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8586                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8587                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8588                         int64_t first_hops_conv_16_ref = 0;
8589                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8590                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8591                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8592                 }
8593                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8594         }
8595         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8596         int64_t inflight_htlcs_ref = 0;
8597         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8598         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8599         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8600         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8601         CHECK(obj != NULL);
8602         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
8603         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8604                 (*env)->ExceptionDescribe(env);
8605                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
8606         }
8607         void* ret_ptr = untag_ptr(ret);
8608         CHECK_ACCESS(ret_ptr);
8609         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8610         FREE(untag_ptr(ret));
8611         if (get_jenv_res == JNI_EDETACHED) {
8612                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8613         }
8614         return ret_conv;
8615 }
8616 LDKCResult_RouteLightningErrorZ find_route_with_id_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, const LDKInFlightHtlcs * inflight_htlcs, LDKThirtyTwoBytes _payment_hash, LDKThirtyTwoBytes _payment_id) {
8617         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8618         JNIEnv *env;
8619         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8620         if (get_jenv_res == JNI_EDETACHED) {
8621                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8622         } else {
8623                 DO_ASSERT(get_jenv_res == JNI_OK);
8624         }
8625         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8626         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8627         LDKRouteParameters route_params_var = *route_params;
8628         int64_t route_params_ref = 0;
8629         route_params_var = RouteParameters_clone(&route_params_var);
8630         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8631         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8632         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8633         int64_tArray first_hops_arr = NULL;
8634         if (first_hops != NULL) {
8635                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8636                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8637                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8638                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8639                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8640                         int64_t first_hops_conv_16_ref = 0;
8641                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8642                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8643                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8644                 }
8645                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8646         }
8647         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8648         int64_t inflight_htlcs_ref = 0;
8649         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8651         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8652         int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
8653         (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
8654         int8_tArray _payment_id_arr = (*env)->NewByteArray(env, 32);
8655         (*env)->SetByteArrayRegion(env, _payment_id_arr, 0, 32, _payment_id.data);
8656         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8657         CHECK(obj != NULL);
8658         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);
8659         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8660                 (*env)->ExceptionDescribe(env);
8661                 (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
8662         }
8663         void* ret_ptr = untag_ptr(ret);
8664         CHECK_ACCESS(ret_ptr);
8665         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8666         FREE(untag_ptr(ret));
8667         if (get_jenv_res == JNI_EDETACHED) {
8668                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8669         }
8670         return ret_conv;
8671 }
8672 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
8673         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
8674         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8675 }
8676 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
8677         jclass c = (*env)->GetObjectClass(env, o);
8678         CHECK(c != NULL);
8679         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
8680         atomic_init(&calls->refcnt, 1);
8681         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8682         calls->o = (*env)->NewWeakGlobalRef(env, o);
8683         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
8684         CHECK(calls->find_route_meth != NULL);
8685         calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
8686         CHECK(calls->find_route_with_id_meth != NULL);
8687
8688         LDKRouter ret = {
8689                 .this_arg = (void*) calls,
8690                 .find_route = find_route_LDKRouter_jcall,
8691                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
8692                 .free = LDKRouter_JCalls_free,
8693         };
8694         return ret;
8695 }
8696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
8697         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
8698         *res_ptr = LDKRouter_init(env, clz, o);
8699         return tag_ptr(res_ptr, true);
8700 }
8701 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) {
8702         void* this_arg_ptr = untag_ptr(this_arg);
8703         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8704         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8705         LDKPublicKey payer_ref;
8706         CHECK((*env)->GetArrayLength(env, payer) == 33);
8707         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8708         LDKRouteParameters route_params_conv;
8709         route_params_conv.inner = untag_ptr(route_params);
8710         route_params_conv.is_owned = ptr_is_owned(route_params);
8711         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8712         route_params_conv.is_owned = false;
8713         LDKCVec_ChannelDetailsZ first_hops_constr;
8714         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8715         if (first_hops != NULL) {
8716                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8717                 if (first_hops_constr.datalen > 0)
8718                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8719                 else
8720                         first_hops_constr.data = NULL;
8721                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8722                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8723                         int64_t first_hops_conv_16 = first_hops_vals[q];
8724                         LDKChannelDetails first_hops_conv_16_conv;
8725                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8726                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8727                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8728                         first_hops_conv_16_conv.is_owned = false;
8729                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8730                 }
8731                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8732                 first_hops_ptr = &first_hops_constr;
8733         }
8734         LDKInFlightHtlcs inflight_htlcs_conv;
8735         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8736         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8737         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8738         inflight_htlcs_conv.is_owned = false;
8739         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8740         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, &inflight_htlcs_conv);
8741         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8742         return tag_ptr(ret_conv, true);
8743 }
8744
8745 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) {
8746         void* this_arg_ptr = untag_ptr(this_arg);
8747         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8748         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8749         LDKPublicKey payer_ref;
8750         CHECK((*env)->GetArrayLength(env, payer) == 33);
8751         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8752         LDKRouteParameters route_params_conv;
8753         route_params_conv.inner = untag_ptr(route_params);
8754         route_params_conv.is_owned = ptr_is_owned(route_params);
8755         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8756         route_params_conv.is_owned = false;
8757         LDKCVec_ChannelDetailsZ first_hops_constr;
8758         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8759         if (first_hops != NULL) {
8760                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8761                 if (first_hops_constr.datalen > 0)
8762                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8763                 else
8764                         first_hops_constr.data = NULL;
8765                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8766                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8767                         int64_t first_hops_conv_16 = first_hops_vals[q];
8768                         LDKChannelDetails first_hops_conv_16_conv;
8769                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8770                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8771                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8772                         first_hops_conv_16_conv.is_owned = false;
8773                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8774                 }
8775                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8776                 first_hops_ptr = &first_hops_constr;
8777         }
8778         LDKInFlightHtlcs inflight_htlcs_conv;
8779         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8780         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8781         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8782         inflight_htlcs_conv.is_owned = false;
8783         LDKThirtyTwoBytes _payment_hash_ref;
8784         CHECK((*env)->GetArrayLength(env, _payment_hash) == 32);
8785         (*env)->GetByteArrayRegion(env, _payment_hash, 0, 32, _payment_hash_ref.data);
8786         LDKThirtyTwoBytes _payment_id_ref;
8787         CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
8788         (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
8789         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8790         *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);
8791         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8792         return tag_ptr(ret_conv, true);
8793 }
8794
8795 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8796         return ThirtyTwoBytes_clone(&owner->a);
8797 }
8798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8799         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8800         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
8802         return ret_arr;
8803 }
8804
8805 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8806         LDKChannelManager ret = owner->b;
8807         ret.is_owned = false;
8808         return ret;
8809 }
8810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8811         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8812         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
8813         int64_t ret_ref = 0;
8814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8816         return ret_ref;
8817 }
8818
8819 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8820 CHECK(owner->result_ok);
8821         return &*owner->contents.result;
8822 }
8823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8824         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8825         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
8826         return ret_ret;
8827 }
8828
8829 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8830 CHECK(!owner->result_ok);
8831         return DecodeError_clone(&*owner->contents.err);
8832 }
8833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8834         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8835         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8836         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
8837         int64_t ret_ref = tag_ptr(ret_copy, true);
8838         return ret_ref;
8839 }
8840
8841 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8842         LDKChannelConfig ret = *owner->contents.result;
8843         ret.is_owned = false;
8844         return ret;
8845 }
8846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8847         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8848         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
8849         int64_t ret_ref = 0;
8850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8851         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8852         return ret_ref;
8853 }
8854
8855 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8856 CHECK(!owner->result_ok);
8857         return DecodeError_clone(&*owner->contents.err);
8858 }
8859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8860         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8861         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8862         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
8863         int64_t ret_ref = tag_ptr(ret_copy, true);
8864         return ret_ref;
8865 }
8866
8867 static jclass LDKCOption_APIErrorZ_Some_class = NULL;
8868 static jmethodID LDKCOption_APIErrorZ_Some_meth = NULL;
8869 static jclass LDKCOption_APIErrorZ_None_class = NULL;
8870 static jmethodID LDKCOption_APIErrorZ_None_meth = NULL;
8871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1APIErrorZ_init (JNIEnv *env, jclass clz) {
8872         LDKCOption_APIErrorZ_Some_class =
8873                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$Some"));
8874         CHECK(LDKCOption_APIErrorZ_Some_class != NULL);
8875         LDKCOption_APIErrorZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_Some_class, "<init>", "(J)V");
8876         CHECK(LDKCOption_APIErrorZ_Some_meth != NULL);
8877         LDKCOption_APIErrorZ_None_class =
8878                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$None"));
8879         CHECK(LDKCOption_APIErrorZ_None_class != NULL);
8880         LDKCOption_APIErrorZ_None_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_None_class, "<init>", "()V");
8881         CHECK(LDKCOption_APIErrorZ_None_meth != NULL);
8882 }
8883 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1APIErrorZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8884         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
8885         switch(obj->tag) {
8886                 case LDKCOption_APIErrorZ_Some: {
8887                         int64_t some_ref = tag_ptr(&obj->some, false);
8888                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_Some_class, LDKCOption_APIErrorZ_Some_meth, some_ref);
8889                 }
8890                 case LDKCOption_APIErrorZ_None: {
8891                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_None_class, LDKCOption_APIErrorZ_None_meth);
8892                 }
8893                 default: abort();
8894         }
8895 }
8896 static inline struct LDKCOption_APIErrorZ CResult_COption_APIErrorZDecodeErrorZ_get_ok(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8897 CHECK(owner->result_ok);
8898         return COption_APIErrorZ_clone(&*owner->contents.result);
8899 }
8900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8901         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8902         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
8903         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_ok(owner_conv);
8904         int64_t ret_ref = tag_ptr(ret_copy, true);
8905         return ret_ref;
8906 }
8907
8908 static inline struct LDKDecodeError CResult_COption_APIErrorZDecodeErrorZ_get_err(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8909 CHECK(!owner->result_ok);
8910         return DecodeError_clone(&*owner->contents.err);
8911 }
8912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8913         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8914         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8915         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_err(owner_conv);
8916         int64_t ret_ref = tag_ptr(ret_copy, true);
8917         return ret_ref;
8918 }
8919
8920 static inline struct LDKUntrustedString CResult_UntrustedStringDecodeErrorZ_get_ok(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
8921         LDKUntrustedString ret = *owner->contents.result;
8922         ret.is_owned = false;
8923         return ret;
8924 }
8925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8926         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
8927         LDKUntrustedString ret_var = CResult_UntrustedStringDecodeErrorZ_get_ok(owner_conv);
8928         int64_t ret_ref = 0;
8929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8931         return ret_ref;
8932 }
8933
8934 static inline struct LDKDecodeError CResult_UntrustedStringDecodeErrorZ_get_err(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
8935 CHECK(!owner->result_ok);
8936         return DecodeError_clone(&*owner->contents.err);
8937 }
8938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8939         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
8940         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8941         *ret_copy = CResult_UntrustedStringDecodeErrorZ_get_err(owner_conv);
8942         int64_t ret_ref = tag_ptr(ret_copy, true);
8943         return ret_ref;
8944 }
8945
8946 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8947         LDKOutPoint ret = *owner->contents.result;
8948         ret.is_owned = false;
8949         return ret;
8950 }
8951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8952         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8953         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
8954         int64_t ret_ref = 0;
8955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8957         return ret_ref;
8958 }
8959
8960 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8961 CHECK(!owner->result_ok);
8962         return DecodeError_clone(&*owner->contents.err);
8963 }
8964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8965         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8966         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8967         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
8968         int64_t ret_ref = tag_ptr(ret_copy, true);
8969         return ret_ref;
8970 }
8971
8972 typedef struct LDKType_JCalls {
8973         atomic_size_t refcnt;
8974         JavaVM *vm;
8975         jweak o;
8976         jmethodID type_id_meth;
8977         jmethodID debug_str_meth;
8978         jmethodID write_meth;
8979 } LDKType_JCalls;
8980 static void LDKType_JCalls_free(void* this_arg) {
8981         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8982         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8983                 JNIEnv *env;
8984                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8985                 if (get_jenv_res == JNI_EDETACHED) {
8986                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8987                 } else {
8988                         DO_ASSERT(get_jenv_res == JNI_OK);
8989                 }
8990                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8991                 if (get_jenv_res == JNI_EDETACHED) {
8992                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8993                 }
8994                 FREE(j_calls);
8995         }
8996 }
8997 uint16_t type_id_LDKType_jcall(const void* this_arg) {
8998         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8999         JNIEnv *env;
9000         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9001         if (get_jenv_res == JNI_EDETACHED) {
9002                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9003         } else {
9004                 DO_ASSERT(get_jenv_res == JNI_OK);
9005         }
9006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9007         CHECK(obj != NULL);
9008         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
9009         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9010                 (*env)->ExceptionDescribe(env);
9011                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
9012         }
9013         if (get_jenv_res == JNI_EDETACHED) {
9014                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9015         }
9016         return ret;
9017 }
9018 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
9019         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
9020         JNIEnv *env;
9021         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9022         if (get_jenv_res == JNI_EDETACHED) {
9023                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9024         } else {
9025                 DO_ASSERT(get_jenv_res == JNI_OK);
9026         }
9027         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9028         CHECK(obj != NULL);
9029         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
9030         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9031                 (*env)->ExceptionDescribe(env);
9032                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
9033         }
9034         LDKStr ret_conv = java_to_owned_str(env, ret);
9035         if (get_jenv_res == JNI_EDETACHED) {
9036                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9037         }
9038         return ret_conv;
9039 }
9040 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
9041         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
9042         JNIEnv *env;
9043         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9044         if (get_jenv_res == JNI_EDETACHED) {
9045                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9046         } else {
9047                 DO_ASSERT(get_jenv_res == JNI_OK);
9048         }
9049         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9050         CHECK(obj != NULL);
9051         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9052         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9053                 (*env)->ExceptionDescribe(env);
9054                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
9055         }
9056         LDKCVec_u8Z ret_ref;
9057         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9058         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9059         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9060         if (get_jenv_res == JNI_EDETACHED) {
9061                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9062         }
9063         return ret_ref;
9064 }
9065 static void LDKType_JCalls_cloned(LDKType* new_obj) {
9066         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
9067         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9068 }
9069 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
9070         jclass c = (*env)->GetObjectClass(env, o);
9071         CHECK(c != NULL);
9072         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
9073         atomic_init(&calls->refcnt, 1);
9074         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9075         calls->o = (*env)->NewWeakGlobalRef(env, o);
9076         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
9077         CHECK(calls->type_id_meth != NULL);
9078         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
9079         CHECK(calls->debug_str_meth != NULL);
9080         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9081         CHECK(calls->write_meth != NULL);
9082
9083         LDKType ret = {
9084                 .this_arg = (void*) calls,
9085                 .type_id = type_id_LDKType_jcall,
9086                 .debug_str = debug_str_LDKType_jcall,
9087                 .write = write_LDKType_jcall,
9088                 .cloned = LDKType_JCalls_cloned,
9089                 .free = LDKType_JCalls_free,
9090         };
9091         return ret;
9092 }
9093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
9094         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
9095         *res_ptr = LDKType_init(env, clz, o);
9096         return tag_ptr(res_ptr, true);
9097 }
9098 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
9099         void* this_arg_ptr = untag_ptr(this_arg);
9100         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9101         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9102         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
9103         return ret_conv;
9104 }
9105
9106 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
9107         void* this_arg_ptr = untag_ptr(this_arg);
9108         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9109         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9110         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
9111         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9112         Str_free(ret_str);
9113         return ret_conv;
9114 }
9115
9116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9117         void* this_arg_ptr = untag_ptr(this_arg);
9118         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9119         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9120         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9123         CVec_u8Z_free(ret_var);
9124         return ret_arr;
9125 }
9126
9127 static jclass LDKCOption_TypeZ_Some_class = NULL;
9128 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
9129 static jclass LDKCOption_TypeZ_None_class = NULL;
9130 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
9131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
9132         LDKCOption_TypeZ_Some_class =
9133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
9134         CHECK(LDKCOption_TypeZ_Some_class != NULL);
9135         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
9136         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
9137         LDKCOption_TypeZ_None_class =
9138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
9139         CHECK(LDKCOption_TypeZ_None_class != NULL);
9140         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
9141         CHECK(LDKCOption_TypeZ_None_meth != NULL);
9142 }
9143 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9144         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
9145         switch(obj->tag) {
9146                 case LDKCOption_TypeZ_Some: {
9147                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
9148                         *some_ret = Type_clone(&obj->some);
9149                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
9150                 }
9151                 case LDKCOption_TypeZ_None: {
9152                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
9153                 }
9154                 default: abort();
9155         }
9156 }
9157 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
9158 CHECK(owner->result_ok);
9159         return COption_TypeZ_clone(&*owner->contents.result);
9160 }
9161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9162         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
9163         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9164         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
9165         int64_t ret_ref = tag_ptr(ret_copy, true);
9166         return ret_ref;
9167 }
9168
9169 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
9170 CHECK(!owner->result_ok);
9171         return DecodeError_clone(&*owner->contents.err);
9172 }
9173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9174         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
9175         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9176         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
9177         int64_t ret_ref = tag_ptr(ret_copy, true);
9178         return ret_ref;
9179 }
9180
9181 static jclass LDKPaymentError_Invoice_class = NULL;
9182 static jmethodID LDKPaymentError_Invoice_meth = NULL;
9183 static jclass LDKPaymentError_Sending_class = NULL;
9184 static jmethodID LDKPaymentError_Sending_meth = NULL;
9185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
9186         LDKPaymentError_Invoice_class =
9187                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
9188         CHECK(LDKPaymentError_Invoice_class != NULL);
9189         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
9190         CHECK(LDKPaymentError_Invoice_meth != NULL);
9191         LDKPaymentError_Sending_class =
9192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
9193         CHECK(LDKPaymentError_Sending_class != NULL);
9194         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(Lorg/ldk/enums/RetryableSendFailure;)V");
9195         CHECK(LDKPaymentError_Sending_meth != NULL);
9196 }
9197 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9198         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
9199         switch(obj->tag) {
9200                 case LDKPaymentError_Invoice: {
9201                         LDKStr invoice_str = obj->invoice;
9202                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
9203                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
9204                 }
9205                 case LDKPaymentError_Sending: {
9206                         jclass sending_conv = LDKRetryableSendFailure_to_java(env, obj->sending);
9207                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_conv);
9208                 }
9209                 default: abort();
9210         }
9211 }
9212 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9213 CHECK(owner->result_ok);
9214         return ThirtyTwoBytes_clone(&*owner->contents.result);
9215 }
9216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9217         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
9220         return ret_arr;
9221 }
9222
9223 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9224 CHECK(!owner->result_ok);
9225         return PaymentError_clone(&*owner->contents.err);
9226 }
9227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9228         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9229         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9230         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
9231         int64_t ret_ref = tag_ptr(ret_copy, true);
9232         return ret_ref;
9233 }
9234
9235 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9236 CHECK(owner->result_ok);
9237         return *owner->contents.result;
9238 }
9239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9240         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9241         CResult_NonePaymentErrorZ_get_ok(owner_conv);
9242 }
9243
9244 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9245 CHECK(!owner->result_ok);
9246         return PaymentError_clone(&*owner->contents.err);
9247 }
9248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9249         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9250         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9251         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
9252         int64_t ret_ref = tag_ptr(ret_copy, true);
9253         return ret_ref;
9254 }
9255
9256 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9257 CHECK(owner->result_ok);
9258         return *owner->contents.result;
9259 }
9260 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9261         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9262         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
9263         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9264         return ret_conv;
9265 }
9266
9267 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9268 CHECK(!owner->result_ok);
9269         return *owner->contents.err;
9270 }
9271 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9272         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9273         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
9274         return ret_conv;
9275 }
9276
9277 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9278         LDKChannelMonitorUpdate ret = *owner->contents.result;
9279         ret.is_owned = false;
9280         return ret;
9281 }
9282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9283         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9284         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
9285         int64_t ret_ref = 0;
9286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9288         return ret_ref;
9289 }
9290
9291 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9292 CHECK(!owner->result_ok);
9293         return DecodeError_clone(&*owner->contents.err);
9294 }
9295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9296         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9297         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9298         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
9299         int64_t ret_ref = tag_ptr(ret_copy, true);
9300         return ret_ref;
9301 }
9302
9303 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
9304 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
9305 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
9306 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
9307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
9308         LDKCOption_MonitorEventZ_Some_class =
9309                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
9310         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
9311         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
9312         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
9313         LDKCOption_MonitorEventZ_None_class =
9314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
9315         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
9316         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
9317         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
9318 }
9319 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9320         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
9321         switch(obj->tag) {
9322                 case LDKCOption_MonitorEventZ_Some: {
9323                         int64_t some_ref = tag_ptr(&obj->some, false);
9324                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
9325                 }
9326                 case LDKCOption_MonitorEventZ_None: {
9327                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
9328                 }
9329                 default: abort();
9330         }
9331 }
9332 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9333 CHECK(owner->result_ok);
9334         return COption_MonitorEventZ_clone(&*owner->contents.result);
9335 }
9336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9337         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9338         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
9339         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
9340         int64_t ret_ref = tag_ptr(ret_copy, true);
9341         return ret_ref;
9342 }
9343
9344 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9345 CHECK(!owner->result_ok);
9346         return DecodeError_clone(&*owner->contents.err);
9347 }
9348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9349         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9350         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9351         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
9352         int64_t ret_ref = tag_ptr(ret_copy, true);
9353         return ret_ref;
9354 }
9355
9356 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9357         LDKHTLCUpdate ret = *owner->contents.result;
9358         ret.is_owned = false;
9359         return ret;
9360 }
9361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9362         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9363         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
9364         int64_t ret_ref = 0;
9365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9367         return ret_ref;
9368 }
9369
9370 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9371 CHECK(!owner->result_ok);
9372         return DecodeError_clone(&*owner->contents.err);
9373 }
9374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9375         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9376         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9377         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
9378         int64_t ret_ref = tag_ptr(ret_copy, true);
9379         return ret_ref;
9380 }
9381
9382 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9383         LDKOutPoint ret = owner->a;
9384         ret.is_owned = false;
9385         return ret;
9386 }
9387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9388         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9389         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
9390         int64_t ret_ref = 0;
9391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9393         return ret_ref;
9394 }
9395
9396 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9397         return CVec_u8Z_clone(&owner->b);
9398 }
9399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9400         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9401         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
9402         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9403         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9404         CVec_u8Z_free(ret_var);
9405         return ret_arr;
9406 }
9407
9408 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9409         return owner->a;
9410 }
9411 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9412         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9413         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
9414         return ret_conv;
9415 }
9416
9417 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9418         return CVec_u8Z_clone(&owner->b);
9419 }
9420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9421         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9422         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
9423         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9424         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9425         CVec_u8Z_free(ret_var);
9426         return ret_arr;
9427 }
9428
9429 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
9430         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
9431         for (size_t i = 0; i < ret.datalen; i++) {
9432                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
9433         }
9434         return ret;
9435 }
9436 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9437         return ThirtyTwoBytes_clone(&owner->a);
9438 }
9439 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9440         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9441         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
9443         return ret_arr;
9444 }
9445
9446 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9447         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
9448 }
9449 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9450         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9451         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
9452         int64_tArray ret_arr = NULL;
9453         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9454         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9455         for (size_t v = 0; v < ret_var.datalen; v++) {
9456                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9457                 *ret_conv_21_conv = ret_var.data[v];
9458                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
9459         }
9460         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9461         FREE(ret_var.data);
9462         return ret_arr;
9463 }
9464
9465 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
9466         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 };
9467         for (size_t i = 0; i < ret.datalen; i++) {
9468                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
9469         }
9470         return ret;
9471 }
9472 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
9473         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
9474         for (size_t i = 0; i < ret.datalen; i++) {
9475                 ret.data[i] = Event_clone(&orig->data[i]);
9476         }
9477         return ret;
9478 }
9479 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9480         return owner->a;
9481 }
9482 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9483         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9484         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
9485         return ret_conv;
9486 }
9487
9488 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9489         return TxOut_clone(&owner->b);
9490 }
9491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9492         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9493         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9494         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
9495         return tag_ptr(ret_ref, true);
9496 }
9497
9498 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
9499         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
9500         for (size_t i = 0; i < ret.datalen; i++) {
9501                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
9502         }
9503         return ret;
9504 }
9505 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9506         return ThirtyTwoBytes_clone(&owner->a);
9507 }
9508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9509         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
9512         return ret_arr;
9513 }
9514
9515 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9516         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
9517 }
9518 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9519         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9520         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
9521         int64_tArray ret_arr = NULL;
9522         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9523         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9524         for (size_t u = 0; u < ret_var.datalen; u++) {
9525                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9526                 *ret_conv_20_conv = ret_var.data[u];
9527                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
9528         }
9529         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9530         FREE(ret_var.data);
9531         return ret_arr;
9532 }
9533
9534 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
9535         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 };
9536         for (size_t i = 0; i < ret.datalen; i++) {
9537                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
9538         }
9539         return ret;
9540 }
9541 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
9542 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
9543 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
9544 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
9545 static jclass LDKBalance_ContentiousClaimable_class = NULL;
9546 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
9547 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
9548 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
9549 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
9550 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
9551 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
9552 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
9553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
9554         LDKBalance_ClaimableOnChannelClose_class =
9555                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
9556         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
9557         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
9558         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
9559         LDKBalance_ClaimableAwaitingConfirmations_class =
9560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
9561         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
9562         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
9563         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
9564         LDKBalance_ContentiousClaimable_class =
9565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
9566         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
9567         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
9568         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
9569         LDKBalance_MaybeTimeoutClaimableHTLC_class =
9570                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
9571         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
9572         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
9573         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
9574         LDKBalance_MaybePreimageClaimableHTLC_class =
9575                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
9576         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
9577         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
9578         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
9579         LDKBalance_CounterpartyRevokedOutputClaimable_class =
9580                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
9581         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
9582         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
9583         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
9584 }
9585 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9586         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
9587         switch(obj->tag) {
9588                 case LDKBalance_ClaimableOnChannelClose: {
9589                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
9590                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
9591                 }
9592                 case LDKBalance_ClaimableAwaitingConfirmations: {
9593                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
9594                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
9595                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
9596                 }
9597                 case LDKBalance_ContentiousClaimable: {
9598                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
9599                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
9600                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
9601                 }
9602                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
9603                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
9604                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
9605                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
9606                 }
9607                 case LDKBalance_MaybePreimageClaimableHTLC: {
9608                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
9609                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
9610                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
9611                 }
9612                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
9613                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
9614                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
9615                 }
9616                 default: abort();
9617         }
9618 }
9619 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
9620         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
9621         for (size_t i = 0; i < ret.datalen; i++) {
9622                 ret.data[i] = Balance_clone(&orig->data[i]);
9623         }
9624         return ret;
9625 }
9626 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9627 CHECK(owner->result_ok);
9628         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
9629 }
9630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9631         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9632         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
9633         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
9634         return tag_ptr(ret_conv, true);
9635 }
9636
9637 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9638 CHECK(!owner->result_ok);
9639         return DecodeError_clone(&*owner->contents.err);
9640 }
9641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9642         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9643         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9644         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
9645         int64_t ret_ref = tag_ptr(ret_copy, true);
9646         return ret_ref;
9647 }
9648
9649 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9650         return owner->a;
9651 }
9652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9653         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9654         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
9656         return ret_arr;
9657 }
9658
9659 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9660         return Type_clone(&owner->b);
9661 }
9662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9663         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9664         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
9665         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
9666         return tag_ptr(ret_ret, true);
9667 }
9668
9669 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
9670         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
9671         for (size_t i = 0; i < ret.datalen; i++) {
9672                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
9673         }
9674         return ret;
9675 }
9676 typedef struct LDKCustomOnionMessageContents_JCalls {
9677         atomic_size_t refcnt;
9678         JavaVM *vm;
9679         jweak o;
9680         jmethodID tlv_type_meth;
9681         jmethodID write_meth;
9682 } LDKCustomOnionMessageContents_JCalls;
9683 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
9684         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9685         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9686                 JNIEnv *env;
9687                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9688                 if (get_jenv_res == JNI_EDETACHED) {
9689                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9690                 } else {
9691                         DO_ASSERT(get_jenv_res == JNI_OK);
9692                 }
9693                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9694                 if (get_jenv_res == JNI_EDETACHED) {
9695                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9696                 }
9697                 FREE(j_calls);
9698         }
9699 }
9700 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9701         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9702         JNIEnv *env;
9703         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9704         if (get_jenv_res == JNI_EDETACHED) {
9705                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9706         } else {
9707                 DO_ASSERT(get_jenv_res == JNI_OK);
9708         }
9709         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9710         CHECK(obj != NULL);
9711         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
9712         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9713                 (*env)->ExceptionDescribe(env);
9714                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
9715         }
9716         if (get_jenv_res == JNI_EDETACHED) {
9717                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9718         }
9719         return ret;
9720 }
9721 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9722         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9723         JNIEnv *env;
9724         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9725         if (get_jenv_res == JNI_EDETACHED) {
9726                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9727         } else {
9728                 DO_ASSERT(get_jenv_res == JNI_OK);
9729         }
9730         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9731         CHECK(obj != NULL);
9732         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9733         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9734                 (*env)->ExceptionDescribe(env);
9735                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
9736         }
9737         LDKCVec_u8Z ret_ref;
9738         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9739         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9740         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9741         if (get_jenv_res == JNI_EDETACHED) {
9742                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9743         }
9744         return ret_ref;
9745 }
9746 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
9747         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
9748         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9749 }
9750 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
9751         jclass c = (*env)->GetObjectClass(env, o);
9752         CHECK(c != NULL);
9753         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
9754         atomic_init(&calls->refcnt, 1);
9755         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9756         calls->o = (*env)->NewWeakGlobalRef(env, o);
9757         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
9758         CHECK(calls->tlv_type_meth != NULL);
9759         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9760         CHECK(calls->write_meth != NULL);
9761
9762         LDKCustomOnionMessageContents ret = {
9763                 .this_arg = (void*) calls,
9764                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
9765                 .write = write_LDKCustomOnionMessageContents_jcall,
9766                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
9767                 .free = LDKCustomOnionMessageContents_JCalls_free,
9768         };
9769         return ret;
9770 }
9771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
9772         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9773         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
9774         return tag_ptr(res_ptr, true);
9775 }
9776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
9777         void* this_arg_ptr = untag_ptr(this_arg);
9778         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9779         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9780         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
9781         return ret_conv;
9782 }
9783
9784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9785         void* this_arg_ptr = untag_ptr(this_arg);
9786         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9787         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9788         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9791         CVec_u8Z_free(ret_var);
9792         return ret_arr;
9793 }
9794
9795 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
9796 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
9797 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
9798 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
9799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
9800         LDKCOption_CustomOnionMessageContentsZ_Some_class =
9801                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
9802         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
9803         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
9804         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
9805         LDKCOption_CustomOnionMessageContentsZ_None_class =
9806                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
9807         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
9808         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
9809         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
9810 }
9811 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9812         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
9813         switch(obj->tag) {
9814                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
9815                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9816                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
9817                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
9818                 }
9819                 case LDKCOption_CustomOnionMessageContentsZ_None: {
9820                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
9821                 }
9822                 default: abort();
9823         }
9824 }
9825 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9826 CHECK(owner->result_ok);
9827         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
9828 }
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9830         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9831         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
9832         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
9833         int64_t ret_ref = tag_ptr(ret_copy, true);
9834         return ret_ref;
9835 }
9836
9837 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9838 CHECK(!owner->result_ok);
9839         return DecodeError_clone(&*owner->contents.err);
9840 }
9841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9842         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9843         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9844         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
9845         int64_t ret_ref = tag_ptr(ret_copy, true);
9846         return ret_ref;
9847 }
9848
9849 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
9850 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
9851 static jclass LDKCOption_NetAddressZ_None_class = NULL;
9852 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
9853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
9854         LDKCOption_NetAddressZ_Some_class =
9855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
9856         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
9857         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
9858         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
9859         LDKCOption_NetAddressZ_None_class =
9860                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
9861         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
9862         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
9863         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
9864 }
9865 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9866         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
9867         switch(obj->tag) {
9868                 case LDKCOption_NetAddressZ_Some: {
9869                         int64_t some_ref = tag_ptr(&obj->some, false);
9870                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
9871                 }
9872                 case LDKCOption_NetAddressZ_None: {
9873                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
9874                 }
9875                 default: abort();
9876         }
9877 }
9878 static inline struct LDKPublicKey C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9879         return owner->a;
9880 }
9881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9882         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9883         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(owner_conv).compressed_form);
9885         return ret_arr;
9886 }
9887
9888 static inline struct LDKCOption_NetAddressZ C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9889         return COption_NetAddressZ_clone(&owner->b);
9890 }
9891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9892         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9893         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
9894         *ret_copy = C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(owner_conv);
9895         int64_t ret_ref = tag_ptr(ret_copy, true);
9896         return ret_ref;
9897 }
9898
9899 static inline LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_clone(const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ *orig) {
9900         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ clone bytes"), .datalen = orig->datalen };
9901         for (size_t i = 0; i < ret.datalen; i++) {
9902                 ret.data[i] = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(&orig->data[i]);
9903         }
9904         return ret;
9905 }
9906 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9907 CHECK(owner->result_ok);
9908         return CVec_u8Z_clone(&*owner->contents.result);
9909 }
9910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9911         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9912         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
9913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9915         CVec_u8Z_free(ret_var);
9916         return ret_arr;
9917 }
9918
9919 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9920         LDKPeerHandleError ret = *owner->contents.err;
9921         ret.is_owned = false;
9922         return ret;
9923 }
9924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9925         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9926         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
9927         int64_t ret_ref = 0;
9928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9930         return ret_ref;
9931 }
9932
9933 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9934 CHECK(owner->result_ok);
9935         return *owner->contents.result;
9936 }
9937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9938         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9939         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
9940 }
9941
9942 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9943         LDKPeerHandleError ret = *owner->contents.err;
9944         ret.is_owned = false;
9945         return ret;
9946 }
9947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9948         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9949         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9950         int64_t ret_ref = 0;
9951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9953         return ret_ref;
9954 }
9955
9956 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9957 CHECK(owner->result_ok);
9958         return *owner->contents.result;
9959 }
9960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9961         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9962         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9963         return ret_conv;
9964 }
9965
9966 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9967         LDKPeerHandleError ret = *owner->contents.err;
9968         ret.is_owned = false;
9969         return ret;
9970 }
9971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9972         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9973         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9974         int64_t ret_ref = 0;
9975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9977         return ret_ref;
9978 }
9979
9980 static jclass LDKSendError_Secp256k1_class = NULL;
9981 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9982 static jclass LDKSendError_TooBigPacket_class = NULL;
9983 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9984 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9985 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9986 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9987 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9988 static jclass LDKSendError_InvalidMessage_class = NULL;
9989 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
9990 static jclass LDKSendError_BufferFull_class = NULL;
9991 static jmethodID LDKSendError_BufferFull_meth = NULL;
9992 static jclass LDKSendError_GetNodeIdFailed_class = NULL;
9993 static jmethodID LDKSendError_GetNodeIdFailed_meth = NULL;
9994 static jclass LDKSendError_BlindedPathAdvanceFailed_class = NULL;
9995 static jmethodID LDKSendError_BlindedPathAdvanceFailed_meth = NULL;
9996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9997         LDKSendError_Secp256k1_class =
9998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9999         CHECK(LDKSendError_Secp256k1_class != NULL);
10000         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
10001         CHECK(LDKSendError_Secp256k1_meth != NULL);
10002         LDKSendError_TooBigPacket_class =
10003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
10004         CHECK(LDKSendError_TooBigPacket_class != NULL);
10005         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
10006         CHECK(LDKSendError_TooBigPacket_meth != NULL);
10007         LDKSendError_TooFewBlindedHops_class =
10008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
10009         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
10010         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
10011         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
10012         LDKSendError_InvalidFirstHop_class =
10013                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
10014         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
10015         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
10016         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
10017         LDKSendError_InvalidMessage_class =
10018                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
10019         CHECK(LDKSendError_InvalidMessage_class != NULL);
10020         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
10021         CHECK(LDKSendError_InvalidMessage_meth != NULL);
10022         LDKSendError_BufferFull_class =
10023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
10024         CHECK(LDKSendError_BufferFull_class != NULL);
10025         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
10026         CHECK(LDKSendError_BufferFull_meth != NULL);
10027         LDKSendError_GetNodeIdFailed_class =
10028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$GetNodeIdFailed"));
10029         CHECK(LDKSendError_GetNodeIdFailed_class != NULL);
10030         LDKSendError_GetNodeIdFailed_meth = (*env)->GetMethodID(env, LDKSendError_GetNodeIdFailed_class, "<init>", "()V");
10031         CHECK(LDKSendError_GetNodeIdFailed_meth != NULL);
10032         LDKSendError_BlindedPathAdvanceFailed_class =
10033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BlindedPathAdvanceFailed"));
10034         CHECK(LDKSendError_BlindedPathAdvanceFailed_class != NULL);
10035         LDKSendError_BlindedPathAdvanceFailed_meth = (*env)->GetMethodID(env, LDKSendError_BlindedPathAdvanceFailed_class, "<init>", "()V");
10036         CHECK(LDKSendError_BlindedPathAdvanceFailed_meth != NULL);
10037 }
10038 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10039         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
10040         switch(obj->tag) {
10041                 case LDKSendError_Secp256k1: {
10042                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
10043                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
10044                 }
10045                 case LDKSendError_TooBigPacket: {
10046                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
10047                 }
10048                 case LDKSendError_TooFewBlindedHops: {
10049                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
10050                 }
10051                 case LDKSendError_InvalidFirstHop: {
10052                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
10053                 }
10054                 case LDKSendError_InvalidMessage: {
10055                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
10056                 }
10057                 case LDKSendError_BufferFull: {
10058                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
10059                 }
10060                 case LDKSendError_GetNodeIdFailed: {
10061                         return (*env)->NewObject(env, LDKSendError_GetNodeIdFailed_class, LDKSendError_GetNodeIdFailed_meth);
10062                 }
10063                 case LDKSendError_BlindedPathAdvanceFailed: {
10064                         return (*env)->NewObject(env, LDKSendError_BlindedPathAdvanceFailed_class, LDKSendError_BlindedPathAdvanceFailed_meth);
10065                 }
10066                 default: abort();
10067         }
10068 }
10069 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
10070 CHECK(owner->result_ok);
10071         return *owner->contents.result;
10072 }
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10074         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
10075         CResult_NoneSendErrorZ_get_ok(owner_conv);
10076 }
10077
10078 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
10079 CHECK(!owner->result_ok);
10080         return SendError_clone(&*owner->contents.err);
10081 }
10082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10083         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
10084         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
10085         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
10086         int64_t ret_ref = tag_ptr(ret_copy, true);
10087         return ret_ref;
10088 }
10089
10090 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
10091         LDKBlindedPath ret = *owner->contents.result;
10092         ret.is_owned = false;
10093         return ret;
10094 }
10095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10096         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
10097         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
10098         int64_t ret_ref = 0;
10099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10101         return ret_ref;
10102 }
10103
10104 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
10105 CHECK(!owner->result_ok);
10106         return *owner->contents.err;
10107 }
10108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10109         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
10110         CResult_BlindedPathNoneZ_get_err(owner_conv);
10111 }
10112
10113 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
10114         LDKBlindedPath ret = *owner->contents.result;
10115         ret.is_owned = false;
10116         return ret;
10117 }
10118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10119         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
10120         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
10121         int64_t ret_ref = 0;
10122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10124         return ret_ref;
10125 }
10126
10127 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
10128 CHECK(!owner->result_ok);
10129         return DecodeError_clone(&*owner->contents.err);
10130 }
10131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10132         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
10133         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10134         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
10135         int64_t ret_ref = tag_ptr(ret_copy, true);
10136         return ret_ref;
10137 }
10138
10139 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
10140         LDKBlindedHop ret = *owner->contents.result;
10141         ret.is_owned = false;
10142         return ret;
10143 }
10144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10145         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
10146         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
10147         int64_t ret_ref = 0;
10148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10150         return ret_ref;
10151 }
10152
10153 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
10154 CHECK(!owner->result_ok);
10155         return DecodeError_clone(&*owner->contents.err);
10156 }
10157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10158         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
10159         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10160         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
10161         int64_t ret_ref = tag_ptr(ret_copy, true);
10162         return ret_ref;
10163 }
10164
10165 static jclass LDKParseError_Bech32Error_class = NULL;
10166 static jmethodID LDKParseError_Bech32Error_meth = NULL;
10167 static jclass LDKParseError_ParseAmountError_class = NULL;
10168 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
10169 static jclass LDKParseError_MalformedSignature_class = NULL;
10170 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
10171 static jclass LDKParseError_BadPrefix_class = NULL;
10172 static jmethodID LDKParseError_BadPrefix_meth = NULL;
10173 static jclass LDKParseError_UnknownCurrency_class = NULL;
10174 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
10175 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
10176 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
10177 static jclass LDKParseError_MalformedHRP_class = NULL;
10178 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
10179 static jclass LDKParseError_TooShortDataPart_class = NULL;
10180 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
10181 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
10182 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
10183 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
10184 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
10185 static jclass LDKParseError_PaddingError_class = NULL;
10186 static jmethodID LDKParseError_PaddingError_meth = NULL;
10187 static jclass LDKParseError_IntegerOverflowError_class = NULL;
10188 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
10189 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
10190 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
10191 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
10192 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
10193 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
10194 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
10195 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
10196 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
10197 static jclass LDKParseError_InvalidSliceLength_class = NULL;
10198 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
10199 static jclass LDKParseError_Skip_class = NULL;
10200 static jmethodID LDKParseError_Skip_meth = NULL;
10201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
10202         LDKParseError_Bech32Error_class =
10203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
10204         CHECK(LDKParseError_Bech32Error_class != NULL);
10205         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
10206         CHECK(LDKParseError_Bech32Error_meth != NULL);
10207         LDKParseError_ParseAmountError_class =
10208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
10209         CHECK(LDKParseError_ParseAmountError_class != NULL);
10210         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
10211         CHECK(LDKParseError_ParseAmountError_meth != NULL);
10212         LDKParseError_MalformedSignature_class =
10213                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
10214         CHECK(LDKParseError_MalformedSignature_class != NULL);
10215         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
10216         CHECK(LDKParseError_MalformedSignature_meth != NULL);
10217         LDKParseError_BadPrefix_class =
10218                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
10219         CHECK(LDKParseError_BadPrefix_class != NULL);
10220         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
10221         CHECK(LDKParseError_BadPrefix_meth != NULL);
10222         LDKParseError_UnknownCurrency_class =
10223                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
10224         CHECK(LDKParseError_UnknownCurrency_class != NULL);
10225         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
10226         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
10227         LDKParseError_UnknownSiPrefix_class =
10228                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
10229         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
10230         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
10231         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
10232         LDKParseError_MalformedHRP_class =
10233                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
10234         CHECK(LDKParseError_MalformedHRP_class != NULL);
10235         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
10236         CHECK(LDKParseError_MalformedHRP_meth != NULL);
10237         LDKParseError_TooShortDataPart_class =
10238                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
10239         CHECK(LDKParseError_TooShortDataPart_class != NULL);
10240         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
10241         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
10242         LDKParseError_UnexpectedEndOfTaggedFields_class =
10243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
10244         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
10245         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
10246         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
10247         LDKParseError_DescriptionDecodeError_class =
10248                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
10249         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
10250         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
10251         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
10252         LDKParseError_PaddingError_class =
10253                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
10254         CHECK(LDKParseError_PaddingError_class != NULL);
10255         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
10256         CHECK(LDKParseError_PaddingError_meth != NULL);
10257         LDKParseError_IntegerOverflowError_class =
10258                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
10259         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
10260         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
10261         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
10262         LDKParseError_InvalidSegWitProgramLength_class =
10263                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
10264         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
10265         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
10266         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
10267         LDKParseError_InvalidPubKeyHashLength_class =
10268                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
10269         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
10270         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
10271         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
10272         LDKParseError_InvalidScriptHashLength_class =
10273                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
10274         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
10275         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
10276         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
10277         LDKParseError_InvalidRecoveryId_class =
10278                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
10279         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
10280         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
10281         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
10282         LDKParseError_InvalidSliceLength_class =
10283                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
10284         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
10285         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
10286         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
10287         LDKParseError_Skip_class =
10288                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
10289         CHECK(LDKParseError_Skip_class != NULL);
10290         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
10291         CHECK(LDKParseError_Skip_meth != NULL);
10292 }
10293 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10294         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
10295         switch(obj->tag) {
10296                 case LDKParseError_Bech32Error: {
10297                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
10298                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
10299                 }
10300                 case LDKParseError_ParseAmountError: {
10301                         /*obj->parse_amount_error*/
10302                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
10303                 }
10304                 case LDKParseError_MalformedSignature: {
10305                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
10306                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
10307                 }
10308                 case LDKParseError_BadPrefix: {
10309                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
10310                 }
10311                 case LDKParseError_UnknownCurrency: {
10312                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
10313                 }
10314                 case LDKParseError_UnknownSiPrefix: {
10315                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
10316                 }
10317                 case LDKParseError_MalformedHRP: {
10318                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
10319                 }
10320                 case LDKParseError_TooShortDataPart: {
10321                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
10322                 }
10323                 case LDKParseError_UnexpectedEndOfTaggedFields: {
10324                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
10325                 }
10326                 case LDKParseError_DescriptionDecodeError: {
10327                         /*obj->description_decode_error*/
10328                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
10329                 }
10330                 case LDKParseError_PaddingError: {
10331                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
10332                 }
10333                 case LDKParseError_IntegerOverflowError: {
10334                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
10335                 }
10336                 case LDKParseError_InvalidSegWitProgramLength: {
10337                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
10338                 }
10339                 case LDKParseError_InvalidPubKeyHashLength: {
10340                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
10341                 }
10342                 case LDKParseError_InvalidScriptHashLength: {
10343                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
10344                 }
10345                 case LDKParseError_InvalidRecoveryId: {
10346                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
10347                 }
10348                 case LDKParseError_InvalidSliceLength: {
10349                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
10350                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
10351                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
10352                 }
10353                 case LDKParseError_Skip: {
10354                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
10355                 }
10356                 default: abort();
10357         }
10358 }
10359 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10360 CHECK(owner->result_ok);
10361         return SiPrefix_clone(&*owner->contents.result);
10362 }
10363 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10364         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10365         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
10366         return ret_conv;
10367 }
10368
10369 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10370 CHECK(!owner->result_ok);
10371         return ParseError_clone(&*owner->contents.err);
10372 }
10373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10374         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10375         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10376         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
10377         int64_t ret_ref = tag_ptr(ret_copy, true);
10378         return ret_ref;
10379 }
10380
10381 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
10382 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
10383 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
10384 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
10385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
10386         LDKParseOrSemanticError_ParseError_class =
10387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
10388         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
10389         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
10390         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
10391         LDKParseOrSemanticError_SemanticError_class =
10392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
10393         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
10394         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
10395         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
10396 }
10397 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10398         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10399         switch(obj->tag) {
10400                 case LDKParseOrSemanticError_ParseError: {
10401                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
10402                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
10403                 }
10404                 case LDKParseOrSemanticError_SemanticError: {
10405                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
10406                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
10407                 }
10408                 default: abort();
10409         }
10410 }
10411 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10412         LDKInvoice ret = *owner->contents.result;
10413         ret.is_owned = false;
10414         return ret;
10415 }
10416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10417         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10418         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
10419         int64_t ret_ref = 0;
10420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10422         return ret_ref;
10423 }
10424
10425 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10426 CHECK(!owner->result_ok);
10427         return ParseOrSemanticError_clone(&*owner->contents.err);
10428 }
10429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10430         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10431         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
10432         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
10433         int64_t ret_ref = tag_ptr(ret_copy, true);
10434         return ret_ref;
10435 }
10436
10437 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10438         LDKSignedRawInvoice ret = *owner->contents.result;
10439         ret.is_owned = false;
10440         return ret;
10441 }
10442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10443         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10444         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
10445         int64_t ret_ref = 0;
10446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10447         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10448         return ret_ref;
10449 }
10450
10451 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10452 CHECK(!owner->result_ok);
10453         return ParseError_clone(&*owner->contents.err);
10454 }
10455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10456         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10457         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10458         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
10459         int64_t ret_ref = tag_ptr(ret_copy, true);
10460         return ret_ref;
10461 }
10462
10463 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10464         LDKRawInvoice ret = owner->a;
10465         ret.is_owned = false;
10466         return ret;
10467 }
10468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
10469         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10470         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
10471         int64_t ret_ref = 0;
10472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10474         return ret_ref;
10475 }
10476
10477 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10478         return ThirtyTwoBytes_clone(&owner->b);
10479 }
10480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
10481         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10482         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10483         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
10484         return ret_arr;
10485 }
10486
10487 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10488         LDKInvoiceSignature ret = owner->c;
10489         ret.is_owned = false;
10490         return ret;
10491 }
10492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
10493         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10494         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
10495         int64_t ret_ref = 0;
10496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10498         return ret_ref;
10499 }
10500
10501 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10502         LDKPayeePubKey ret = *owner->contents.result;
10503         ret.is_owned = false;
10504         return ret;
10505 }
10506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10507         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10508         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
10509         int64_t ret_ref = 0;
10510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10512         return ret_ref;
10513 }
10514
10515 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10516 CHECK(!owner->result_ok);
10517         return *owner->contents.err;
10518 }
10519 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10520         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10521         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
10522         return ret_conv;
10523 }
10524
10525 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
10526         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
10527         for (size_t i = 0; i < ret.datalen; i++) {
10528                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
10529         }
10530         return ret;
10531 }
10532 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10533         LDKPositiveTimestamp ret = *owner->contents.result;
10534         ret.is_owned = false;
10535         return ret;
10536 }
10537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10538         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10539         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
10540         int64_t ret_ref = 0;
10541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10543         return ret_ref;
10544 }
10545
10546 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10547 CHECK(!owner->result_ok);
10548         return CreationError_clone(&*owner->contents.err);
10549 }
10550 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10551         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10552         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
10553         return ret_conv;
10554 }
10555
10556 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10557 CHECK(owner->result_ok);
10558         return *owner->contents.result;
10559 }
10560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10561         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10562         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
10563 }
10564
10565 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10566 CHECK(!owner->result_ok);
10567         return SemanticError_clone(&*owner->contents.err);
10568 }
10569 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10570         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10571         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
10572         return ret_conv;
10573 }
10574
10575 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10576         LDKInvoice ret = *owner->contents.result;
10577         ret.is_owned = false;
10578         return ret;
10579 }
10580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10581         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10582         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
10583         int64_t ret_ref = 0;
10584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10586         return ret_ref;
10587 }
10588
10589 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10590 CHECK(!owner->result_ok);
10591         return SemanticError_clone(&*owner->contents.err);
10592 }
10593 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10594         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10595         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
10596         return ret_conv;
10597 }
10598
10599 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10600         LDKDescription ret = *owner->contents.result;
10601         ret.is_owned = false;
10602         return ret;
10603 }
10604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10605         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10606         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_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 enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10614 CHECK(!owner->result_ok);
10615         return CreationError_clone(&*owner->contents.err);
10616 }
10617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10618         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10619         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
10620         return ret_conv;
10621 }
10622
10623 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10624         LDKPrivateRoute ret = *owner->contents.result;
10625         ret.is_owned = false;
10626         return ret;
10627 }
10628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10629         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10630         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
10631         int64_t ret_ref = 0;
10632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10634         return ret_ref;
10635 }
10636
10637 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10638 CHECK(!owner->result_ok);
10639         return CreationError_clone(&*owner->contents.err);
10640 }
10641 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10642         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10643         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
10644         return ret_conv;
10645 }
10646
10647 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10648 CHECK(owner->result_ok);
10649         return NetAddress_clone(&*owner->contents.result);
10650 }
10651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10652         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10653         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10654         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
10655         int64_t ret_ref = tag_ptr(ret_copy, true);
10656         return ret_ref;
10657 }
10658
10659 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10660 CHECK(!owner->result_ok);
10661         return DecodeError_clone(&*owner->contents.err);
10662 }
10663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10664         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10665         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10666         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
10667         int64_t ret_ref = tag_ptr(ret_copy, true);
10668         return ret_ref;
10669 }
10670
10671 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
10672         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
10673         for (size_t i = 0; i < ret.datalen; i++) {
10674                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
10675         }
10676         return ret;
10677 }
10678 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
10679         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
10680         for (size_t i = 0; i < ret.datalen; i++) {
10681                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
10682         }
10683         return ret;
10684 }
10685 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
10686         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
10687         for (size_t i = 0; i < ret.datalen; i++) {
10688                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
10689         }
10690         return ret;
10691 }
10692 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
10693         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
10694         for (size_t i = 0; i < ret.datalen; i++) {
10695                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
10696         }
10697         return ret;
10698 }
10699 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10700         LDKAcceptChannel ret = *owner->contents.result;
10701         ret.is_owned = false;
10702         return ret;
10703 }
10704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10705         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10706         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
10707         int64_t ret_ref = 0;
10708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10710         return ret_ref;
10711 }
10712
10713 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10714 CHECK(!owner->result_ok);
10715         return DecodeError_clone(&*owner->contents.err);
10716 }
10717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10718         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10719         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10720         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
10721         int64_t ret_ref = tag_ptr(ret_copy, true);
10722         return ret_ref;
10723 }
10724
10725 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10726         LDKAnnouncementSignatures ret = *owner->contents.result;
10727         ret.is_owned = false;
10728         return ret;
10729 }
10730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10731         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10732         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
10733         int64_t ret_ref = 0;
10734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10736         return ret_ref;
10737 }
10738
10739 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10740 CHECK(!owner->result_ok);
10741         return DecodeError_clone(&*owner->contents.err);
10742 }
10743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10744         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10745         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10746         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
10747         int64_t ret_ref = tag_ptr(ret_copy, true);
10748         return ret_ref;
10749 }
10750
10751 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10752         LDKChannelReestablish ret = *owner->contents.result;
10753         ret.is_owned = false;
10754         return ret;
10755 }
10756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10757         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10758         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
10759         int64_t ret_ref = 0;
10760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10762         return ret_ref;
10763 }
10764
10765 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10766 CHECK(!owner->result_ok);
10767         return DecodeError_clone(&*owner->contents.err);
10768 }
10769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10770         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10771         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10772         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
10773         int64_t ret_ref = tag_ptr(ret_copy, true);
10774         return ret_ref;
10775 }
10776
10777 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10778         LDKClosingSigned ret = *owner->contents.result;
10779         ret.is_owned = false;
10780         return ret;
10781 }
10782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10783         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10784         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
10785         int64_t ret_ref = 0;
10786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10788         return ret_ref;
10789 }
10790
10791 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10792 CHECK(!owner->result_ok);
10793         return DecodeError_clone(&*owner->contents.err);
10794 }
10795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10796         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10797         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10798         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
10799         int64_t ret_ref = tag_ptr(ret_copy, true);
10800         return ret_ref;
10801 }
10802
10803 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10804         LDKClosingSignedFeeRange ret = *owner->contents.result;
10805         ret.is_owned = false;
10806         return ret;
10807 }
10808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10809         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10810         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
10811         int64_t ret_ref = 0;
10812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10814         return ret_ref;
10815 }
10816
10817 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10818 CHECK(!owner->result_ok);
10819         return DecodeError_clone(&*owner->contents.err);
10820 }
10821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10822         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10823         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10824         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
10825         int64_t ret_ref = tag_ptr(ret_copy, true);
10826         return ret_ref;
10827 }
10828
10829 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10830         LDKCommitmentSigned ret = *owner->contents.result;
10831         ret.is_owned = false;
10832         return ret;
10833 }
10834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10835         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10836         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
10837         int64_t ret_ref = 0;
10838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10840         return ret_ref;
10841 }
10842
10843 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10844 CHECK(!owner->result_ok);
10845         return DecodeError_clone(&*owner->contents.err);
10846 }
10847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10848         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10849         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10850         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
10851         int64_t ret_ref = tag_ptr(ret_copy, true);
10852         return ret_ref;
10853 }
10854
10855 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10856         LDKFundingCreated ret = *owner->contents.result;
10857         ret.is_owned = false;
10858         return ret;
10859 }
10860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10861         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10862         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
10863         int64_t ret_ref = 0;
10864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10866         return ret_ref;
10867 }
10868
10869 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10870 CHECK(!owner->result_ok);
10871         return DecodeError_clone(&*owner->contents.err);
10872 }
10873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10874         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10875         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10876         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
10877         int64_t ret_ref = tag_ptr(ret_copy, true);
10878         return ret_ref;
10879 }
10880
10881 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10882         LDKFundingSigned ret = *owner->contents.result;
10883         ret.is_owned = false;
10884         return ret;
10885 }
10886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10887         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10888         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
10889         int64_t ret_ref = 0;
10890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10892         return ret_ref;
10893 }
10894
10895 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10896 CHECK(!owner->result_ok);
10897         return DecodeError_clone(&*owner->contents.err);
10898 }
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10900         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10901         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10902         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
10903         int64_t ret_ref = tag_ptr(ret_copy, true);
10904         return ret_ref;
10905 }
10906
10907 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10908         LDKChannelReady ret = *owner->contents.result;
10909         ret.is_owned = false;
10910         return ret;
10911 }
10912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10913         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10914         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
10915         int64_t ret_ref = 0;
10916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10918         return ret_ref;
10919 }
10920
10921 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10922 CHECK(!owner->result_ok);
10923         return DecodeError_clone(&*owner->contents.err);
10924 }
10925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10926         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10927         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10928         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
10929         int64_t ret_ref = tag_ptr(ret_copy, true);
10930         return ret_ref;
10931 }
10932
10933 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10934         LDKInit ret = *owner->contents.result;
10935         ret.is_owned = false;
10936         return ret;
10937 }
10938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10939         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10940         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
10941         int64_t ret_ref = 0;
10942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10944         return ret_ref;
10945 }
10946
10947 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10948 CHECK(!owner->result_ok);
10949         return DecodeError_clone(&*owner->contents.err);
10950 }
10951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10952         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10953         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10954         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
10955         int64_t ret_ref = tag_ptr(ret_copy, true);
10956         return ret_ref;
10957 }
10958
10959 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10960         LDKOpenChannel ret = *owner->contents.result;
10961         ret.is_owned = false;
10962         return ret;
10963 }
10964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10965         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10966         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
10967         int64_t ret_ref = 0;
10968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10969         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10970         return ret_ref;
10971 }
10972
10973 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10974 CHECK(!owner->result_ok);
10975         return DecodeError_clone(&*owner->contents.err);
10976 }
10977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10978         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10979         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10980         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
10981         int64_t ret_ref = tag_ptr(ret_copy, true);
10982         return ret_ref;
10983 }
10984
10985 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
10986         LDKRevokeAndACK ret = *owner->contents.result;
10987         ret.is_owned = false;
10988         return ret;
10989 }
10990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10991         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
10992         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
10993         int64_t ret_ref = 0;
10994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10996         return ret_ref;
10997 }
10998
10999 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
11000 CHECK(!owner->result_ok);
11001         return DecodeError_clone(&*owner->contents.err);
11002 }
11003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11004         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
11005         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11006         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
11007         int64_t ret_ref = tag_ptr(ret_copy, true);
11008         return ret_ref;
11009 }
11010
11011 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
11012         LDKShutdown ret = *owner->contents.result;
11013         ret.is_owned = false;
11014         return ret;
11015 }
11016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11017         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
11018         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
11019         int64_t ret_ref = 0;
11020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11022         return ret_ref;
11023 }
11024
11025 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
11026 CHECK(!owner->result_ok);
11027         return DecodeError_clone(&*owner->contents.err);
11028 }
11029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11030         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
11031         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11032         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
11033         int64_t ret_ref = tag_ptr(ret_copy, true);
11034         return ret_ref;
11035 }
11036
11037 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
11038         LDKUpdateFailHTLC ret = *owner->contents.result;
11039         ret.is_owned = false;
11040         return ret;
11041 }
11042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11043         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
11044         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
11045         int64_t ret_ref = 0;
11046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11048         return ret_ref;
11049 }
11050
11051 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
11052 CHECK(!owner->result_ok);
11053         return DecodeError_clone(&*owner->contents.err);
11054 }
11055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11056         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
11057         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11058         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
11059         int64_t ret_ref = tag_ptr(ret_copy, true);
11060         return ret_ref;
11061 }
11062
11063 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
11064         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
11065         ret.is_owned = false;
11066         return ret;
11067 }
11068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11069         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
11070         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
11071         int64_t ret_ref = 0;
11072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11074         return ret_ref;
11075 }
11076
11077 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
11078 CHECK(!owner->result_ok);
11079         return DecodeError_clone(&*owner->contents.err);
11080 }
11081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11082         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
11083         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11084         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
11085         int64_t ret_ref = tag_ptr(ret_copy, true);
11086         return ret_ref;
11087 }
11088
11089 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
11090         LDKUpdateFee ret = *owner->contents.result;
11091         ret.is_owned = false;
11092         return ret;
11093 }
11094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11095         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
11096         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
11097         int64_t ret_ref = 0;
11098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11100         return ret_ref;
11101 }
11102
11103 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
11104 CHECK(!owner->result_ok);
11105         return DecodeError_clone(&*owner->contents.err);
11106 }
11107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11108         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
11109         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11110         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
11111         int64_t ret_ref = tag_ptr(ret_copy, true);
11112         return ret_ref;
11113 }
11114
11115 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
11116         LDKUpdateFulfillHTLC ret = *owner->contents.result;
11117         ret.is_owned = false;
11118         return ret;
11119 }
11120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11121         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
11122         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
11123         int64_t ret_ref = 0;
11124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11126         return ret_ref;
11127 }
11128
11129 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
11130 CHECK(!owner->result_ok);
11131         return DecodeError_clone(&*owner->contents.err);
11132 }
11133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11134         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
11135         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11136         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
11137         int64_t ret_ref = tag_ptr(ret_copy, true);
11138         return ret_ref;
11139 }
11140
11141 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
11142         LDKUpdateAddHTLC ret = *owner->contents.result;
11143         ret.is_owned = false;
11144         return ret;
11145 }
11146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11147         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
11148         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
11149         int64_t ret_ref = 0;
11150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11152         return ret_ref;
11153 }
11154
11155 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
11156 CHECK(!owner->result_ok);
11157         return DecodeError_clone(&*owner->contents.err);
11158 }
11159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11160         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
11161         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11162         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
11163         int64_t ret_ref = tag_ptr(ret_copy, true);
11164         return ret_ref;
11165 }
11166
11167 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
11168         LDKOnionMessage ret = *owner->contents.result;
11169         ret.is_owned = false;
11170         return ret;
11171 }
11172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11173         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
11174         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
11175         int64_t ret_ref = 0;
11176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11178         return ret_ref;
11179 }
11180
11181 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
11182 CHECK(!owner->result_ok);
11183         return DecodeError_clone(&*owner->contents.err);
11184 }
11185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11186         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
11187         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11188         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
11189         int64_t ret_ref = tag_ptr(ret_copy, true);
11190         return ret_ref;
11191 }
11192
11193 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11194         LDKPing ret = *owner->contents.result;
11195         ret.is_owned = false;
11196         return ret;
11197 }
11198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11199         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11200         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
11201         int64_t ret_ref = 0;
11202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11204         return ret_ref;
11205 }
11206
11207 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11208 CHECK(!owner->result_ok);
11209         return DecodeError_clone(&*owner->contents.err);
11210 }
11211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11212         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11213         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11214         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
11215         int64_t ret_ref = tag_ptr(ret_copy, true);
11216         return ret_ref;
11217 }
11218
11219 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11220         LDKPong ret = *owner->contents.result;
11221         ret.is_owned = false;
11222         return ret;
11223 }
11224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11225         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11226         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
11227         int64_t ret_ref = 0;
11228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11230         return ret_ref;
11231 }
11232
11233 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11234 CHECK(!owner->result_ok);
11235         return DecodeError_clone(&*owner->contents.err);
11236 }
11237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11238         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11239         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11240         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
11241         int64_t ret_ref = tag_ptr(ret_copy, true);
11242         return ret_ref;
11243 }
11244
11245 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11246         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
11247         ret.is_owned = false;
11248         return ret;
11249 }
11250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11251         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11252         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11253         int64_t ret_ref = 0;
11254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11256         return ret_ref;
11257 }
11258
11259 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11260 CHECK(!owner->result_ok);
11261         return DecodeError_clone(&*owner->contents.err);
11262 }
11263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11264         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11265         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11266         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11267         int64_t ret_ref = tag_ptr(ret_copy, true);
11268         return ret_ref;
11269 }
11270
11271 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11272         LDKChannelAnnouncement ret = *owner->contents.result;
11273         ret.is_owned = false;
11274         return ret;
11275 }
11276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11277         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11278         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11279         int64_t ret_ref = 0;
11280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11282         return ret_ref;
11283 }
11284
11285 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11286 CHECK(!owner->result_ok);
11287         return DecodeError_clone(&*owner->contents.err);
11288 }
11289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11290         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11291         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11292         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11293         int64_t ret_ref = tag_ptr(ret_copy, true);
11294         return ret_ref;
11295 }
11296
11297 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11298         LDKUnsignedChannelUpdate ret = *owner->contents.result;
11299         ret.is_owned = false;
11300         return ret;
11301 }
11302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11303         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11304         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11305         int64_t ret_ref = 0;
11306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11308         return ret_ref;
11309 }
11310
11311 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11312 CHECK(!owner->result_ok);
11313         return DecodeError_clone(&*owner->contents.err);
11314 }
11315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11316         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11317         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11318         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
11319         int64_t ret_ref = tag_ptr(ret_copy, true);
11320         return ret_ref;
11321 }
11322
11323 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11324         LDKChannelUpdate ret = *owner->contents.result;
11325         ret.is_owned = false;
11326         return ret;
11327 }
11328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11329         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11330         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11331         int64_t ret_ref = 0;
11332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11334         return ret_ref;
11335 }
11336
11337 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11338 CHECK(!owner->result_ok);
11339         return DecodeError_clone(&*owner->contents.err);
11340 }
11341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11342         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11343         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11344         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
11345         int64_t ret_ref = tag_ptr(ret_copy, true);
11346         return ret_ref;
11347 }
11348
11349 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11350         LDKErrorMessage ret = *owner->contents.result;
11351         ret.is_owned = false;
11352         return ret;
11353 }
11354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11355         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11356         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
11357         int64_t ret_ref = 0;
11358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11360         return ret_ref;
11361 }
11362
11363 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11364 CHECK(!owner->result_ok);
11365         return DecodeError_clone(&*owner->contents.err);
11366 }
11367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11368         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11369         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11370         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
11371         int64_t ret_ref = tag_ptr(ret_copy, true);
11372         return ret_ref;
11373 }
11374
11375 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11376         LDKWarningMessage ret = *owner->contents.result;
11377         ret.is_owned = false;
11378         return ret;
11379 }
11380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11381         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11382         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
11383         int64_t ret_ref = 0;
11384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11386         return ret_ref;
11387 }
11388
11389 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11390 CHECK(!owner->result_ok);
11391         return DecodeError_clone(&*owner->contents.err);
11392 }
11393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11394         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11395         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11396         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
11397         int64_t ret_ref = tag_ptr(ret_copy, true);
11398         return ret_ref;
11399 }
11400
11401 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11402         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
11403         ret.is_owned = false;
11404         return ret;
11405 }
11406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11407         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11408         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11409         int64_t ret_ref = 0;
11410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11412         return ret_ref;
11413 }
11414
11415 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11416 CHECK(!owner->result_ok);
11417         return DecodeError_clone(&*owner->contents.err);
11418 }
11419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11421         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11422         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11423         int64_t ret_ref = tag_ptr(ret_copy, true);
11424         return ret_ref;
11425 }
11426
11427 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11428         LDKNodeAnnouncement ret = *owner->contents.result;
11429         ret.is_owned = false;
11430         return ret;
11431 }
11432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11433         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11434         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11435         int64_t ret_ref = 0;
11436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11438         return ret_ref;
11439 }
11440
11441 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11442 CHECK(!owner->result_ok);
11443         return DecodeError_clone(&*owner->contents.err);
11444 }
11445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11446         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11447         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11448         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11449         int64_t ret_ref = tag_ptr(ret_copy, true);
11450         return ret_ref;
11451 }
11452
11453 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11454         LDKQueryShortChannelIds ret = *owner->contents.result;
11455         ret.is_owned = false;
11456         return ret;
11457 }
11458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11459         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11460         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
11461         int64_t ret_ref = 0;
11462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11464         return ret_ref;
11465 }
11466
11467 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11468 CHECK(!owner->result_ok);
11469         return DecodeError_clone(&*owner->contents.err);
11470 }
11471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11472         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11473         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11474         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
11475         int64_t ret_ref = tag_ptr(ret_copy, true);
11476         return ret_ref;
11477 }
11478
11479 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11480         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
11481         ret.is_owned = false;
11482         return ret;
11483 }
11484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11485         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11486         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
11487         int64_t ret_ref = 0;
11488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11490         return ret_ref;
11491 }
11492
11493 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11494 CHECK(!owner->result_ok);
11495         return DecodeError_clone(&*owner->contents.err);
11496 }
11497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11498         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11499         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11500         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
11501         int64_t ret_ref = tag_ptr(ret_copy, true);
11502         return ret_ref;
11503 }
11504
11505 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11506         LDKQueryChannelRange ret = *owner->contents.result;
11507         ret.is_owned = false;
11508         return ret;
11509 }
11510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11511         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11512         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
11513         int64_t ret_ref = 0;
11514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11516         return ret_ref;
11517 }
11518
11519 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11520 CHECK(!owner->result_ok);
11521         return DecodeError_clone(&*owner->contents.err);
11522 }
11523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11524         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11525         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11526         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
11527         int64_t ret_ref = tag_ptr(ret_copy, true);
11528         return ret_ref;
11529 }
11530
11531 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11532         LDKReplyChannelRange ret = *owner->contents.result;
11533         ret.is_owned = false;
11534         return ret;
11535 }
11536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11537         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11538         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
11539         int64_t ret_ref = 0;
11540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11541         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11542         return ret_ref;
11543 }
11544
11545 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11546 CHECK(!owner->result_ok);
11547         return DecodeError_clone(&*owner->contents.err);
11548 }
11549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11550         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11551         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11552         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
11553         int64_t ret_ref = tag_ptr(ret_copy, true);
11554         return ret_ref;
11555 }
11556
11557 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11558         LDKGossipTimestampFilter ret = *owner->contents.result;
11559         ret.is_owned = false;
11560         return ret;
11561 }
11562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11563         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11564         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
11565         int64_t ret_ref = 0;
11566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11568         return ret_ref;
11569 }
11570
11571 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11572 CHECK(!owner->result_ok);
11573         return DecodeError_clone(&*owner->contents.err);
11574 }
11575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11576         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11577         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11578         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
11579         int64_t ret_ref = tag_ptr(ret_copy, true);
11580         return ret_ref;
11581 }
11582
11583 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
11584         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
11585         for (size_t i = 0; i < ret.datalen; i++) {
11586                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
11587         }
11588         return ret;
11589 }
11590 static jclass LDKSignOrCreationError_SignError_class = NULL;
11591 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
11592 static jclass LDKSignOrCreationError_CreationError_class = NULL;
11593 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
11594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
11595         LDKSignOrCreationError_SignError_class =
11596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
11597         CHECK(LDKSignOrCreationError_SignError_class != NULL);
11598         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
11599         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
11600         LDKSignOrCreationError_CreationError_class =
11601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
11602         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
11603         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
11604         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
11605 }
11606 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11607         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
11608         switch(obj->tag) {
11609                 case LDKSignOrCreationError_SignError: {
11610                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
11611                 }
11612                 case LDKSignOrCreationError_CreationError: {
11613                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
11614                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
11615                 }
11616                 default: abort();
11617         }
11618 }
11619 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11620         LDKInvoice ret = *owner->contents.result;
11621         ret.is_owned = false;
11622         return ret;
11623 }
11624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11625         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11626         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
11627         int64_t ret_ref = 0;
11628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11630         return ret_ref;
11631 }
11632
11633 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11634 CHECK(!owner->result_ok);
11635         return SignOrCreationError_clone(&*owner->contents.err);
11636 }
11637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11638         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11639         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
11640         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
11641         int64_t ret_ref = tag_ptr(ret_copy, true);
11642         return ret_ref;
11643 }
11644
11645 static inline LDKCVec_FutureZ CVec_FutureZ_clone(const LDKCVec_FutureZ *orig) {
11646         LDKCVec_FutureZ ret = { .data = MALLOC(sizeof(LDKFuture) * orig->datalen, "LDKCVec_FutureZ clone bytes"), .datalen = orig->datalen };
11647         for (size_t i = 0; i < ret.datalen; i++) {
11648                 ret.data[i] = Future_clone(&orig->data[i]);
11649         }
11650         return ret;
11651 }
11652 typedef struct LDKFilter_JCalls {
11653         atomic_size_t refcnt;
11654         JavaVM *vm;
11655         jweak o;
11656         jmethodID register_tx_meth;
11657         jmethodID register_output_meth;
11658 } LDKFilter_JCalls;
11659 static void LDKFilter_JCalls_free(void* this_arg) {
11660         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11661         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11662                 JNIEnv *env;
11663                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11664                 if (get_jenv_res == JNI_EDETACHED) {
11665                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11666                 } else {
11667                         DO_ASSERT(get_jenv_res == JNI_OK);
11668                 }
11669                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11670                 if (get_jenv_res == JNI_EDETACHED) {
11671                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11672                 }
11673                 FREE(j_calls);
11674         }
11675 }
11676 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
11677         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11678         JNIEnv *env;
11679         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11680         if (get_jenv_res == JNI_EDETACHED) {
11681                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11682         } else {
11683                 DO_ASSERT(get_jenv_res == JNI_OK);
11684         }
11685         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11686         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11687         LDKu8slice script_pubkey_var = script_pubkey;
11688         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
11689         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
11690         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11691         CHECK(obj != NULL);
11692         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
11693         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11694                 (*env)->ExceptionDescribe(env);
11695                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
11696         }
11697         if (get_jenv_res == JNI_EDETACHED) {
11698                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11699         }
11700 }
11701 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
11702         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11703         JNIEnv *env;
11704         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11705         if (get_jenv_res == JNI_EDETACHED) {
11706                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11707         } else {
11708                 DO_ASSERT(get_jenv_res == JNI_OK);
11709         }
11710         LDKWatchedOutput output_var = output;
11711         int64_t output_ref = 0;
11712         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
11713         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
11714         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11715         CHECK(obj != NULL);
11716         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
11717         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11718                 (*env)->ExceptionDescribe(env);
11719                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
11720         }
11721         if (get_jenv_res == JNI_EDETACHED) {
11722                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11723         }
11724 }
11725 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
11726         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
11727         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11728 }
11729 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
11730         jclass c = (*env)->GetObjectClass(env, o);
11731         CHECK(c != NULL);
11732         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
11733         atomic_init(&calls->refcnt, 1);
11734         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11735         calls->o = (*env)->NewWeakGlobalRef(env, o);
11736         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
11737         CHECK(calls->register_tx_meth != NULL);
11738         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
11739         CHECK(calls->register_output_meth != NULL);
11740
11741         LDKFilter ret = {
11742                 .this_arg = (void*) calls,
11743                 .register_tx = register_tx_LDKFilter_jcall,
11744                 .register_output = register_output_LDKFilter_jcall,
11745                 .free = LDKFilter_JCalls_free,
11746         };
11747         return ret;
11748 }
11749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
11750         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11751         *res_ptr = LDKFilter_init(env, clz, o);
11752         return tag_ptr(res_ptr, true);
11753 }
11754 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) {
11755         void* this_arg_ptr = untag_ptr(this_arg);
11756         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11757         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11758         uint8_t txid_arr[32];
11759         CHECK((*env)->GetArrayLength(env, txid) == 32);
11760         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11761         uint8_t (*txid_ref)[32] = &txid_arr;
11762         LDKu8slice script_pubkey_ref;
11763         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11764         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
11765         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
11766         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
11767 }
11768
11769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
11770         void* this_arg_ptr = untag_ptr(this_arg);
11771         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11772         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11773         LDKWatchedOutput output_conv;
11774         output_conv.inner = untag_ptr(output);
11775         output_conv.is_owned = ptr_is_owned(output);
11776         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
11777         output_conv = WatchedOutput_clone(&output_conv);
11778         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
11779 }
11780
11781 static jclass LDKCOption_FilterZ_Some_class = NULL;
11782 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
11783 static jclass LDKCOption_FilterZ_None_class = NULL;
11784 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
11785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
11786         LDKCOption_FilterZ_Some_class =
11787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
11788         CHECK(LDKCOption_FilterZ_Some_class != NULL);
11789         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
11790         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
11791         LDKCOption_FilterZ_None_class =
11792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
11793         CHECK(LDKCOption_FilterZ_None_class != NULL);
11794         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
11795         CHECK(LDKCOption_FilterZ_None_meth != NULL);
11796 }
11797 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11798         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11799         switch(obj->tag) {
11800                 case LDKCOption_FilterZ_Some: {
11801                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
11802                         *some_ret = obj->some;
11803                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
11804                         if ((*some_ret).free == LDKFilter_JCalls_free) {
11805                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11806                                 LDKFilter_JCalls_cloned(&(*some_ret));
11807                         }
11808                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
11809                 }
11810                 case LDKCOption_FilterZ_None: {
11811                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
11812                 }
11813                 default: abort();
11814         }
11815 }
11816 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11817         LDKLockedChannelMonitor ret = *owner->contents.result;
11818         ret.is_owned = false;
11819         return ret;
11820 }
11821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11822         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11823         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
11824         int64_t ret_ref = 0;
11825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11827         return ret_ref;
11828 }
11829
11830 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11831 CHECK(!owner->result_ok);
11832         return *owner->contents.err;
11833 }
11834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11835         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11836         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
11837 }
11838
11839 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
11840         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
11841         for (size_t i = 0; i < ret.datalen; i++) {
11842                 ret.data[i] = OutPoint_clone(&orig->data[i]);
11843         }
11844         return ret;
11845 }
11846 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
11847         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
11848         for (size_t i = 0; i < ret.datalen; i++) {
11849                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
11850         }
11851         return ret;
11852 }
11853 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11854         LDKOutPoint ret = owner->a;
11855         ret.is_owned = false;
11856         return ret;
11857 }
11858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
11859         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11860         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
11861         int64_t ret_ref = 0;
11862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11864         return ret_ref;
11865 }
11866
11867 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11868         return CVec_MonitorUpdateIdZ_clone(&owner->b);
11869 }
11870 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
11871         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11872         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
11873         int64_tArray ret_arr = NULL;
11874         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11875         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11876         for (size_t r = 0; r < ret_var.datalen; r++) {
11877                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
11878                 int64_t ret_conv_17_ref = 0;
11879                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
11880                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
11881                 ret_arr_ptr[r] = ret_conv_17_ref;
11882         }
11883         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11884         FREE(ret_var.data);
11885         return ret_arr;
11886 }
11887
11888 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
11889         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
11890         for (size_t i = 0; i < ret.datalen; i++) {
11891                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
11892         }
11893         return ret;
11894 }
11895 static jclass LDKGraphSyncError_DecodeError_class = NULL;
11896 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
11897 static jclass LDKGraphSyncError_LightningError_class = NULL;
11898 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
11899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
11900         LDKGraphSyncError_DecodeError_class =
11901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
11902         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
11903         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
11904         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
11905         LDKGraphSyncError_LightningError_class =
11906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
11907         CHECK(LDKGraphSyncError_LightningError_class != NULL);
11908         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
11909         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
11910 }
11911 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11912         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
11913         switch(obj->tag) {
11914                 case LDKGraphSyncError_DecodeError: {
11915                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
11916                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
11917                 }
11918                 case LDKGraphSyncError_LightningError: {
11919                         LDKLightningError lightning_error_var = obj->lightning_error;
11920                         int64_t lightning_error_ref = 0;
11921                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
11922                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
11923                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
11924                 }
11925                 default: abort();
11926         }
11927 }
11928 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
11929 CHECK(owner->result_ok);
11930         return *owner->contents.result;
11931 }
11932 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11933         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
11934         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
11935         return ret_conv;
11936 }
11937
11938 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
11939 CHECK(!owner->result_ok);
11940         return GraphSyncError_clone(&*owner->contents.err);
11941 }
11942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11943         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
11944         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
11945         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
11946         int64_t ret_ref = tag_ptr(ret_copy, true);
11947         return ret_ref;
11948 }
11949
11950 typedef struct LDKPersister_JCalls {
11951         atomic_size_t refcnt;
11952         JavaVM *vm;
11953         jweak o;
11954         jmethodID persist_manager_meth;
11955         jmethodID persist_graph_meth;
11956         jmethodID persist_scorer_meth;
11957 } LDKPersister_JCalls;
11958 static void LDKPersister_JCalls_free(void* this_arg) {
11959         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11960         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11961                 JNIEnv *env;
11962                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11963                 if (get_jenv_res == JNI_EDETACHED) {
11964                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11965                 } else {
11966                         DO_ASSERT(get_jenv_res == JNI_OK);
11967                 }
11968                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11969                 if (get_jenv_res == JNI_EDETACHED) {
11970                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11971                 }
11972                 FREE(j_calls);
11973         }
11974 }
11975 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11976         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11977         JNIEnv *env;
11978         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11979         if (get_jenv_res == JNI_EDETACHED) {
11980                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11981         } else {
11982                 DO_ASSERT(get_jenv_res == JNI_OK);
11983         }
11984         LDKChannelManager channel_manager_var = *channel_manager;
11985         int64_t channel_manager_ref = 0;
11986         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11987         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11988         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
11989         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11990         CHECK(obj != NULL);
11991         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11992         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11993                 (*env)->ExceptionDescribe(env);
11994                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11995         }
11996         void* ret_ptr = untag_ptr(ret);
11997         CHECK_ACCESS(ret_ptr);
11998         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11999         FREE(untag_ptr(ret));
12000         if (get_jenv_res == JNI_EDETACHED) {
12001                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12002         }
12003         return ret_conv;
12004 }
12005 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
12006         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12007         JNIEnv *env;
12008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12009         if (get_jenv_res == JNI_EDETACHED) {
12010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12011         } else {
12012                 DO_ASSERT(get_jenv_res == JNI_OK);
12013         }
12014         LDKNetworkGraph network_graph_var = *network_graph;
12015         int64_t network_graph_ref = 0;
12016         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
12017         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
12018         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
12019         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12020         CHECK(obj != NULL);
12021         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
12022         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12023                 (*env)->ExceptionDescribe(env);
12024                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
12025         }
12026         void* ret_ptr = untag_ptr(ret);
12027         CHECK_ACCESS(ret_ptr);
12028         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12029         FREE(untag_ptr(ret));
12030         if (get_jenv_res == JNI_EDETACHED) {
12031                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12032         }
12033         return ret_conv;
12034 }
12035 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
12036         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12037         JNIEnv *env;
12038         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12039         if (get_jenv_res == JNI_EDETACHED) {
12040                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12041         } else {
12042                 DO_ASSERT(get_jenv_res == JNI_OK);
12043         }
12044         // WARNING: This object doesn't live past this scope, needs clone!
12045         int64_t ret_scorer = tag_ptr(scorer, false);
12046         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12047         CHECK(obj != NULL);
12048         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
12049         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12050                 (*env)->ExceptionDescribe(env);
12051                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
12052         }
12053         void* ret_ptr = untag_ptr(ret);
12054         CHECK_ACCESS(ret_ptr);
12055         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12056         FREE(untag_ptr(ret));
12057         if (get_jenv_res == JNI_EDETACHED) {
12058                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12059         }
12060         return ret_conv;
12061 }
12062 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
12063         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
12064         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12065 }
12066 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
12067         jclass c = (*env)->GetObjectClass(env, o);
12068         CHECK(c != NULL);
12069         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
12070         atomic_init(&calls->refcnt, 1);
12071         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12072         calls->o = (*env)->NewWeakGlobalRef(env, o);
12073         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
12074         CHECK(calls->persist_manager_meth != NULL);
12075         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
12076         CHECK(calls->persist_graph_meth != NULL);
12077         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
12078         CHECK(calls->persist_scorer_meth != NULL);
12079
12080         LDKPersister ret = {
12081                 .this_arg = (void*) calls,
12082                 .persist_manager = persist_manager_LDKPersister_jcall,
12083                 .persist_graph = persist_graph_LDKPersister_jcall,
12084                 .persist_scorer = persist_scorer_LDKPersister_jcall,
12085                 .free = LDKPersister_JCalls_free,
12086         };
12087         return ret;
12088 }
12089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
12090         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
12091         *res_ptr = LDKPersister_init(env, clz, o);
12092         return tag_ptr(res_ptr, true);
12093 }
12094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
12095         void* this_arg_ptr = untag_ptr(this_arg);
12096         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12097         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12098         LDKChannelManager channel_manager_conv;
12099         channel_manager_conv.inner = untag_ptr(channel_manager);
12100         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
12101         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12102         channel_manager_conv.is_owned = false;
12103         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12104         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12105         return tag_ptr(ret_conv, true);
12106 }
12107
12108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
12109         void* this_arg_ptr = untag_ptr(this_arg);
12110         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12111         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12112         LDKNetworkGraph network_graph_conv;
12113         network_graph_conv.inner = untag_ptr(network_graph);
12114         network_graph_conv.is_owned = ptr_is_owned(network_graph);
12115         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
12116         network_graph_conv.is_owned = false;
12117         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12118         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
12119         return tag_ptr(ret_conv, true);
12120 }
12121
12122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
12123         void* this_arg_ptr = untag_ptr(this_arg);
12124         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12125         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12126         void* scorer_ptr = untag_ptr(scorer);
12127         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
12128         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
12129         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12130         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
12131         return tag_ptr(ret_conv, true);
12132 }
12133
12134 typedef struct LDKFutureCallback_JCalls {
12135         atomic_size_t refcnt;
12136         JavaVM *vm;
12137         jweak o;
12138         jmethodID call_meth;
12139 } LDKFutureCallback_JCalls;
12140 static void LDKFutureCallback_JCalls_free(void* this_arg) {
12141         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12142         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12143                 JNIEnv *env;
12144                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12145                 if (get_jenv_res == JNI_EDETACHED) {
12146                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12147                 } else {
12148                         DO_ASSERT(get_jenv_res == JNI_OK);
12149                 }
12150                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12151                 if (get_jenv_res == JNI_EDETACHED) {
12152                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12153                 }
12154                 FREE(j_calls);
12155         }
12156 }
12157 void call_LDKFutureCallback_jcall(const void* this_arg) {
12158         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12159         JNIEnv *env;
12160         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12161         if (get_jenv_res == JNI_EDETACHED) {
12162                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12163         } else {
12164                 DO_ASSERT(get_jenv_res == JNI_OK);
12165         }
12166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12167         CHECK(obj != NULL);
12168         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
12169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12170                 (*env)->ExceptionDescribe(env);
12171                 (*env)->FatalError(env, "A call to call in LDKFutureCallback 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 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
12178         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
12179         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12180 }
12181 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
12182         jclass c = (*env)->GetObjectClass(env, o);
12183         CHECK(c != NULL);
12184         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
12185         atomic_init(&calls->refcnt, 1);
12186         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12187         calls->o = (*env)->NewWeakGlobalRef(env, o);
12188         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
12189         CHECK(calls->call_meth != NULL);
12190
12191         LDKFutureCallback ret = {
12192                 .this_arg = (void*) calls,
12193                 .call = call_LDKFutureCallback_jcall,
12194                 .free = LDKFutureCallback_JCalls_free,
12195         };
12196         return ret;
12197 }
12198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
12199         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
12200         *res_ptr = LDKFutureCallback_init(env, clz, o);
12201         return tag_ptr(res_ptr, true);
12202 }
12203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
12204         void* this_arg_ptr = untag_ptr(this_arg);
12205         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12206         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
12207         (this_arg_conv->call)(this_arg_conv->this_arg);
12208 }
12209
12210 typedef struct LDKListen_JCalls {
12211         atomic_size_t refcnt;
12212         JavaVM *vm;
12213         jweak o;
12214         jmethodID filtered_block_connected_meth;
12215         jmethodID block_connected_meth;
12216         jmethodID block_disconnected_meth;
12217 } LDKListen_JCalls;
12218 static void LDKListen_JCalls_free(void* this_arg) {
12219         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12220         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12221                 JNIEnv *env;
12222                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12223                 if (get_jenv_res == JNI_EDETACHED) {
12224                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12225                 } else {
12226                         DO_ASSERT(get_jenv_res == JNI_OK);
12227                 }
12228                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12229                 if (get_jenv_res == JNI_EDETACHED) {
12230                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12231                 }
12232                 FREE(j_calls);
12233         }
12234 }
12235 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12236         LDKListen_JCalls *j_calls = (LDKListen_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 header_arr = (*env)->NewByteArray(env, 80);
12245         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12246         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12247         int64_tArray txdata_arr = NULL;
12248         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12249         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12250         for (size_t c = 0; c < txdata_var.datalen; c++) {
12251                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12252                 *txdata_conv_28_conv = txdata_var.data[c];
12253                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12254         }
12255         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12256         FREE(txdata_var.data);
12257         int32_t height_conv = height;
12258         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12259         CHECK(obj != NULL);
12260         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
12261         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12262                 (*env)->ExceptionDescribe(env);
12263                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
12264         }
12265         if (get_jenv_res == JNI_EDETACHED) {
12266                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12267         }
12268 }
12269 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
12270         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12271         JNIEnv *env;
12272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12273         if (get_jenv_res == JNI_EDETACHED) {
12274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12275         } else {
12276                 DO_ASSERT(get_jenv_res == JNI_OK);
12277         }
12278         LDKu8slice block_var = block;
12279         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
12280         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
12281         int32_t height_conv = height;
12282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12283         CHECK(obj != NULL);
12284         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
12285         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12286                 (*env)->ExceptionDescribe(env);
12287                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
12288         }
12289         if (get_jenv_res == JNI_EDETACHED) {
12290                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12291         }
12292 }
12293 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12294         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12295         JNIEnv *env;
12296         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12297         if (get_jenv_res == JNI_EDETACHED) {
12298                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12299         } else {
12300                 DO_ASSERT(get_jenv_res == JNI_OK);
12301         }
12302         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12303         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12304         int32_t height_conv = height;
12305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12306         CHECK(obj != NULL);
12307         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
12308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12309                 (*env)->ExceptionDescribe(env);
12310                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
12311         }
12312         if (get_jenv_res == JNI_EDETACHED) {
12313                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12314         }
12315 }
12316 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
12317         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
12318         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12319 }
12320 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
12321         jclass c = (*env)->GetObjectClass(env, o);
12322         CHECK(c != NULL);
12323         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
12324         atomic_init(&calls->refcnt, 1);
12325         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12326         calls->o = (*env)->NewWeakGlobalRef(env, o);
12327         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
12328         CHECK(calls->filtered_block_connected_meth != NULL);
12329         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
12330         CHECK(calls->block_connected_meth != NULL);
12331         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
12332         CHECK(calls->block_disconnected_meth != NULL);
12333
12334         LDKListen ret = {
12335                 .this_arg = (void*) calls,
12336                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
12337                 .block_connected = block_connected_LDKListen_jcall,
12338                 .block_disconnected = block_disconnected_LDKListen_jcall,
12339                 .free = LDKListen_JCalls_free,
12340         };
12341         return ret;
12342 }
12343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
12344         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
12345         *res_ptr = LDKListen_init(env, clz, o);
12346         return tag_ptr(res_ptr, true);
12347 }
12348 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) {
12349         void* this_arg_ptr = untag_ptr(this_arg);
12350         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12351         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12352         uint8_t header_arr[80];
12353         CHECK((*env)->GetArrayLength(env, header) == 80);
12354         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12355         uint8_t (*header_ref)[80] = &header_arr;
12356         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12357         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12358         if (txdata_constr.datalen > 0)
12359                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12360         else
12361                 txdata_constr.data = NULL;
12362         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12363         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12364                 int64_t txdata_conv_28 = txdata_vals[c];
12365                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12366                 CHECK_ACCESS(txdata_conv_28_ptr);
12367                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12368                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12369                 txdata_constr.data[c] = txdata_conv_28_conv;
12370         }
12371         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12372         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12373 }
12374
12375 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) {
12376         void* this_arg_ptr = untag_ptr(this_arg);
12377         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12378         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12379         LDKu8slice block_ref;
12380         block_ref.datalen = (*env)->GetArrayLength(env, block);
12381         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
12382         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
12383         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
12384 }
12385
12386 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) {
12387         void* this_arg_ptr = untag_ptr(this_arg);
12388         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12389         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12390         uint8_t header_arr[80];
12391         CHECK((*env)->GetArrayLength(env, header) == 80);
12392         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12393         uint8_t (*header_ref)[80] = &header_arr;
12394         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
12395 }
12396
12397 typedef struct LDKConfirm_JCalls {
12398         atomic_size_t refcnt;
12399         JavaVM *vm;
12400         jweak o;
12401         jmethodID transactions_confirmed_meth;
12402         jmethodID transaction_unconfirmed_meth;
12403         jmethodID best_block_updated_meth;
12404         jmethodID get_relevant_txids_meth;
12405 } LDKConfirm_JCalls;
12406 static void LDKConfirm_JCalls_free(void* this_arg) {
12407         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12408         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12409                 JNIEnv *env;
12410                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12411                 if (get_jenv_res == JNI_EDETACHED) {
12412                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12413                 } else {
12414                         DO_ASSERT(get_jenv_res == JNI_OK);
12415                 }
12416                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12417                 if (get_jenv_res == JNI_EDETACHED) {
12418                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12419                 }
12420                 FREE(j_calls);
12421         }
12422 }
12423 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12424         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12425         JNIEnv *env;
12426         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12427         if (get_jenv_res == JNI_EDETACHED) {
12428                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12429         } else {
12430                 DO_ASSERT(get_jenv_res == JNI_OK);
12431         }
12432         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12433         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12434         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12435         int64_tArray txdata_arr = NULL;
12436         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12437         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12438         for (size_t c = 0; c < txdata_var.datalen; c++) {
12439                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12440                 *txdata_conv_28_conv = txdata_var.data[c];
12441                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12442         }
12443         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12444         FREE(txdata_var.data);
12445         int32_t height_conv = height;
12446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12447         CHECK(obj != NULL);
12448         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
12449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12450                 (*env)->ExceptionDescribe(env);
12451                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
12452         }
12453         if (get_jenv_res == JNI_EDETACHED) {
12454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12455         }
12456 }
12457 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
12458         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12459         JNIEnv *env;
12460         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12461         if (get_jenv_res == JNI_EDETACHED) {
12462                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12463         } else {
12464                 DO_ASSERT(get_jenv_res == JNI_OK);
12465         }
12466         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
12467         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
12468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12469         CHECK(obj != NULL);
12470         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
12471         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12472                 (*env)->ExceptionDescribe(env);
12473                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
12474         }
12475         if (get_jenv_res == JNI_EDETACHED) {
12476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12477         }
12478 }
12479 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12480         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12481         JNIEnv *env;
12482         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12483         if (get_jenv_res == JNI_EDETACHED) {
12484                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12485         } else {
12486                 DO_ASSERT(get_jenv_res == JNI_OK);
12487         }
12488         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12489         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12490         int32_t height_conv = height;
12491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12492         CHECK(obj != NULL);
12493         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
12494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12495                 (*env)->ExceptionDescribe(env);
12496                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
12497         }
12498         if (get_jenv_res == JNI_EDETACHED) {
12499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12500         }
12501 }
12502 LDKCVec_C2Tuple_TxidBlockHashZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
12503         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12504         JNIEnv *env;
12505         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12506         if (get_jenv_res == JNI_EDETACHED) {
12507                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12508         } else {
12509                 DO_ASSERT(get_jenv_res == JNI_OK);
12510         }
12511         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12512         CHECK(obj != NULL);
12513         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
12514         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12515                 (*env)->ExceptionDescribe(env);
12516                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
12517         }
12518         LDKCVec_C2Tuple_TxidBlockHashZZ ret_constr;
12519         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12520         if (ret_constr.datalen > 0)
12521                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
12522         else
12523                 ret_constr.data = NULL;
12524         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12525         for (size_t z = 0; z < ret_constr.datalen; z++) {
12526                 int64_t ret_conv_25 = ret_vals[z];
12527                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
12528                 CHECK_ACCESS(ret_conv_25_ptr);
12529                 LDKC2Tuple_TxidBlockHashZ ret_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(ret_conv_25_ptr);
12530                 FREE(untag_ptr(ret_conv_25));
12531                 ret_constr.data[z] = ret_conv_25_conv;
12532         }
12533         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12534         if (get_jenv_res == JNI_EDETACHED) {
12535                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12536         }
12537         return ret_constr;
12538 }
12539 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
12540         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
12541         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12542 }
12543 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
12544         jclass c = (*env)->GetObjectClass(env, o);
12545         CHECK(c != NULL);
12546         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
12547         atomic_init(&calls->refcnt, 1);
12548         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12549         calls->o = (*env)->NewWeakGlobalRef(env, o);
12550         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
12551         CHECK(calls->transactions_confirmed_meth != NULL);
12552         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
12553         CHECK(calls->transaction_unconfirmed_meth != NULL);
12554         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
12555         CHECK(calls->best_block_updated_meth != NULL);
12556         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[J");
12557         CHECK(calls->get_relevant_txids_meth != NULL);
12558
12559         LDKConfirm ret = {
12560                 .this_arg = (void*) calls,
12561                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
12562                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
12563                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
12564                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
12565                 .free = LDKConfirm_JCalls_free,
12566         };
12567         return ret;
12568 }
12569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
12570         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12571         *res_ptr = LDKConfirm_init(env, clz, o);
12572         return tag_ptr(res_ptr, true);
12573 }
12574 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) {
12575         void* this_arg_ptr = untag_ptr(this_arg);
12576         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12577         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12578         uint8_t header_arr[80];
12579         CHECK((*env)->GetArrayLength(env, header) == 80);
12580         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12581         uint8_t (*header_ref)[80] = &header_arr;
12582         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12583         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12584         if (txdata_constr.datalen > 0)
12585                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12586         else
12587                 txdata_constr.data = NULL;
12588         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12589         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12590                 int64_t txdata_conv_28 = txdata_vals[c];
12591                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12592                 CHECK_ACCESS(txdata_conv_28_ptr);
12593                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12594                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12595                 txdata_constr.data[c] = txdata_conv_28_conv;
12596         }
12597         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12598         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12599 }
12600
12601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
12602         void* this_arg_ptr = untag_ptr(this_arg);
12603         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12604         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12605         uint8_t txid_arr[32];
12606         CHECK((*env)->GetArrayLength(env, txid) == 32);
12607         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
12608         uint8_t (*txid_ref)[32] = &txid_arr;
12609         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
12610 }
12611
12612 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) {
12613         void* this_arg_ptr = untag_ptr(this_arg);
12614         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12615         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12616         uint8_t header_arr[80];
12617         CHECK((*env)->GetArrayLength(env, header) == 80);
12618         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12619         uint8_t (*header_ref)[80] = &header_arr;
12620         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
12621 }
12622
12623 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
12624         void* this_arg_ptr = untag_ptr(this_arg);
12625         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12626         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12627         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
12628         int64_tArray ret_arr = NULL;
12629         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12630         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12631         for (size_t z = 0; z < ret_var.datalen; z++) {
12632                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
12633                 *ret_conv_25_conv = ret_var.data[z];
12634                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
12635         }
12636         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12637         FREE(ret_var.data);
12638         return ret_arr;
12639 }
12640
12641 typedef struct LDKPersist_JCalls {
12642         atomic_size_t refcnt;
12643         JavaVM *vm;
12644         jweak o;
12645         jmethodID persist_new_channel_meth;
12646         jmethodID update_persisted_channel_meth;
12647 } LDKPersist_JCalls;
12648 static void LDKPersist_JCalls_free(void* this_arg) {
12649         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12650         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12651                 JNIEnv *env;
12652                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12653                 if (get_jenv_res == JNI_EDETACHED) {
12654                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12655                 } else {
12656                         DO_ASSERT(get_jenv_res == JNI_OK);
12657                 }
12658                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12659                 if (get_jenv_res == JNI_EDETACHED) {
12660                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12661                 }
12662                 FREE(j_calls);
12663         }
12664 }
12665 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12666         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12667         JNIEnv *env;
12668         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12669         if (get_jenv_res == JNI_EDETACHED) {
12670                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12671         } else {
12672                 DO_ASSERT(get_jenv_res == JNI_OK);
12673         }
12674         LDKOutPoint channel_id_var = channel_id;
12675         int64_t channel_id_ref = 0;
12676         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12677         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12678         LDKChannelMonitor data_var = *data;
12679         int64_t data_ref = 0;
12680         data_var = ChannelMonitor_clone(&data_var);
12681         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12682         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12683         LDKMonitorUpdateId update_id_var = update_id;
12684         int64_t update_id_ref = 0;
12685         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12686         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12687         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12688         CHECK(obj != NULL);
12689         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
12690         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12691                 (*env)->ExceptionDescribe(env);
12692                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
12693         }
12694         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12695         if (get_jenv_res == JNI_EDETACHED) {
12696                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12697         }
12698         return ret_conv;
12699 }
12700 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, LDKChannelMonitorUpdate update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12701         LDKPersist_JCalls *j_calls = (LDKPersist_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         LDKOutPoint channel_id_var = channel_id;
12710         int64_t channel_id_ref = 0;
12711         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12712         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12713         LDKChannelMonitorUpdate update_var = update;
12714         int64_t update_ref = 0;
12715         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12716         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12717         LDKChannelMonitor data_var = *data;
12718         int64_t data_ref = 0;
12719         data_var = ChannelMonitor_clone(&data_var);
12720         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12721         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12722         LDKMonitorUpdateId update_id_var = update_id;
12723         int64_t update_id_ref = 0;
12724         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12725         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12727         CHECK(obj != NULL);
12728         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
12729         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12730                 (*env)->ExceptionDescribe(env);
12731                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
12732         }
12733         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12734         if (get_jenv_res == JNI_EDETACHED) {
12735                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12736         }
12737         return ret_conv;
12738 }
12739 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12740         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12741         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12742 }
12743 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
12744         jclass c = (*env)->GetObjectClass(env, o);
12745         CHECK(c != NULL);
12746         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12747         atomic_init(&calls->refcnt, 1);
12748         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12749         calls->o = (*env)->NewWeakGlobalRef(env, o);
12750         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12751         CHECK(calls->persist_new_channel_meth != NULL);
12752         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12753         CHECK(calls->update_persisted_channel_meth != NULL);
12754
12755         LDKPersist ret = {
12756                 .this_arg = (void*) calls,
12757                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12758                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12759                 .free = LDKPersist_JCalls_free,
12760         };
12761         return ret;
12762 }
12763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
12764         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12765         *res_ptr = LDKPersist_init(env, clz, o);
12766         return tag_ptr(res_ptr, true);
12767 }
12768 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) {
12769         void* this_arg_ptr = untag_ptr(this_arg);
12770         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12771         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12772         LDKOutPoint channel_id_conv;
12773         channel_id_conv.inner = untag_ptr(channel_id);
12774         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12775         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12776         channel_id_conv = OutPoint_clone(&channel_id_conv);
12777         LDKChannelMonitor data_conv;
12778         data_conv.inner = untag_ptr(data);
12779         data_conv.is_owned = ptr_is_owned(data);
12780         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12781         data_conv.is_owned = false;
12782         LDKMonitorUpdateId update_id_conv;
12783         update_id_conv.inner = untag_ptr(update_id);
12784         update_id_conv.is_owned = ptr_is_owned(update_id);
12785         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12786         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12787         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));
12788         return ret_conv;
12789 }
12790
12791 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) {
12792         void* this_arg_ptr = untag_ptr(this_arg);
12793         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12794         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12795         LDKOutPoint channel_id_conv;
12796         channel_id_conv.inner = untag_ptr(channel_id);
12797         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12798         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12799         channel_id_conv = OutPoint_clone(&channel_id_conv);
12800         LDKChannelMonitorUpdate update_conv;
12801         update_conv.inner = untag_ptr(update);
12802         update_conv.is_owned = ptr_is_owned(update);
12803         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12804         update_conv = ChannelMonitorUpdate_clone(&update_conv);
12805         LDKChannelMonitor data_conv;
12806         data_conv.inner = untag_ptr(data);
12807         data_conv.is_owned = ptr_is_owned(data);
12808         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12809         data_conv.is_owned = false;
12810         LDKMonitorUpdateId update_id_conv;
12811         update_id_conv.inner = untag_ptr(update_id);
12812         update_id_conv.is_owned = ptr_is_owned(update_id);
12813         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12814         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12815         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));
12816         return ret_conv;
12817 }
12818
12819 typedef struct LDKEventHandler_JCalls {
12820         atomic_size_t refcnt;
12821         JavaVM *vm;
12822         jweak o;
12823         jmethodID handle_event_meth;
12824 } LDKEventHandler_JCalls;
12825 static void LDKEventHandler_JCalls_free(void* this_arg) {
12826         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12827         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12828                 JNIEnv *env;
12829                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12830                 if (get_jenv_res == JNI_EDETACHED) {
12831                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12832                 } else {
12833                         DO_ASSERT(get_jenv_res == JNI_OK);
12834                 }
12835                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12836                 if (get_jenv_res == JNI_EDETACHED) {
12837                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12838                 }
12839                 FREE(j_calls);
12840         }
12841 }
12842 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
12843         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12844         JNIEnv *env;
12845         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12846         if (get_jenv_res == JNI_EDETACHED) {
12847                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12848         } else {
12849                 DO_ASSERT(get_jenv_res == JNI_OK);
12850         }
12851         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12852         *event_copy = event;
12853         int64_t event_ref = tag_ptr(event_copy, true);
12854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12855         CHECK(obj != NULL);
12856         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
12857         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12858                 (*env)->ExceptionDescribe(env);
12859                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
12860         }
12861         if (get_jenv_res == JNI_EDETACHED) {
12862                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12863         }
12864 }
12865 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
12866         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
12867         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12868 }
12869 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
12870         jclass c = (*env)->GetObjectClass(env, o);
12871         CHECK(c != NULL);
12872         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
12873         atomic_init(&calls->refcnt, 1);
12874         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12875         calls->o = (*env)->NewWeakGlobalRef(env, o);
12876         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
12877         CHECK(calls->handle_event_meth != NULL);
12878
12879         LDKEventHandler ret = {
12880                 .this_arg = (void*) calls,
12881                 .handle_event = handle_event_LDKEventHandler_jcall,
12882                 .free = LDKEventHandler_JCalls_free,
12883         };
12884         return ret;
12885 }
12886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
12887         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12888         *res_ptr = LDKEventHandler_init(env, clz, o);
12889         return tag_ptr(res_ptr, true);
12890 }
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
12892         void* this_arg_ptr = untag_ptr(this_arg);
12893         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12894         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
12895         void* event_ptr = untag_ptr(event);
12896         CHECK_ACCESS(event_ptr);
12897         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
12898         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
12899         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
12900 }
12901
12902 typedef struct LDKEventsProvider_JCalls {
12903         atomic_size_t refcnt;
12904         JavaVM *vm;
12905         jweak o;
12906         jmethodID process_pending_events_meth;
12907 } LDKEventsProvider_JCalls;
12908 static void LDKEventsProvider_JCalls_free(void* this_arg) {
12909         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12910         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12911                 JNIEnv *env;
12912                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12913                 if (get_jenv_res == JNI_EDETACHED) {
12914                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12915                 } else {
12916                         DO_ASSERT(get_jenv_res == JNI_OK);
12917                 }
12918                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12919                 if (get_jenv_res == JNI_EDETACHED) {
12920                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12921                 }
12922                 FREE(j_calls);
12923         }
12924 }
12925 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
12926         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12927         JNIEnv *env;
12928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12929         if (get_jenv_res == JNI_EDETACHED) {
12930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12931         } else {
12932                 DO_ASSERT(get_jenv_res == JNI_OK);
12933         }
12934         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12935         *handler_ret = handler;
12936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12937         CHECK(obj != NULL);
12938         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
12939         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12940                 (*env)->ExceptionDescribe(env);
12941                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
12942         }
12943         if (get_jenv_res == JNI_EDETACHED) {
12944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12945         }
12946 }
12947 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
12948         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
12949         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12950 }
12951 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
12952         jclass c = (*env)->GetObjectClass(env, o);
12953         CHECK(c != NULL);
12954         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
12955         atomic_init(&calls->refcnt, 1);
12956         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12957         calls->o = (*env)->NewWeakGlobalRef(env, o);
12958         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
12959         CHECK(calls->process_pending_events_meth != NULL);
12960
12961         LDKEventsProvider ret = {
12962                 .this_arg = (void*) calls,
12963                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
12964                 .free = LDKEventsProvider_JCalls_free,
12965         };
12966         return ret;
12967 }
12968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
12969         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12970         *res_ptr = LDKEventsProvider_init(env, clz, o);
12971         return tag_ptr(res_ptr, true);
12972 }
12973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
12974         void* this_arg_ptr = untag_ptr(this_arg);
12975         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12976         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
12977         void* handler_ptr = untag_ptr(handler);
12978         CHECK_ACCESS(handler_ptr);
12979         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
12980         if (handler_conv.free == LDKEventHandler_JCalls_free) {
12981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12982                 LDKEventHandler_JCalls_cloned(&handler_conv);
12983         }
12984         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
12985 }
12986
12987 static jclass LDKRetry_Attempts_class = NULL;
12988 static jmethodID LDKRetry_Attempts_meth = NULL;
12989 static jclass LDKRetry_Timeout_class = NULL;
12990 static jmethodID LDKRetry_Timeout_meth = NULL;
12991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
12992         LDKRetry_Attempts_class =
12993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
12994         CHECK(LDKRetry_Attempts_class != NULL);
12995         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
12996         CHECK(LDKRetry_Attempts_meth != NULL);
12997         LDKRetry_Timeout_class =
12998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
12999         CHECK(LDKRetry_Timeout_class != NULL);
13000         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
13001         CHECK(LDKRetry_Timeout_meth != NULL);
13002 }
13003 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13004         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
13005         switch(obj->tag) {
13006                 case LDKRetry_Attempts: {
13007                         int64_t attempts_conv = obj->attempts;
13008                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
13009                 }
13010                 case LDKRetry_Timeout: {
13011                         int64_t timeout_conv = obj->timeout;
13012                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
13013                 }
13014                 default: abort();
13015         }
13016 }
13017 typedef struct LDKMessageSendEventsProvider_JCalls {
13018         atomic_size_t refcnt;
13019         JavaVM *vm;
13020         jweak o;
13021         jmethodID get_and_clear_pending_msg_events_meth;
13022 } LDKMessageSendEventsProvider_JCalls;
13023 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
13024         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
13025         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13026                 JNIEnv *env;
13027                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13028                 if (get_jenv_res == JNI_EDETACHED) {
13029                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13030                 } else {
13031                         DO_ASSERT(get_jenv_res == JNI_OK);
13032                 }
13033                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13034                 if (get_jenv_res == JNI_EDETACHED) {
13035                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13036                 }
13037                 FREE(j_calls);
13038         }
13039 }
13040 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
13041         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
13042         JNIEnv *env;
13043         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13044         if (get_jenv_res == JNI_EDETACHED) {
13045                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13046         } else {
13047                 DO_ASSERT(get_jenv_res == JNI_OK);
13048         }
13049         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13050         CHECK(obj != NULL);
13051         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
13052         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13053                 (*env)->ExceptionDescribe(env);
13054                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
13055         }
13056         LDKCVec_MessageSendEventZ ret_constr;
13057         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13058         if (ret_constr.datalen > 0)
13059                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13060         else
13061                 ret_constr.data = NULL;
13062         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13063         for (size_t s = 0; s < ret_constr.datalen; s++) {
13064                 int64_t ret_conv_18 = ret_vals[s];
13065                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
13066                 CHECK_ACCESS(ret_conv_18_ptr);
13067                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
13068                 FREE(untag_ptr(ret_conv_18));
13069                 ret_constr.data[s] = ret_conv_18_conv;
13070         }
13071         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13072         if (get_jenv_res == JNI_EDETACHED) {
13073                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13074         }
13075         return ret_constr;
13076 }
13077 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
13078         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
13079         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13080 }
13081 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
13082         jclass c = (*env)->GetObjectClass(env, o);
13083         CHECK(c != NULL);
13084         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
13085         atomic_init(&calls->refcnt, 1);
13086         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13087         calls->o = (*env)->NewWeakGlobalRef(env, o);
13088         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
13089         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
13090
13091         LDKMessageSendEventsProvider ret = {
13092                 .this_arg = (void*) calls,
13093                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
13094                 .free = LDKMessageSendEventsProvider_JCalls_free,
13095         };
13096         return ret;
13097 }
13098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
13099         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13100         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
13101         return tag_ptr(res_ptr, true);
13102 }
13103 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
13104         void* this_arg_ptr = untag_ptr(this_arg);
13105         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13106         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
13107         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
13108         int64_tArray ret_arr = NULL;
13109         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13110         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13111         for (size_t s = 0; s < ret_var.datalen; s++) {
13112                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13113                 *ret_conv_18_copy = ret_var.data[s];
13114                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
13115                 ret_arr_ptr[s] = ret_conv_18_ref;
13116         }
13117         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13118         FREE(ret_var.data);
13119         return ret_arr;
13120 }
13121
13122 typedef struct LDKChannelMessageHandler_JCalls {
13123         atomic_size_t refcnt;
13124         JavaVM *vm;
13125         jweak o;
13126         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13127         jmethodID handle_open_channel_meth;
13128         jmethodID handle_accept_channel_meth;
13129         jmethodID handle_funding_created_meth;
13130         jmethodID handle_funding_signed_meth;
13131         jmethodID handle_channel_ready_meth;
13132         jmethodID handle_shutdown_meth;
13133         jmethodID handle_closing_signed_meth;
13134         jmethodID handle_update_add_htlc_meth;
13135         jmethodID handle_update_fulfill_htlc_meth;
13136         jmethodID handle_update_fail_htlc_meth;
13137         jmethodID handle_update_fail_malformed_htlc_meth;
13138         jmethodID handle_commitment_signed_meth;
13139         jmethodID handle_revoke_and_ack_meth;
13140         jmethodID handle_update_fee_meth;
13141         jmethodID handle_announcement_signatures_meth;
13142         jmethodID peer_disconnected_meth;
13143         jmethodID peer_connected_meth;
13144         jmethodID handle_channel_reestablish_meth;
13145         jmethodID handle_channel_update_meth;
13146         jmethodID handle_error_meth;
13147         jmethodID provided_node_features_meth;
13148         jmethodID provided_init_features_meth;
13149 } LDKChannelMessageHandler_JCalls;
13150 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
13151         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13152         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13153                 JNIEnv *env;
13154                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13155                 if (get_jenv_res == JNI_EDETACHED) {
13156                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13157                 } else {
13158                         DO_ASSERT(get_jenv_res == JNI_OK);
13159                 }
13160                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13161                 if (get_jenv_res == JNI_EDETACHED) {
13162                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13163                 }
13164                 FREE(j_calls);
13165         }
13166 }
13167 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannel * msg) {
13168         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13169         JNIEnv *env;
13170         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13171         if (get_jenv_res == JNI_EDETACHED) {
13172                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13173         } else {
13174                 DO_ASSERT(get_jenv_res == JNI_OK);
13175         }
13176         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13177         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13178         LDKOpenChannel msg_var = *msg;
13179         int64_t msg_ref = 0;
13180         msg_var = OpenChannel_clone(&msg_var);
13181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13182         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13183         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13184         CHECK(obj != NULL);
13185         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, msg_ref);
13186         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13187                 (*env)->ExceptionDescribe(env);
13188                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
13189         }
13190         if (get_jenv_res == JNI_EDETACHED) {
13191                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13192         }
13193 }
13194 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannel * msg) {
13195         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13196         JNIEnv *env;
13197         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13198         if (get_jenv_res == JNI_EDETACHED) {
13199                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13200         } else {
13201                 DO_ASSERT(get_jenv_res == JNI_OK);
13202         }
13203         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13204         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13205         LDKAcceptChannel msg_var = *msg;
13206         int64_t msg_ref = 0;
13207         msg_var = AcceptChannel_clone(&msg_var);
13208         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13209         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13210         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13211         CHECK(obj != NULL);
13212         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, msg_ref);
13213         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13214                 (*env)->ExceptionDescribe(env);
13215                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
13216         }
13217         if (get_jenv_res == JNI_EDETACHED) {
13218                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13219         }
13220 }
13221 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
13222         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13223         JNIEnv *env;
13224         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13225         if (get_jenv_res == JNI_EDETACHED) {
13226                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13227         } else {
13228                 DO_ASSERT(get_jenv_res == JNI_OK);
13229         }
13230         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13231         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13232         LDKFundingCreated msg_var = *msg;
13233         int64_t msg_ref = 0;
13234         msg_var = FundingCreated_clone(&msg_var);
13235         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13236         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13237         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13238         CHECK(obj != NULL);
13239         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
13240         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13241                 (*env)->ExceptionDescribe(env);
13242                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
13243         }
13244         if (get_jenv_res == JNI_EDETACHED) {
13245                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13246         }
13247 }
13248 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
13249         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13250         JNIEnv *env;
13251         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13252         if (get_jenv_res == JNI_EDETACHED) {
13253                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13254         } else {
13255                 DO_ASSERT(get_jenv_res == JNI_OK);
13256         }
13257         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13258         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13259         LDKFundingSigned msg_var = *msg;
13260         int64_t msg_ref = 0;
13261         msg_var = FundingSigned_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         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
13267         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13268                 (*env)->ExceptionDescribe(env);
13269                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
13270         }
13271         if (get_jenv_res == JNI_EDETACHED) {
13272                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13273         }
13274 }
13275 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
13276         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13277         JNIEnv *env;
13278         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13279         if (get_jenv_res == JNI_EDETACHED) {
13280                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13281         } else {
13282                 DO_ASSERT(get_jenv_res == JNI_OK);
13283         }
13284         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13285         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13286         LDKChannelReady msg_var = *msg;
13287         int64_t msg_ref = 0;
13288         msg_var = ChannelReady_clone(&msg_var);
13289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13290         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13292         CHECK(obj != NULL);
13293         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
13294         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13295                 (*env)->ExceptionDescribe(env);
13296                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
13297         }
13298         if (get_jenv_res == JNI_EDETACHED) {
13299                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13300         }
13301 }
13302 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
13303         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13304         JNIEnv *env;
13305         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13306         if (get_jenv_res == JNI_EDETACHED) {
13307                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13308         } else {
13309                 DO_ASSERT(get_jenv_res == JNI_OK);
13310         }
13311         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13312         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13313         LDKShutdown msg_var = *msg;
13314         int64_t msg_ref = 0;
13315         msg_var = Shutdown_clone(&msg_var);
13316         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13317         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13319         CHECK(obj != NULL);
13320         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
13321         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13322                 (*env)->ExceptionDescribe(env);
13323                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
13324         }
13325         if (get_jenv_res == JNI_EDETACHED) {
13326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13327         }
13328 }
13329 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
13330         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13331         JNIEnv *env;
13332         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13333         if (get_jenv_res == JNI_EDETACHED) {
13334                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13335         } else {
13336                 DO_ASSERT(get_jenv_res == JNI_OK);
13337         }
13338         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13339         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13340         LDKClosingSigned msg_var = *msg;
13341         int64_t msg_ref = 0;
13342         msg_var = ClosingSigned_clone(&msg_var);
13343         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13344         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13345         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13346         CHECK(obj != NULL);
13347         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
13348         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13349                 (*env)->ExceptionDescribe(env);
13350                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
13351         }
13352         if (get_jenv_res == JNI_EDETACHED) {
13353                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13354         }
13355 }
13356 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
13357         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13358         JNIEnv *env;
13359         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13360         if (get_jenv_res == JNI_EDETACHED) {
13361                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13362         } else {
13363                 DO_ASSERT(get_jenv_res == JNI_OK);
13364         }
13365         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13366         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13367         LDKUpdateAddHTLC msg_var = *msg;
13368         int64_t msg_ref = 0;
13369         msg_var = UpdateAddHTLC_clone(&msg_var);
13370         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13371         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13373         CHECK(obj != NULL);
13374         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
13375         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13376                 (*env)->ExceptionDescribe(env);
13377                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
13378         }
13379         if (get_jenv_res == JNI_EDETACHED) {
13380                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13381         }
13382 }
13383 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
13384         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13385         JNIEnv *env;
13386         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13387         if (get_jenv_res == JNI_EDETACHED) {
13388                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13389         } else {
13390                 DO_ASSERT(get_jenv_res == JNI_OK);
13391         }
13392         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13393         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13394         LDKUpdateFulfillHTLC msg_var = *msg;
13395         int64_t msg_ref = 0;
13396         msg_var = UpdateFulfillHTLC_clone(&msg_var);
13397         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13398         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13400         CHECK(obj != NULL);
13401         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
13402         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13403                 (*env)->ExceptionDescribe(env);
13404                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
13405         }
13406         if (get_jenv_res == JNI_EDETACHED) {
13407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13408         }
13409 }
13410 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
13411         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13412         JNIEnv *env;
13413         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13414         if (get_jenv_res == JNI_EDETACHED) {
13415                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13416         } else {
13417                 DO_ASSERT(get_jenv_res == JNI_OK);
13418         }
13419         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13420         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13421         LDKUpdateFailHTLC msg_var = *msg;
13422         int64_t msg_ref = 0;
13423         msg_var = UpdateFailHTLC_clone(&msg_var);
13424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13425         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13426         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13427         CHECK(obj != NULL);
13428         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
13429         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13430                 (*env)->ExceptionDescribe(env);
13431                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
13432         }
13433         if (get_jenv_res == JNI_EDETACHED) {
13434                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13435         }
13436 }
13437 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
13438         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13439         JNIEnv *env;
13440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13441         if (get_jenv_res == JNI_EDETACHED) {
13442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13443         } else {
13444                 DO_ASSERT(get_jenv_res == JNI_OK);
13445         }
13446         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13447         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13448         LDKUpdateFailMalformedHTLC msg_var = *msg;
13449         int64_t msg_ref = 0;
13450         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
13451         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13452         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13453         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13454         CHECK(obj != NULL);
13455         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
13456         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13457                 (*env)->ExceptionDescribe(env);
13458                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
13459         }
13460         if (get_jenv_res == JNI_EDETACHED) {
13461                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13462         }
13463 }
13464 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
13465         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13466         JNIEnv *env;
13467         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13468         if (get_jenv_res == JNI_EDETACHED) {
13469                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13470         } else {
13471                 DO_ASSERT(get_jenv_res == JNI_OK);
13472         }
13473         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13474         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13475         LDKCommitmentSigned msg_var = *msg;
13476         int64_t msg_ref = 0;
13477         msg_var = CommitmentSigned_clone(&msg_var);
13478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13479         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13480         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13481         CHECK(obj != NULL);
13482         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
13483         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13484                 (*env)->ExceptionDescribe(env);
13485                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
13486         }
13487         if (get_jenv_res == JNI_EDETACHED) {
13488                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13489         }
13490 }
13491 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
13492         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13493         JNIEnv *env;
13494         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13495         if (get_jenv_res == JNI_EDETACHED) {
13496                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13497         } else {
13498                 DO_ASSERT(get_jenv_res == JNI_OK);
13499         }
13500         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13501         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13502         LDKRevokeAndACK msg_var = *msg;
13503         int64_t msg_ref = 0;
13504         msg_var = RevokeAndACK_clone(&msg_var);
13505         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13506         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13507         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13508         CHECK(obj != NULL);
13509         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
13510         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13511                 (*env)->ExceptionDescribe(env);
13512                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
13513         }
13514         if (get_jenv_res == JNI_EDETACHED) {
13515                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13516         }
13517 }
13518 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
13519         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13520         JNIEnv *env;
13521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13522         if (get_jenv_res == JNI_EDETACHED) {
13523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13524         } else {
13525                 DO_ASSERT(get_jenv_res == JNI_OK);
13526         }
13527         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13528         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13529         LDKUpdateFee msg_var = *msg;
13530         int64_t msg_ref = 0;
13531         msg_var = UpdateFee_clone(&msg_var);
13532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13533         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13535         CHECK(obj != NULL);
13536         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
13537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13538                 (*env)->ExceptionDescribe(env);
13539                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
13540         }
13541         if (get_jenv_res == JNI_EDETACHED) {
13542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13543         }
13544 }
13545 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
13546         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13547         JNIEnv *env;
13548         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13549         if (get_jenv_res == JNI_EDETACHED) {
13550                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13551         } else {
13552                 DO_ASSERT(get_jenv_res == JNI_OK);
13553         }
13554         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13555         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13556         LDKAnnouncementSignatures msg_var = *msg;
13557         int64_t msg_ref = 0;
13558         msg_var = AnnouncementSignatures_clone(&msg_var);
13559         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13560         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13562         CHECK(obj != NULL);
13563         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
13564         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13565                 (*env)->ExceptionDescribe(env);
13566                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
13567         }
13568         if (get_jenv_res == JNI_EDETACHED) {
13569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13570         }
13571 }
13572 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13573         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13574         JNIEnv *env;
13575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13576         if (get_jenv_res == JNI_EDETACHED) {
13577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13578         } else {
13579                 DO_ASSERT(get_jenv_res == JNI_OK);
13580         }
13581         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13582         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13584         CHECK(obj != NULL);
13585         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
13586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13587                 (*env)->ExceptionDescribe(env);
13588                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
13589         }
13590         if (get_jenv_res == JNI_EDETACHED) {
13591                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13592         }
13593 }
13594 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg, bool inbound) {
13595         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13596         JNIEnv *env;
13597         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13598         if (get_jenv_res == JNI_EDETACHED) {
13599                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13600         } else {
13601                 DO_ASSERT(get_jenv_res == JNI_OK);
13602         }
13603         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13604         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13605         LDKInit msg_var = *msg;
13606         int64_t msg_ref = 0;
13607         msg_var = Init_clone(&msg_var);
13608         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13609         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13610         jboolean inbound_conv = inbound;
13611         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13612         CHECK(obj != NULL);
13613         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref, inbound_conv);
13614         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13615                 (*env)->ExceptionDescribe(env);
13616                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
13617         }
13618         void* ret_ptr = untag_ptr(ret);
13619         CHECK_ACCESS(ret_ptr);
13620         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13621         FREE(untag_ptr(ret));
13622         if (get_jenv_res == JNI_EDETACHED) {
13623                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13624         }
13625         return ret_conv;
13626 }
13627 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
13628         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13629         JNIEnv *env;
13630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13631         if (get_jenv_res == JNI_EDETACHED) {
13632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13633         } else {
13634                 DO_ASSERT(get_jenv_res == JNI_OK);
13635         }
13636         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13637         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13638         LDKChannelReestablish msg_var = *msg;
13639         int64_t msg_ref = 0;
13640         msg_var = ChannelReestablish_clone(&msg_var);
13641         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13642         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13643         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13644         CHECK(obj != NULL);
13645         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
13646         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13647                 (*env)->ExceptionDescribe(env);
13648                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
13649         }
13650         if (get_jenv_res == JNI_EDETACHED) {
13651                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13652         }
13653 }
13654 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
13655         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13656         JNIEnv *env;
13657         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13658         if (get_jenv_res == JNI_EDETACHED) {
13659                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13660         } else {
13661                 DO_ASSERT(get_jenv_res == JNI_OK);
13662         }
13663         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13664         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13665         LDKChannelUpdate msg_var = *msg;
13666         int64_t msg_ref = 0;
13667         msg_var = ChannelUpdate_clone(&msg_var);
13668         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13669         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13670         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13671         CHECK(obj != NULL);
13672         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
13673         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13674                 (*env)->ExceptionDescribe(env);
13675                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
13676         }
13677         if (get_jenv_res == JNI_EDETACHED) {
13678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13679         }
13680 }
13681 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
13682         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13683         JNIEnv *env;
13684         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13685         if (get_jenv_res == JNI_EDETACHED) {
13686                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13687         } else {
13688                 DO_ASSERT(get_jenv_res == JNI_OK);
13689         }
13690         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13691         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13692         LDKErrorMessage msg_var = *msg;
13693         int64_t msg_ref = 0;
13694         msg_var = ErrorMessage_clone(&msg_var);
13695         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13696         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13698         CHECK(obj != NULL);
13699         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
13700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13701                 (*env)->ExceptionDescribe(env);
13702                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
13703         }
13704         if (get_jenv_res == JNI_EDETACHED) {
13705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13706         }
13707 }
13708 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
13709         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13710         JNIEnv *env;
13711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13712         if (get_jenv_res == JNI_EDETACHED) {
13713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13714         } else {
13715                 DO_ASSERT(get_jenv_res == JNI_OK);
13716         }
13717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13718         CHECK(obj != NULL);
13719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13721                 (*env)->ExceptionDescribe(env);
13722                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
13723         }
13724         LDKNodeFeatures ret_conv;
13725         ret_conv.inner = untag_ptr(ret);
13726         ret_conv.is_owned = ptr_is_owned(ret);
13727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13728         if (get_jenv_res == JNI_EDETACHED) {
13729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13730         }
13731         return ret_conv;
13732 }
13733 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13734         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13735         JNIEnv *env;
13736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13737         if (get_jenv_res == JNI_EDETACHED) {
13738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13739         } else {
13740                 DO_ASSERT(get_jenv_res == JNI_OK);
13741         }
13742         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13743         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13745         CHECK(obj != NULL);
13746         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13747         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13748                 (*env)->ExceptionDescribe(env);
13749                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
13750         }
13751         LDKInitFeatures ret_conv;
13752         ret_conv.inner = untag_ptr(ret);
13753         ret_conv.is_owned = ptr_is_owned(ret);
13754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13755         if (get_jenv_res == JNI_EDETACHED) {
13756                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13757         }
13758         return ret_conv;
13759 }
13760 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
13761         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
13762         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13763         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13764 }
13765 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13766         jclass c = (*env)->GetObjectClass(env, o);
13767         CHECK(c != NULL);
13768         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
13769         atomic_init(&calls->refcnt, 1);
13770         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13771         calls->o = (*env)->NewWeakGlobalRef(env, o);
13772         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJ)V");
13773         CHECK(calls->handle_open_channel_meth != NULL);
13774         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJ)V");
13775         CHECK(calls->handle_accept_channel_meth != NULL);
13776         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
13777         CHECK(calls->handle_funding_created_meth != NULL);
13778         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
13779         CHECK(calls->handle_funding_signed_meth != NULL);
13780         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
13781         CHECK(calls->handle_channel_ready_meth != NULL);
13782         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
13783         CHECK(calls->handle_shutdown_meth != NULL);
13784         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
13785         CHECK(calls->handle_closing_signed_meth != NULL);
13786         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
13787         CHECK(calls->handle_update_add_htlc_meth != NULL);
13788         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
13789         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
13790         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
13791         CHECK(calls->handle_update_fail_htlc_meth != NULL);
13792         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
13793         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
13794         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
13795         CHECK(calls->handle_commitment_signed_meth != NULL);
13796         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
13797         CHECK(calls->handle_revoke_and_ack_meth != NULL);
13798         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
13799         CHECK(calls->handle_update_fee_meth != NULL);
13800         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
13801         CHECK(calls->handle_announcement_signatures_meth != NULL);
13802         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
13803         CHECK(calls->peer_disconnected_meth != NULL);
13804         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
13805         CHECK(calls->peer_connected_meth != NULL);
13806         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
13807         CHECK(calls->handle_channel_reestablish_meth != NULL);
13808         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
13809         CHECK(calls->handle_channel_update_meth != NULL);
13810         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
13811         CHECK(calls->handle_error_meth != NULL);
13812         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13813         CHECK(calls->provided_node_features_meth != NULL);
13814         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13815         CHECK(calls->provided_init_features_meth != NULL);
13816
13817         LDKChannelMessageHandler ret = {
13818                 .this_arg = (void*) calls,
13819                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
13820                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
13821                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
13822                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
13823                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
13824                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
13825                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
13826                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
13827                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
13828                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
13829                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
13830                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
13831                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
13832                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
13833                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
13834                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
13835                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
13836                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
13837                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
13838                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
13839                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
13840                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
13841                 .free = LDKChannelMessageHandler_JCalls_free,
13842                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13843         };
13844         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13845         return ret;
13846 }
13847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13848         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13849         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13850         return tag_ptr(res_ptr, true);
13851 }
13852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13853         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
13854         return tag_ptr(&inp->MessageSendEventsProvider, false);
13855 }
13856 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 msg) {
13857         void* this_arg_ptr = untag_ptr(this_arg);
13858         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13859         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13860         LDKPublicKey their_node_id_ref;
13861         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13862         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13863         LDKOpenChannel msg_conv;
13864         msg_conv.inner = untag_ptr(msg);
13865         msg_conv.is_owned = ptr_is_owned(msg);
13866         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13867         msg_conv.is_owned = false;
13868         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13869 }
13870
13871 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 msg) {
13872         void* this_arg_ptr = untag_ptr(this_arg);
13873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13874         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13875         LDKPublicKey their_node_id_ref;
13876         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13877         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13878         LDKAcceptChannel msg_conv;
13879         msg_conv.inner = untag_ptr(msg);
13880         msg_conv.is_owned = ptr_is_owned(msg);
13881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13882         msg_conv.is_owned = false;
13883         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13884 }
13885
13886 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) {
13887         void* this_arg_ptr = untag_ptr(this_arg);
13888         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13890         LDKPublicKey their_node_id_ref;
13891         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13892         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13893         LDKFundingCreated msg_conv;
13894         msg_conv.inner = untag_ptr(msg);
13895         msg_conv.is_owned = ptr_is_owned(msg);
13896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13897         msg_conv.is_owned = false;
13898         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13899 }
13900
13901 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) {
13902         void* this_arg_ptr = untag_ptr(this_arg);
13903         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13904         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13905         LDKPublicKey their_node_id_ref;
13906         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13907         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13908         LDKFundingSigned msg_conv;
13909         msg_conv.inner = untag_ptr(msg);
13910         msg_conv.is_owned = ptr_is_owned(msg);
13911         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13912         msg_conv.is_owned = false;
13913         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13914 }
13915
13916 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) {
13917         void* this_arg_ptr = untag_ptr(this_arg);
13918         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13919         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13920         LDKPublicKey their_node_id_ref;
13921         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13922         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13923         LDKChannelReady msg_conv;
13924         msg_conv.inner = untag_ptr(msg);
13925         msg_conv.is_owned = ptr_is_owned(msg);
13926         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13927         msg_conv.is_owned = false;
13928         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13929 }
13930
13931 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 msg) {
13932         void* this_arg_ptr = untag_ptr(this_arg);
13933         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13934         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13935         LDKPublicKey their_node_id_ref;
13936         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13937         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13938         LDKShutdown msg_conv;
13939         msg_conv.inner = untag_ptr(msg);
13940         msg_conv.is_owned = ptr_is_owned(msg);
13941         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13942         msg_conv.is_owned = false;
13943         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13944 }
13945
13946 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) {
13947         void* this_arg_ptr = untag_ptr(this_arg);
13948         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13949         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13950         LDKPublicKey their_node_id_ref;
13951         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13952         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13953         LDKClosingSigned msg_conv;
13954         msg_conv.inner = untag_ptr(msg);
13955         msg_conv.is_owned = ptr_is_owned(msg);
13956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13957         msg_conv.is_owned = false;
13958         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13959 }
13960
13961 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) {
13962         void* this_arg_ptr = untag_ptr(this_arg);
13963         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13964         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13965         LDKPublicKey their_node_id_ref;
13966         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13967         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13968         LDKUpdateAddHTLC msg_conv;
13969         msg_conv.inner = untag_ptr(msg);
13970         msg_conv.is_owned = ptr_is_owned(msg);
13971         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13972         msg_conv.is_owned = false;
13973         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13974 }
13975
13976 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) {
13977         void* this_arg_ptr = untag_ptr(this_arg);
13978         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13979         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13980         LDKPublicKey their_node_id_ref;
13981         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13982         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13983         LDKUpdateFulfillHTLC msg_conv;
13984         msg_conv.inner = untag_ptr(msg);
13985         msg_conv.is_owned = ptr_is_owned(msg);
13986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13987         msg_conv.is_owned = false;
13988         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13989 }
13990
13991 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) {
13992         void* this_arg_ptr = untag_ptr(this_arg);
13993         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13994         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13995         LDKPublicKey their_node_id_ref;
13996         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13997         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13998         LDKUpdateFailHTLC msg_conv;
13999         msg_conv.inner = untag_ptr(msg);
14000         msg_conv.is_owned = ptr_is_owned(msg);
14001         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14002         msg_conv.is_owned = false;
14003         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14004 }
14005
14006 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) {
14007         void* this_arg_ptr = untag_ptr(this_arg);
14008         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14009         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14010         LDKPublicKey their_node_id_ref;
14011         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14012         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14013         LDKUpdateFailMalformedHTLC msg_conv;
14014         msg_conv.inner = untag_ptr(msg);
14015         msg_conv.is_owned = ptr_is_owned(msg);
14016         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14017         msg_conv.is_owned = false;
14018         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14019 }
14020
14021 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) {
14022         void* this_arg_ptr = untag_ptr(this_arg);
14023         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14024         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14025         LDKPublicKey their_node_id_ref;
14026         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14027         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14028         LDKCommitmentSigned msg_conv;
14029         msg_conv.inner = untag_ptr(msg);
14030         msg_conv.is_owned = ptr_is_owned(msg);
14031         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14032         msg_conv.is_owned = false;
14033         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14034 }
14035
14036 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) {
14037         void* this_arg_ptr = untag_ptr(this_arg);
14038         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14039         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14040         LDKPublicKey their_node_id_ref;
14041         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14042         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14043         LDKRevokeAndACK msg_conv;
14044         msg_conv.inner = untag_ptr(msg);
14045         msg_conv.is_owned = ptr_is_owned(msg);
14046         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14047         msg_conv.is_owned = false;
14048         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14049 }
14050
14051 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) {
14052         void* this_arg_ptr = untag_ptr(this_arg);
14053         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14054         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14055         LDKPublicKey their_node_id_ref;
14056         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14057         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14058         LDKUpdateFee msg_conv;
14059         msg_conv.inner = untag_ptr(msg);
14060         msg_conv.is_owned = ptr_is_owned(msg);
14061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14062         msg_conv.is_owned = false;
14063         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14064 }
14065
14066 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) {
14067         void* this_arg_ptr = untag_ptr(this_arg);
14068         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14069         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14070         LDKPublicKey their_node_id_ref;
14071         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14072         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14073         LDKAnnouncementSignatures msg_conv;
14074         msg_conv.inner = untag_ptr(msg);
14075         msg_conv.is_owned = ptr_is_owned(msg);
14076         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14077         msg_conv.is_owned = false;
14078         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14079 }
14080
14081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
14082         void* this_arg_ptr = untag_ptr(this_arg);
14083         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14084         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14085         LDKPublicKey their_node_id_ref;
14086         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14087         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14088         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
14089 }
14090
14091 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, jboolean inbound) {
14092         void* this_arg_ptr = untag_ptr(this_arg);
14093         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14094         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14095         LDKPublicKey their_node_id_ref;
14096         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14097         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14098         LDKInit msg_conv;
14099         msg_conv.inner = untag_ptr(msg);
14100         msg_conv.is_owned = ptr_is_owned(msg);
14101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14102         msg_conv.is_owned = false;
14103         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14104         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv, inbound);
14105         return tag_ptr(ret_conv, true);
14106 }
14107
14108 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) {
14109         void* this_arg_ptr = untag_ptr(this_arg);
14110         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14111         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14112         LDKPublicKey their_node_id_ref;
14113         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14114         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14115         LDKChannelReestablish msg_conv;
14116         msg_conv.inner = untag_ptr(msg);
14117         msg_conv.is_owned = ptr_is_owned(msg);
14118         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14119         msg_conv.is_owned = false;
14120         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14121 }
14122
14123 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) {
14124         void* this_arg_ptr = untag_ptr(this_arg);
14125         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14126         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14127         LDKPublicKey their_node_id_ref;
14128         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14129         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14130         LDKChannelUpdate msg_conv;
14131         msg_conv.inner = untag_ptr(msg);
14132         msg_conv.is_owned = ptr_is_owned(msg);
14133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14134         msg_conv.is_owned = false;
14135         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14136 }
14137
14138 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) {
14139         void* this_arg_ptr = untag_ptr(this_arg);
14140         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14141         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14142         LDKPublicKey their_node_id_ref;
14143         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14144         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14145         LDKErrorMessage msg_conv;
14146         msg_conv.inner = untag_ptr(msg);
14147         msg_conv.is_owned = ptr_is_owned(msg);
14148         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14149         msg_conv.is_owned = false;
14150         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14151 }
14152
14153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14154         void* this_arg_ptr = untag_ptr(this_arg);
14155         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14156         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14157         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14158         int64_t ret_ref = 0;
14159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14161         return ret_ref;
14162 }
14163
14164 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) {
14165         void* this_arg_ptr = untag_ptr(this_arg);
14166         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14167         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14168         LDKPublicKey their_node_id_ref;
14169         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14170         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14171         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14172         int64_t ret_ref = 0;
14173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14175         return ret_ref;
14176 }
14177
14178 typedef struct LDKRoutingMessageHandler_JCalls {
14179         atomic_size_t refcnt;
14180         JavaVM *vm;
14181         jweak o;
14182         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
14183         jmethodID handle_node_announcement_meth;
14184         jmethodID handle_channel_announcement_meth;
14185         jmethodID handle_channel_update_meth;
14186         jmethodID get_next_channel_announcement_meth;
14187         jmethodID get_next_node_announcement_meth;
14188         jmethodID peer_connected_meth;
14189         jmethodID handle_reply_channel_range_meth;
14190         jmethodID handle_reply_short_channel_ids_end_meth;
14191         jmethodID handle_query_channel_range_meth;
14192         jmethodID handle_query_short_channel_ids_meth;
14193         jmethodID processing_queue_high_meth;
14194         jmethodID provided_node_features_meth;
14195         jmethodID provided_init_features_meth;
14196 } LDKRoutingMessageHandler_JCalls;
14197 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
14198         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14199         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14200                 JNIEnv *env;
14201                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14202                 if (get_jenv_res == JNI_EDETACHED) {
14203                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14204                 } else {
14205                         DO_ASSERT(get_jenv_res == JNI_OK);
14206                 }
14207                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14208                 if (get_jenv_res == JNI_EDETACHED) {
14209                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14210                 }
14211                 FREE(j_calls);
14212         }
14213 }
14214 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
14215         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14216         JNIEnv *env;
14217         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14218         if (get_jenv_res == JNI_EDETACHED) {
14219                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14220         } else {
14221                 DO_ASSERT(get_jenv_res == JNI_OK);
14222         }
14223         LDKNodeAnnouncement msg_var = *msg;
14224         int64_t msg_ref = 0;
14225         msg_var = NodeAnnouncement_clone(&msg_var);
14226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14227         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14228         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14229         CHECK(obj != NULL);
14230         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
14231         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14232                 (*env)->ExceptionDescribe(env);
14233                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14234         }
14235         void* ret_ptr = untag_ptr(ret);
14236         CHECK_ACCESS(ret_ptr);
14237         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14238         FREE(untag_ptr(ret));
14239         if (get_jenv_res == JNI_EDETACHED) {
14240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14241         }
14242         return ret_conv;
14243 }
14244 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
14245         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14246         JNIEnv *env;
14247         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14248         if (get_jenv_res == JNI_EDETACHED) {
14249                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14250         } else {
14251                 DO_ASSERT(get_jenv_res == JNI_OK);
14252         }
14253         LDKChannelAnnouncement msg_var = *msg;
14254         int64_t msg_ref = 0;
14255         msg_var = ChannelAnnouncement_clone(&msg_var);
14256         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14257         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14258         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14259         CHECK(obj != NULL);
14260         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
14261         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14262                 (*env)->ExceptionDescribe(env);
14263                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14264         }
14265         void* ret_ptr = untag_ptr(ret);
14266         CHECK_ACCESS(ret_ptr);
14267         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14268         FREE(untag_ptr(ret));
14269         if (get_jenv_res == JNI_EDETACHED) {
14270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14271         }
14272         return ret_conv;
14273 }
14274 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
14275         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14276         JNIEnv *env;
14277         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14278         if (get_jenv_res == JNI_EDETACHED) {
14279                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14280         } else {
14281                 DO_ASSERT(get_jenv_res == JNI_OK);
14282         }
14283         LDKChannelUpdate msg_var = *msg;
14284         int64_t msg_ref = 0;
14285         msg_var = ChannelUpdate_clone(&msg_var);
14286         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14287         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14288         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14289         CHECK(obj != NULL);
14290         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
14291         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14292                 (*env)->ExceptionDescribe(env);
14293                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
14294         }
14295         void* ret_ptr = untag_ptr(ret);
14296         CHECK_ACCESS(ret_ptr);
14297         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14298         FREE(untag_ptr(ret));
14299         if (get_jenv_res == JNI_EDETACHED) {
14300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14301         }
14302         return ret_conv;
14303 }
14304 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
14305         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14306         JNIEnv *env;
14307         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14308         if (get_jenv_res == JNI_EDETACHED) {
14309                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14310         } else {
14311                 DO_ASSERT(get_jenv_res == JNI_OK);
14312         }
14313         int64_t starting_point_conv = starting_point;
14314         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14315         CHECK(obj != NULL);
14316         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
14317         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14318                 (*env)->ExceptionDescribe(env);
14319                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14320         }
14321         void* ret_ptr = untag_ptr(ret);
14322         CHECK_ACCESS(ret_ptr);
14323         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
14324         FREE(untag_ptr(ret));
14325         if (get_jenv_res == JNI_EDETACHED) {
14326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14327         }
14328         return ret_conv;
14329 }
14330 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKNodeId starting_point) {
14331         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14332         JNIEnv *env;
14333         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14334         if (get_jenv_res == JNI_EDETACHED) {
14335                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14336         } else {
14337                 DO_ASSERT(get_jenv_res == JNI_OK);
14338         }
14339         LDKNodeId starting_point_var = starting_point;
14340         int64_t starting_point_ref = 0;
14341         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_var);
14342         starting_point_ref = tag_ptr(starting_point_var.inner, starting_point_var.is_owned);
14343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14344         CHECK(obj != NULL);
14345         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_ref);
14346         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14347                 (*env)->ExceptionDescribe(env);
14348                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14349         }
14350         LDKNodeAnnouncement ret_conv;
14351         ret_conv.inner = untag_ptr(ret);
14352         ret_conv.is_owned = ptr_is_owned(ret);
14353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14354         if (get_jenv_res == JNI_EDETACHED) {
14355                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14356         }
14357         return ret_conv;
14358 }
14359 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14360         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14361         JNIEnv *env;
14362         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14363         if (get_jenv_res == JNI_EDETACHED) {
14364                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14365         } else {
14366                 DO_ASSERT(get_jenv_res == JNI_OK);
14367         }
14368         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14369         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14370         LDKInit init_var = *init;
14371         int64_t init_ref = 0;
14372         init_var = Init_clone(&init_var);
14373         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14374         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14375         jboolean inbound_conv = inbound;
14376         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14377         CHECK(obj != NULL);
14378         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
14379         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14380                 (*env)->ExceptionDescribe(env);
14381                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
14382         }
14383         void* ret_ptr = untag_ptr(ret);
14384         CHECK_ACCESS(ret_ptr);
14385         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14386         FREE(untag_ptr(ret));
14387         if (get_jenv_res == JNI_EDETACHED) {
14388                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14389         }
14390         return ret_conv;
14391 }
14392 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
14393         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14394         JNIEnv *env;
14395         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14396         if (get_jenv_res == JNI_EDETACHED) {
14397                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14398         } else {
14399                 DO_ASSERT(get_jenv_res == JNI_OK);
14400         }
14401         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14402         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14403         LDKReplyChannelRange msg_var = msg;
14404         int64_t msg_ref = 0;
14405         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14406         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14407         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14408         CHECK(obj != NULL);
14409         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
14410         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14411                 (*env)->ExceptionDescribe(env);
14412                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14413         }
14414         void* ret_ptr = untag_ptr(ret);
14415         CHECK_ACCESS(ret_ptr);
14416         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14417         FREE(untag_ptr(ret));
14418         if (get_jenv_res == JNI_EDETACHED) {
14419                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14420         }
14421         return ret_conv;
14422 }
14423 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
14424         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14425         JNIEnv *env;
14426         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14427         if (get_jenv_res == JNI_EDETACHED) {
14428                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14429         } else {
14430                 DO_ASSERT(get_jenv_res == JNI_OK);
14431         }
14432         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14433         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14434         LDKReplyShortChannelIdsEnd msg_var = msg;
14435         int64_t msg_ref = 0;
14436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14437         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14438         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14439         CHECK(obj != NULL);
14440         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
14441         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14442                 (*env)->ExceptionDescribe(env);
14443                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
14444         }
14445         void* ret_ptr = untag_ptr(ret);
14446         CHECK_ACCESS(ret_ptr);
14447         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14448         FREE(untag_ptr(ret));
14449         if (get_jenv_res == JNI_EDETACHED) {
14450                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14451         }
14452         return ret_conv;
14453 }
14454 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
14455         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14456         JNIEnv *env;
14457         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14458         if (get_jenv_res == JNI_EDETACHED) {
14459                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14460         } else {
14461                 DO_ASSERT(get_jenv_res == JNI_OK);
14462         }
14463         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14464         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14465         LDKQueryChannelRange msg_var = msg;
14466         int64_t msg_ref = 0;
14467         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14468         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14470         CHECK(obj != NULL);
14471         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
14472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14473                 (*env)->ExceptionDescribe(env);
14474                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14475         }
14476         void* ret_ptr = untag_ptr(ret);
14477         CHECK_ACCESS(ret_ptr);
14478         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14479         FREE(untag_ptr(ret));
14480         if (get_jenv_res == JNI_EDETACHED) {
14481                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14482         }
14483         return ret_conv;
14484 }
14485 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
14486         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14487         JNIEnv *env;
14488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14489         if (get_jenv_res == JNI_EDETACHED) {
14490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14491         } else {
14492                 DO_ASSERT(get_jenv_res == JNI_OK);
14493         }
14494         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14495         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14496         LDKQueryShortChannelIds msg_var = msg;
14497         int64_t msg_ref = 0;
14498         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14499         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14501         CHECK(obj != NULL);
14502         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
14503         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14504                 (*env)->ExceptionDescribe(env);
14505                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
14506         }
14507         void* ret_ptr = untag_ptr(ret);
14508         CHECK_ACCESS(ret_ptr);
14509         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14510         FREE(untag_ptr(ret));
14511         if (get_jenv_res == JNI_EDETACHED) {
14512                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14513         }
14514         return ret_conv;
14515 }
14516 bool processing_queue_high_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14517         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14518         JNIEnv *env;
14519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14520         if (get_jenv_res == JNI_EDETACHED) {
14521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14522         } else {
14523                 DO_ASSERT(get_jenv_res == JNI_OK);
14524         }
14525         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14526         CHECK(obj != NULL);
14527         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->processing_queue_high_meth);
14528         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14529                 (*env)->ExceptionDescribe(env);
14530                 (*env)->FatalError(env, "A call to processing_queue_high in LDKRoutingMessageHandler from rust threw an exception.");
14531         }
14532         if (get_jenv_res == JNI_EDETACHED) {
14533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14534         }
14535         return ret;
14536 }
14537 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14538         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14539         JNIEnv *env;
14540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14541         if (get_jenv_res == JNI_EDETACHED) {
14542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14543         } else {
14544                 DO_ASSERT(get_jenv_res == JNI_OK);
14545         }
14546         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14547         CHECK(obj != NULL);
14548         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
14549         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14550                 (*env)->ExceptionDescribe(env);
14551                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
14552         }
14553         LDKNodeFeatures ret_conv;
14554         ret_conv.inner = untag_ptr(ret);
14555         ret_conv.is_owned = ptr_is_owned(ret);
14556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14557         if (get_jenv_res == JNI_EDETACHED) {
14558                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14559         }
14560         return ret_conv;
14561 }
14562 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14563         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14564         JNIEnv *env;
14565         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14566         if (get_jenv_res == JNI_EDETACHED) {
14567                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14568         } else {
14569                 DO_ASSERT(get_jenv_res == JNI_OK);
14570         }
14571         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14572         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14573         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14574         CHECK(obj != NULL);
14575         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
14576         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14577                 (*env)->ExceptionDescribe(env);
14578                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
14579         }
14580         LDKInitFeatures ret_conv;
14581         ret_conv.inner = untag_ptr(ret);
14582         ret_conv.is_owned = ptr_is_owned(ret);
14583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14584         if (get_jenv_res == JNI_EDETACHED) {
14585                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14586         }
14587         return ret_conv;
14588 }
14589 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
14590         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
14591         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14592         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
14593 }
14594 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14595         jclass c = (*env)->GetObjectClass(env, o);
14596         CHECK(c != NULL);
14597         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
14598         atomic_init(&calls->refcnt, 1);
14599         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14600         calls->o = (*env)->NewWeakGlobalRef(env, o);
14601         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
14602         CHECK(calls->handle_node_announcement_meth != NULL);
14603         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
14604         CHECK(calls->handle_channel_announcement_meth != NULL);
14605         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
14606         CHECK(calls->handle_channel_update_meth != NULL);
14607         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
14608         CHECK(calls->get_next_channel_announcement_meth != NULL);
14609         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "(J)J");
14610         CHECK(calls->get_next_node_announcement_meth != NULL);
14611         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
14612         CHECK(calls->peer_connected_meth != NULL);
14613         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
14614         CHECK(calls->handle_reply_channel_range_meth != NULL);
14615         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
14616         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
14617         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
14618         CHECK(calls->handle_query_channel_range_meth != NULL);
14619         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
14620         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
14621         calls->processing_queue_high_meth = (*env)->GetMethodID(env, c, "processing_queue_high", "()Z");
14622         CHECK(calls->processing_queue_high_meth != NULL);
14623         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
14624         CHECK(calls->provided_node_features_meth != NULL);
14625         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
14626         CHECK(calls->provided_init_features_meth != NULL);
14627
14628         LDKRoutingMessageHandler ret = {
14629                 .this_arg = (void*) calls,
14630                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
14631                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
14632                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
14633                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
14634                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
14635                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
14636                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
14637                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
14638                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
14639                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
14640                 .processing_queue_high = processing_queue_high_LDKRoutingMessageHandler_jcall,
14641                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
14642                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
14643                 .free = LDKRoutingMessageHandler_JCalls_free,
14644                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
14645         };
14646         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
14647         return ret;
14648 }
14649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14650         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14651         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
14652         return tag_ptr(res_ptr, true);
14653 }
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
14655         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
14656         return tag_ptr(&inp->MessageSendEventsProvider, false);
14657 }
14658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14659         void* this_arg_ptr = untag_ptr(this_arg);
14660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14661         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14662         LDKNodeAnnouncement msg_conv;
14663         msg_conv.inner = untag_ptr(msg);
14664         msg_conv.is_owned = ptr_is_owned(msg);
14665         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14666         msg_conv.is_owned = false;
14667         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14668         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
14669         return tag_ptr(ret_conv, true);
14670 }
14671
14672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14673         void* this_arg_ptr = untag_ptr(this_arg);
14674         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14675         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14676         LDKChannelAnnouncement msg_conv;
14677         msg_conv.inner = untag_ptr(msg);
14678         msg_conv.is_owned = ptr_is_owned(msg);
14679         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14680         msg_conv.is_owned = false;
14681         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14682         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
14683         return tag_ptr(ret_conv, true);
14684 }
14685
14686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14687         void* this_arg_ptr = untag_ptr(this_arg);
14688         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14689         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14690         LDKChannelUpdate msg_conv;
14691         msg_conv.inner = untag_ptr(msg);
14692         msg_conv.is_owned = ptr_is_owned(msg);
14693         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14694         msg_conv.is_owned = false;
14695         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14696         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
14697         return tag_ptr(ret_conv, true);
14698 }
14699
14700 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) {
14701         void* this_arg_ptr = untag_ptr(this_arg);
14702         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14703         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14704         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14705         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
14706         int64_t ret_ref = tag_ptr(ret_copy, true);
14707         return ret_ref;
14708 }
14709
14710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point) {
14711         void* this_arg_ptr = untag_ptr(this_arg);
14712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14713         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14714         LDKNodeId starting_point_conv;
14715         starting_point_conv.inner = untag_ptr(starting_point);
14716         starting_point_conv.is_owned = ptr_is_owned(starting_point);
14717         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_conv);
14718         starting_point_conv = NodeId_clone(&starting_point_conv);
14719         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_conv);
14720         int64_t ret_ref = 0;
14721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14723         return ret_ref;
14724 }
14725
14726 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, jboolean inbound) {
14727         void* this_arg_ptr = untag_ptr(this_arg);
14728         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14729         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14730         LDKPublicKey their_node_id_ref;
14731         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14732         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14733         LDKInit init_conv;
14734         init_conv.inner = untag_ptr(init);
14735         init_conv.is_owned = ptr_is_owned(init);
14736         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14737         init_conv.is_owned = false;
14738         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14739         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14740         return tag_ptr(ret_conv, true);
14741 }
14742
14743 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) {
14744         void* this_arg_ptr = untag_ptr(this_arg);
14745         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14746         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14747         LDKPublicKey their_node_id_ref;
14748         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14749         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14750         LDKReplyChannelRange msg_conv;
14751         msg_conv.inner = untag_ptr(msg);
14752         msg_conv.is_owned = ptr_is_owned(msg);
14753         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14754         msg_conv = ReplyChannelRange_clone(&msg_conv);
14755         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14756         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14757         return tag_ptr(ret_conv, true);
14758 }
14759
14760 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) {
14761         void* this_arg_ptr = untag_ptr(this_arg);
14762         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14763         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14764         LDKPublicKey their_node_id_ref;
14765         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14766         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14767         LDKReplyShortChannelIdsEnd msg_conv;
14768         msg_conv.inner = untag_ptr(msg);
14769         msg_conv.is_owned = ptr_is_owned(msg);
14770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14771         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
14772         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14773         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14774         return tag_ptr(ret_conv, true);
14775 }
14776
14777 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) {
14778         void* this_arg_ptr = untag_ptr(this_arg);
14779         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14780         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14781         LDKPublicKey their_node_id_ref;
14782         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14783         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14784         LDKQueryChannelRange msg_conv;
14785         msg_conv.inner = untag_ptr(msg);
14786         msg_conv.is_owned = ptr_is_owned(msg);
14787         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14788         msg_conv = QueryChannelRange_clone(&msg_conv);
14789         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14790         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14791         return tag_ptr(ret_conv, true);
14792 }
14793
14794 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) {
14795         void* this_arg_ptr = untag_ptr(this_arg);
14796         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14797         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14798         LDKPublicKey their_node_id_ref;
14799         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14800         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14801         LDKQueryShortChannelIds msg_conv;
14802         msg_conv.inner = untag_ptr(msg);
14803         msg_conv.is_owned = ptr_is_owned(msg);
14804         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14805         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14806         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14807         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14808         return tag_ptr(ret_conv, true);
14809 }
14810
14811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1processing_1queue_1high(JNIEnv *env, jclass clz, int64_t this_arg) {
14812         void* this_arg_ptr = untag_ptr(this_arg);
14813         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14814         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14815         jboolean ret_conv = (this_arg_conv->processing_queue_high)(this_arg_conv->this_arg);
14816         return ret_conv;
14817 }
14818
14819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14820         void* this_arg_ptr = untag_ptr(this_arg);
14821         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14822         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14823         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14824         int64_t ret_ref = 0;
14825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14827         return ret_ref;
14828 }
14829
14830 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) {
14831         void* this_arg_ptr = untag_ptr(this_arg);
14832         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14833         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14834         LDKPublicKey their_node_id_ref;
14835         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14836         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14837         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14838         int64_t ret_ref = 0;
14839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14840         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14841         return ret_ref;
14842 }
14843
14844 typedef struct LDKOnionMessageProvider_JCalls {
14845         atomic_size_t refcnt;
14846         JavaVM *vm;
14847         jweak o;
14848         jmethodID next_onion_message_for_peer_meth;
14849 } LDKOnionMessageProvider_JCalls;
14850 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
14851         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
14852         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14853                 JNIEnv *env;
14854                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14855                 if (get_jenv_res == JNI_EDETACHED) {
14856                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14857                 } else {
14858                         DO_ASSERT(get_jenv_res == JNI_OK);
14859                 }
14860                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14861                 if (get_jenv_res == JNI_EDETACHED) {
14862                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14863                 }
14864                 FREE(j_calls);
14865         }
14866 }
14867 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
14868         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
14869         JNIEnv *env;
14870         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14871         if (get_jenv_res == JNI_EDETACHED) {
14872                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14873         } else {
14874                 DO_ASSERT(get_jenv_res == JNI_OK);
14875         }
14876         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
14877         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
14878         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14879         CHECK(obj != NULL);
14880         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
14881         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14882                 (*env)->ExceptionDescribe(env);
14883                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
14884         }
14885         LDKOnionMessage ret_conv;
14886         ret_conv.inner = untag_ptr(ret);
14887         ret_conv.is_owned = ptr_is_owned(ret);
14888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14889         if (get_jenv_res == JNI_EDETACHED) {
14890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14891         }
14892         return ret_conv;
14893 }
14894 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
14895         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
14896         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14897 }
14898 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
14899         jclass c = (*env)->GetObjectClass(env, o);
14900         CHECK(c != NULL);
14901         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
14902         atomic_init(&calls->refcnt, 1);
14903         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14904         calls->o = (*env)->NewWeakGlobalRef(env, o);
14905         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
14906         CHECK(calls->next_onion_message_for_peer_meth != NULL);
14907
14908         LDKOnionMessageProvider ret = {
14909                 .this_arg = (void*) calls,
14910                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
14911                 .free = LDKOnionMessageProvider_JCalls_free,
14912         };
14913         return ret;
14914 }
14915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
14916         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
14917         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
14918         return tag_ptr(res_ptr, true);
14919 }
14920 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) {
14921         void* this_arg_ptr = untag_ptr(this_arg);
14922         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14923         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
14924         LDKPublicKey peer_node_id_ref;
14925         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
14926         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
14927         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
14928         int64_t ret_ref = 0;
14929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14931         return ret_ref;
14932 }
14933
14934 typedef struct LDKOnionMessageHandler_JCalls {
14935         atomic_size_t refcnt;
14936         JavaVM *vm;
14937         jweak o;
14938         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
14939         jmethodID handle_onion_message_meth;
14940         jmethodID peer_connected_meth;
14941         jmethodID peer_disconnected_meth;
14942         jmethodID provided_node_features_meth;
14943         jmethodID provided_init_features_meth;
14944 } LDKOnionMessageHandler_JCalls;
14945 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
14946         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14947         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14948                 JNIEnv *env;
14949                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14950                 if (get_jenv_res == JNI_EDETACHED) {
14951                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14952                 } else {
14953                         DO_ASSERT(get_jenv_res == JNI_OK);
14954                 }
14955                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14956                 if (get_jenv_res == JNI_EDETACHED) {
14957                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14958                 }
14959                 FREE(j_calls);
14960         }
14961 }
14962 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
14963         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14964         JNIEnv *env;
14965         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14966         if (get_jenv_res == JNI_EDETACHED) {
14967                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14968         } else {
14969                 DO_ASSERT(get_jenv_res == JNI_OK);
14970         }
14971         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
14972         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
14973         LDKOnionMessage msg_var = *msg;
14974         int64_t msg_ref = 0;
14975         msg_var = OnionMessage_clone(&msg_var);
14976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14977         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14978         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14979         CHECK(obj != NULL);
14980         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
14981         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14982                 (*env)->ExceptionDescribe(env);
14983                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
14984         }
14985         if (get_jenv_res == JNI_EDETACHED) {
14986                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14987         }
14988 }
14989 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14990         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14991         JNIEnv *env;
14992         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14993         if (get_jenv_res == JNI_EDETACHED) {
14994                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14995         } else {
14996                 DO_ASSERT(get_jenv_res == JNI_OK);
14997         }
14998         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14999         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
15000         LDKInit init_var = *init;
15001         int64_t init_ref = 0;
15002         init_var = Init_clone(&init_var);
15003         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
15004         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
15005         jboolean inbound_conv = inbound;
15006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15007         CHECK(obj != NULL);
15008         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
15009         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15010                 (*env)->ExceptionDescribe(env);
15011                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
15012         }
15013         void* ret_ptr = untag_ptr(ret);
15014         CHECK_ACCESS(ret_ptr);
15015         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
15016         FREE(untag_ptr(ret));
15017         if (get_jenv_res == JNI_EDETACHED) {
15018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15019         }
15020         return ret_conv;
15021 }
15022 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
15023         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15024         JNIEnv *env;
15025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15026         if (get_jenv_res == JNI_EDETACHED) {
15027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15028         } else {
15029                 DO_ASSERT(get_jenv_res == JNI_OK);
15030         }
15031         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
15032         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
15033         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15034         CHECK(obj != NULL);
15035         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
15036         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15037                 (*env)->ExceptionDescribe(env);
15038                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
15039         }
15040         if (get_jenv_res == JNI_EDETACHED) {
15041                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15042         }
15043 }
15044 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
15045         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15046         JNIEnv *env;
15047         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15048         if (get_jenv_res == JNI_EDETACHED) {
15049                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15050         } else {
15051                 DO_ASSERT(get_jenv_res == JNI_OK);
15052         }
15053         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15054         CHECK(obj != NULL);
15055         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
15056         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15057                 (*env)->ExceptionDescribe(env);
15058                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
15059         }
15060         LDKNodeFeatures ret_conv;
15061         ret_conv.inner = untag_ptr(ret);
15062         ret_conv.is_owned = ptr_is_owned(ret);
15063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15064         if (get_jenv_res == JNI_EDETACHED) {
15065                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15066         }
15067         return ret_conv;
15068 }
15069 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
15070         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15071         JNIEnv *env;
15072         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15073         if (get_jenv_res == JNI_EDETACHED) {
15074                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15075         } else {
15076                 DO_ASSERT(get_jenv_res == JNI_OK);
15077         }
15078         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
15079         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
15080         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15081         CHECK(obj != NULL);
15082         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
15083         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15084                 (*env)->ExceptionDescribe(env);
15085                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
15086         }
15087         LDKInitFeatures ret_conv;
15088         ret_conv.inner = untag_ptr(ret);
15089         ret_conv.is_owned = ptr_is_owned(ret);
15090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15091         if (get_jenv_res == JNI_EDETACHED) {
15092                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15093         }
15094         return ret_conv;
15095 }
15096 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
15097         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
15098         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15099         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
15100 }
15101 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
15102         jclass c = (*env)->GetObjectClass(env, o);
15103         CHECK(c != NULL);
15104         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
15105         atomic_init(&calls->refcnt, 1);
15106         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15107         calls->o = (*env)->NewWeakGlobalRef(env, o);
15108         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
15109         CHECK(calls->handle_onion_message_meth != NULL);
15110         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
15111         CHECK(calls->peer_connected_meth != NULL);
15112         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
15113         CHECK(calls->peer_disconnected_meth != NULL);
15114         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
15115         CHECK(calls->provided_node_features_meth != NULL);
15116         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
15117         CHECK(calls->provided_init_features_meth != NULL);
15118
15119         LDKOnionMessageHandler ret = {
15120                 .this_arg = (void*) calls,
15121                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
15122                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
15123                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
15124                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
15125                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
15126                 .free = LDKOnionMessageHandler_JCalls_free,
15127                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
15128         };
15129         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
15130         return ret;
15131 }
15132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
15133         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
15134         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
15135         return tag_ptr(res_ptr, true);
15136 }
15137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
15138         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
15139         return tag_ptr(&inp->OnionMessageProvider, false);
15140 }
15141 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) {
15142         void* this_arg_ptr = untag_ptr(this_arg);
15143         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15144         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15145         LDKPublicKey peer_node_id_ref;
15146         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
15147         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
15148         LDKOnionMessage msg_conv;
15149         msg_conv.inner = untag_ptr(msg);
15150         msg_conv.is_owned = ptr_is_owned(msg);
15151         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
15152         msg_conv.is_owned = false;
15153         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
15154 }
15155
15156 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, jboolean inbound) {
15157         void* this_arg_ptr = untag_ptr(this_arg);
15158         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15159         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15160         LDKPublicKey their_node_id_ref;
15161         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15162         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15163         LDKInit init_conv;
15164         init_conv.inner = untag_ptr(init);
15165         init_conv.is_owned = ptr_is_owned(init);
15166         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
15167         init_conv.is_owned = false;
15168         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15169         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
15170         return tag_ptr(ret_conv, true);
15171 }
15172
15173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
15174         void* this_arg_ptr = untag_ptr(this_arg);
15175         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15176         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15177         LDKPublicKey their_node_id_ref;
15178         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15179         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15180         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
15181 }
15182
15183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
15184         void* this_arg_ptr = untag_ptr(this_arg);
15185         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15186         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15187         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
15188         int64_t ret_ref = 0;
15189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15191         return ret_ref;
15192 }
15193
15194 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) {
15195         void* this_arg_ptr = untag_ptr(this_arg);
15196         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15197         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15198         LDKPublicKey their_node_id_ref;
15199         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15200         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15201         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
15202         int64_t ret_ref = 0;
15203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15205         return ret_ref;
15206 }
15207
15208 typedef struct LDKCustomMessageReader_JCalls {
15209         atomic_size_t refcnt;
15210         JavaVM *vm;
15211         jweak o;
15212         jmethodID read_meth;
15213 } LDKCustomMessageReader_JCalls;
15214 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
15215         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
15216         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15217                 JNIEnv *env;
15218                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15219                 if (get_jenv_res == JNI_EDETACHED) {
15220                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15221                 } else {
15222                         DO_ASSERT(get_jenv_res == JNI_OK);
15223                 }
15224                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15225                 if (get_jenv_res == JNI_EDETACHED) {
15226                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15227                 }
15228                 FREE(j_calls);
15229         }
15230 }
15231 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
15232         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
15233         JNIEnv *env;
15234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15235         if (get_jenv_res == JNI_EDETACHED) {
15236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15237         } else {
15238                 DO_ASSERT(get_jenv_res == JNI_OK);
15239         }
15240         int16_t message_type_conv = message_type;
15241         LDKu8slice buffer_var = buffer;
15242         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
15243         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
15244         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15245         CHECK(obj != NULL);
15246         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
15247         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15248                 (*env)->ExceptionDescribe(env);
15249                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
15250         }
15251         void* ret_ptr = untag_ptr(ret);
15252         CHECK_ACCESS(ret_ptr);
15253         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
15254         FREE(untag_ptr(ret));
15255         if (get_jenv_res == JNI_EDETACHED) {
15256                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15257         }
15258         return ret_conv;
15259 }
15260 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
15261         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
15262         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15263 }
15264 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
15265         jclass c = (*env)->GetObjectClass(env, o);
15266         CHECK(c != NULL);
15267         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
15268         atomic_init(&calls->refcnt, 1);
15269         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15270         calls->o = (*env)->NewWeakGlobalRef(env, o);
15271         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
15272         CHECK(calls->read_meth != NULL);
15273
15274         LDKCustomMessageReader ret = {
15275                 .this_arg = (void*) calls,
15276                 .read = read_LDKCustomMessageReader_jcall,
15277                 .free = LDKCustomMessageReader_JCalls_free,
15278         };
15279         return ret;
15280 }
15281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
15282         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
15283         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
15284         return tag_ptr(res_ptr, true);
15285 }
15286 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) {
15287         void* this_arg_ptr = untag_ptr(this_arg);
15288         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15289         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
15290         LDKu8slice buffer_ref;
15291         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15292         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15293         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15294         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
15295         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15296         return tag_ptr(ret_conv, true);
15297 }
15298
15299 typedef struct LDKCustomMessageHandler_JCalls {
15300         atomic_size_t refcnt;
15301         JavaVM *vm;
15302         jweak o;
15303         LDKCustomMessageReader_JCalls* CustomMessageReader;
15304         jmethodID handle_custom_message_meth;
15305         jmethodID get_and_clear_pending_msg_meth;
15306 } LDKCustomMessageHandler_JCalls;
15307 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
15308         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15309         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15310                 JNIEnv *env;
15311                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15312                 if (get_jenv_res == JNI_EDETACHED) {
15313                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15314                 } else {
15315                         DO_ASSERT(get_jenv_res == JNI_OK);
15316                 }
15317                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15318                 if (get_jenv_res == JNI_EDETACHED) {
15319                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15320                 }
15321                 FREE(j_calls);
15322         }
15323 }
15324 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
15325         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15326         JNIEnv *env;
15327         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15328         if (get_jenv_res == JNI_EDETACHED) {
15329                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15330         } else {
15331                 DO_ASSERT(get_jenv_res == JNI_OK);
15332         }
15333         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
15334         *msg_ret = msg;
15335         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
15336         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
15337         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15338         CHECK(obj != NULL);
15339         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
15340         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15341                 (*env)->ExceptionDescribe(env);
15342                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
15343         }
15344         void* ret_ptr = untag_ptr(ret);
15345         CHECK_ACCESS(ret_ptr);
15346         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
15347         FREE(untag_ptr(ret));
15348         if (get_jenv_res == JNI_EDETACHED) {
15349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15350         }
15351         return ret_conv;
15352 }
15353 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
15354         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15355         JNIEnv *env;
15356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15357         if (get_jenv_res == JNI_EDETACHED) {
15358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15359         } else {
15360                 DO_ASSERT(get_jenv_res == JNI_OK);
15361         }
15362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15363         CHECK(obj != NULL);
15364         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
15365         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15366                 (*env)->ExceptionDescribe(env);
15367                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
15368         }
15369         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
15370         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
15371         if (ret_constr.datalen > 0)
15372                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
15373         else
15374                 ret_constr.data = NULL;
15375         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
15376         for (size_t z = 0; z < ret_constr.datalen; z++) {
15377                 int64_t ret_conv_25 = ret_vals[z];
15378                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
15379                 CHECK_ACCESS(ret_conv_25_ptr);
15380                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
15381                 FREE(untag_ptr(ret_conv_25));
15382                 ret_constr.data[z] = ret_conv_25_conv;
15383         }
15384         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
15385         if (get_jenv_res == JNI_EDETACHED) {
15386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15387         }
15388         return ret_constr;
15389 }
15390 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
15391         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
15392         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15393         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
15394 }
15395 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15396         jclass c = (*env)->GetObjectClass(env, o);
15397         CHECK(c != NULL);
15398         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
15399         atomic_init(&calls->refcnt, 1);
15400         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15401         calls->o = (*env)->NewWeakGlobalRef(env, o);
15402         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
15403         CHECK(calls->handle_custom_message_meth != NULL);
15404         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
15405         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
15406
15407         LDKCustomMessageHandler ret = {
15408                 .this_arg = (void*) calls,
15409                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
15410                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
15411                 .free = LDKCustomMessageHandler_JCalls_free,
15412                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
15413         };
15414         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
15415         return ret;
15416 }
15417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15418         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
15419         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
15420         return tag_ptr(res_ptr, true);
15421 }
15422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
15423         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
15424         return tag_ptr(&inp->CustomMessageReader, false);
15425 }
15426 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) {
15427         void* this_arg_ptr = untag_ptr(this_arg);
15428         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15429         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15430         void* msg_ptr = untag_ptr(msg);
15431         CHECK_ACCESS(msg_ptr);
15432         LDKType msg_conv = *(LDKType*)(msg_ptr);
15433         if (msg_conv.free == LDKType_JCalls_free) {
15434                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15435                 LDKType_JCalls_cloned(&msg_conv);
15436         }
15437         LDKPublicKey sender_node_id_ref;
15438         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
15439         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
15440         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15441         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
15442         return tag_ptr(ret_conv, true);
15443 }
15444
15445 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
15446         void* this_arg_ptr = untag_ptr(this_arg);
15447         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15448         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15449         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
15450         int64_tArray ret_arr = NULL;
15451         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15452         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15453         for (size_t z = 0; z < ret_var.datalen; z++) {
15454                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
15455                 *ret_conv_25_conv = ret_var.data[z];
15456                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
15457         }
15458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15459         FREE(ret_var.data);
15460         return ret_arr;
15461 }
15462
15463 typedef struct LDKCustomOnionMessageHandler_JCalls {
15464         atomic_size_t refcnt;
15465         JavaVM *vm;
15466         jweak o;
15467         jmethodID handle_custom_message_meth;
15468         jmethodID read_custom_message_meth;
15469 } LDKCustomOnionMessageHandler_JCalls;
15470 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
15471         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15472         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15473                 JNIEnv *env;
15474                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15475                 if (get_jenv_res == JNI_EDETACHED) {
15476                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15477                 } else {
15478                         DO_ASSERT(get_jenv_res == JNI_OK);
15479                 }
15480                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15481                 if (get_jenv_res == JNI_EDETACHED) {
15482                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15483                 }
15484                 FREE(j_calls);
15485         }
15486 }
15487 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
15488         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15489         JNIEnv *env;
15490         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15491         if (get_jenv_res == JNI_EDETACHED) {
15492                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15493         } else {
15494                 DO_ASSERT(get_jenv_res == JNI_OK);
15495         }
15496         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15497         *msg_ret = msg;
15498         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15499         CHECK(obj != NULL);
15500         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
15501         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15502                 (*env)->ExceptionDescribe(env);
15503                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15504         }
15505         if (get_jenv_res == JNI_EDETACHED) {
15506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15507         }
15508 }
15509 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
15510         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15511         JNIEnv *env;
15512         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15513         if (get_jenv_res == JNI_EDETACHED) {
15514                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15515         } else {
15516                 DO_ASSERT(get_jenv_res == JNI_OK);
15517         }
15518         int64_t message_type_conv = message_type;
15519         LDKu8slice buffer_var = buffer;
15520         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
15521         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
15522         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15523         CHECK(obj != NULL);
15524         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
15525         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15526                 (*env)->ExceptionDescribe(env);
15527                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15528         }
15529         void* ret_ptr = untag_ptr(ret);
15530         CHECK_ACCESS(ret_ptr);
15531         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
15532         FREE(untag_ptr(ret));
15533         if (get_jenv_res == JNI_EDETACHED) {
15534                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15535         }
15536         return ret_conv;
15537 }
15538 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
15539         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
15540         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15541 }
15542 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
15543         jclass c = (*env)->GetObjectClass(env, o);
15544         CHECK(c != NULL);
15545         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
15546         atomic_init(&calls->refcnt, 1);
15547         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15548         calls->o = (*env)->NewWeakGlobalRef(env, o);
15549         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
15550         CHECK(calls->handle_custom_message_meth != NULL);
15551         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
15552         CHECK(calls->read_custom_message_meth != NULL);
15553
15554         LDKCustomOnionMessageHandler ret = {
15555                 .this_arg = (void*) calls,
15556                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
15557                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
15558                 .free = LDKCustomOnionMessageHandler_JCalls_free,
15559         };
15560         return ret;
15561 }
15562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
15563         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
15564         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
15565         return tag_ptr(res_ptr, true);
15566 }
15567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
15568         void* this_arg_ptr = untag_ptr(this_arg);
15569         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15570         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15571         void* msg_ptr = untag_ptr(msg);
15572         CHECK_ACCESS(msg_ptr);
15573         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
15574         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
15575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15576                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
15577         }
15578         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
15579 }
15580
15581 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) {
15582         void* this_arg_ptr = untag_ptr(this_arg);
15583         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15584         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15585         LDKu8slice buffer_ref;
15586         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15587         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15588         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
15589         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
15590         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15591         return tag_ptr(ret_conv, true);
15592 }
15593
15594 typedef struct LDKSocketDescriptor_JCalls {
15595         atomic_size_t refcnt;
15596         JavaVM *vm;
15597         jweak o;
15598         jmethodID send_data_meth;
15599         jmethodID disconnect_socket_meth;
15600         jmethodID eq_meth;
15601         jmethodID hash_meth;
15602 } LDKSocketDescriptor_JCalls;
15603 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
15604         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15605         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15606                 JNIEnv *env;
15607                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15608                 if (get_jenv_res == JNI_EDETACHED) {
15609                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15610                 } else {
15611                         DO_ASSERT(get_jenv_res == JNI_OK);
15612                 }
15613                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15614                 if (get_jenv_res == JNI_EDETACHED) {
15615                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15616                 }
15617                 FREE(j_calls);
15618         }
15619 }
15620 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
15621         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15622         JNIEnv *env;
15623         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15624         if (get_jenv_res == JNI_EDETACHED) {
15625                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15626         } else {
15627                 DO_ASSERT(get_jenv_res == JNI_OK);
15628         }
15629         LDKu8slice data_var = data;
15630         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
15631         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
15632         jboolean resume_read_conv = resume_read;
15633         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15634         CHECK(obj != NULL);
15635         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
15636         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15637                 (*env)->ExceptionDescribe(env);
15638                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
15639         }
15640         if (get_jenv_res == JNI_EDETACHED) {
15641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15642         }
15643         return ret;
15644 }
15645 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
15646         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15647         JNIEnv *env;
15648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15649         if (get_jenv_res == JNI_EDETACHED) {
15650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15651         } else {
15652                 DO_ASSERT(get_jenv_res == JNI_OK);
15653         }
15654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15655         CHECK(obj != NULL);
15656         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
15657         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15658                 (*env)->ExceptionDescribe(env);
15659                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
15660         }
15661         if (get_jenv_res == JNI_EDETACHED) {
15662                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15663         }
15664 }
15665 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
15666         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15667         JNIEnv *env;
15668         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15669         if (get_jenv_res == JNI_EDETACHED) {
15670                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15671         } else {
15672                 DO_ASSERT(get_jenv_res == JNI_OK);
15673         }
15674         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15675         *other_arg_clone = SocketDescriptor_clone(other_arg);
15676         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15677         CHECK(obj != NULL);
15678         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
15679         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15680                 (*env)->ExceptionDescribe(env);
15681                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
15682         }
15683         if (get_jenv_res == JNI_EDETACHED) {
15684                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15685         }
15686         return ret;
15687 }
15688 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
15689         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15690         JNIEnv *env;
15691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15692         if (get_jenv_res == JNI_EDETACHED) {
15693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15694         } else {
15695                 DO_ASSERT(get_jenv_res == JNI_OK);
15696         }
15697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15698         CHECK(obj != NULL);
15699         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
15700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15701                 (*env)->ExceptionDescribe(env);
15702                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
15703         }
15704         if (get_jenv_res == JNI_EDETACHED) {
15705                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15706         }
15707         return ret;
15708 }
15709 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
15710         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
15711         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15712 }
15713 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
15714         jclass c = (*env)->GetObjectClass(env, o);
15715         CHECK(c != NULL);
15716         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
15717         atomic_init(&calls->refcnt, 1);
15718         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15719         calls->o = (*env)->NewWeakGlobalRef(env, o);
15720         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
15721         CHECK(calls->send_data_meth != NULL);
15722         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
15723         CHECK(calls->disconnect_socket_meth != NULL);
15724         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
15725         CHECK(calls->eq_meth != NULL);
15726         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
15727         CHECK(calls->hash_meth != NULL);
15728
15729         LDKSocketDescriptor ret = {
15730                 .this_arg = (void*) calls,
15731                 .send_data = send_data_LDKSocketDescriptor_jcall,
15732                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
15733                 .eq = eq_LDKSocketDescriptor_jcall,
15734                 .hash = hash_LDKSocketDescriptor_jcall,
15735                 .cloned = LDKSocketDescriptor_JCalls_cloned,
15736                 .free = LDKSocketDescriptor_JCalls_free,
15737         };
15738         return ret;
15739 }
15740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
15741         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15742         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
15743         return tag_ptr(res_ptr, true);
15744 }
15745 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) {
15746         void* this_arg_ptr = untag_ptr(this_arg);
15747         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15748         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15749         LDKu8slice data_ref;
15750         data_ref.datalen = (*env)->GetArrayLength(env, data);
15751         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
15752         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
15753         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
15754         return ret_conv;
15755 }
15756
15757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
15758         void* this_arg_ptr = untag_ptr(this_arg);
15759         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15760         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15761         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
15762 }
15763
15764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15765         void* this_arg_ptr = untag_ptr(this_arg);
15766         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15767         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15768         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
15769         return ret_conv;
15770 }
15771
15772 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
15773 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
15774 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
15775 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
15776 static jclass LDKEffectiveCapacity_Total_class = NULL;
15777 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
15778 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
15779 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
15780 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
15781 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
15782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
15783         LDKEffectiveCapacity_ExactLiquidity_class =
15784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
15785         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
15786         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
15787         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
15788         LDKEffectiveCapacity_MaximumHTLC_class =
15789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
15790         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
15791         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
15792         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
15793         LDKEffectiveCapacity_Total_class =
15794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
15795         CHECK(LDKEffectiveCapacity_Total_class != NULL);
15796         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
15797         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
15798         LDKEffectiveCapacity_Infinite_class =
15799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
15800         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
15801         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
15802         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
15803         LDKEffectiveCapacity_Unknown_class =
15804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
15805         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
15806         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
15807         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
15808 }
15809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15810         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
15811         switch(obj->tag) {
15812                 case LDKEffectiveCapacity_ExactLiquidity: {
15813                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
15814                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
15815                 }
15816                 case LDKEffectiveCapacity_MaximumHTLC: {
15817                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
15818                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
15819                 }
15820                 case LDKEffectiveCapacity_Total: {
15821                         int64_t capacity_msat_conv = obj->total.capacity_msat;
15822                         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
15823                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_conv);
15824                 }
15825                 case LDKEffectiveCapacity_Infinite: {
15826                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
15827                 }
15828                 case LDKEffectiveCapacity_Unknown: {
15829                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
15830                 }
15831                 default: abort();
15832         }
15833 }
15834 static jclass LDKHints_Blinded_class = NULL;
15835 static jmethodID LDKHints_Blinded_meth = NULL;
15836 static jclass LDKHints_Clear_class = NULL;
15837 static jmethodID LDKHints_Clear_meth = NULL;
15838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHints_init (JNIEnv *env, jclass clz) {
15839         LDKHints_Blinded_class =
15840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHints$Blinded"));
15841         CHECK(LDKHints_Blinded_class != NULL);
15842         LDKHints_Blinded_meth = (*env)->GetMethodID(env, LDKHints_Blinded_class, "<init>", "([J)V");
15843         CHECK(LDKHints_Blinded_meth != NULL);
15844         LDKHints_Clear_class =
15845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHints$Clear"));
15846         CHECK(LDKHints_Clear_class != NULL);
15847         LDKHints_Clear_meth = (*env)->GetMethodID(env, LDKHints_Clear_class, "<init>", "([J)V");
15848         CHECK(LDKHints_Clear_meth != NULL);
15849 }
15850 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHints_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15851         LDKHints *obj = (LDKHints*)untag_ptr(ptr);
15852         switch(obj->tag) {
15853                 case LDKHints_Blinded: {
15854                         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_var = obj->blinded;
15855                         int64_tArray blinded_arr = NULL;
15856                         blinded_arr = (*env)->NewLongArray(env, blinded_var.datalen);
15857                         int64_t *blinded_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, blinded_arr, NULL);
15858                         for (size_t l = 0; l < blinded_var.datalen; l++) {
15859                                 LDKC2Tuple_BlindedPayInfoBlindedPathZ* blinded_conv_37_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
15860                                 *blinded_conv_37_conv = blinded_var.data[l];
15861                                 *blinded_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(blinded_conv_37_conv);
15862                                 blinded_arr_ptr[l] = tag_ptr(blinded_conv_37_conv, true);
15863                         }
15864                         (*env)->ReleasePrimitiveArrayCritical(env, blinded_arr, blinded_arr_ptr, 0);
15865                         return (*env)->NewObject(env, LDKHints_Blinded_class, LDKHints_Blinded_meth, blinded_arr);
15866                 }
15867                 case LDKHints_Clear: {
15868                         LDKCVec_RouteHintZ clear_var = obj->clear;
15869                         int64_tArray clear_arr = NULL;
15870                         clear_arr = (*env)->NewLongArray(env, clear_var.datalen);
15871                         int64_t *clear_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, clear_arr, NULL);
15872                         for (size_t l = 0; l < clear_var.datalen; l++) {
15873                                 LDKRouteHint clear_conv_11_var = clear_var.data[l];
15874                                 int64_t clear_conv_11_ref = 0;
15875                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(clear_conv_11_var);
15876                                 clear_conv_11_ref = tag_ptr(clear_conv_11_var.inner, false);
15877                                 clear_arr_ptr[l] = clear_conv_11_ref;
15878                         }
15879                         (*env)->ReleasePrimitiveArrayCritical(env, clear_arr, clear_arr_ptr, 0);
15880                         return (*env)->NewObject(env, LDKHints_Clear_class, LDKHints_Clear_meth, clear_arr);
15881                 }
15882                 default: abort();
15883         }
15884 }
15885 static jclass LDKDestination_Node_class = NULL;
15886 static jmethodID LDKDestination_Node_meth = NULL;
15887 static jclass LDKDestination_BlindedPath_class = NULL;
15888 static jmethodID LDKDestination_BlindedPath_meth = NULL;
15889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
15890         LDKDestination_Node_class =
15891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
15892         CHECK(LDKDestination_Node_class != NULL);
15893         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
15894         CHECK(LDKDestination_Node_meth != NULL);
15895         LDKDestination_BlindedPath_class =
15896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedPath"));
15897         CHECK(LDKDestination_BlindedPath_class != NULL);
15898         LDKDestination_BlindedPath_meth = (*env)->GetMethodID(env, LDKDestination_BlindedPath_class, "<init>", "(J)V");
15899         CHECK(LDKDestination_BlindedPath_meth != NULL);
15900 }
15901 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15902         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
15903         switch(obj->tag) {
15904                 case LDKDestination_Node: {
15905                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
15906                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
15907                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
15908                 }
15909                 case LDKDestination_BlindedPath: {
15910                         LDKBlindedPath blinded_path_var = obj->blinded_path;
15911                         int64_t blinded_path_ref = 0;
15912                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
15913                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
15914                         return (*env)->NewObject(env, LDKDestination_BlindedPath_class, LDKDestination_BlindedPath_meth, blinded_path_ref);
15915                 }
15916                 default: abort();
15917         }
15918 }
15919 static jclass LDKOnionMessageContents_Custom_class = NULL;
15920 static jmethodID LDKOnionMessageContents_Custom_meth = NULL;
15921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKOnionMessageContents_init (JNIEnv *env, jclass clz) {
15922         LDKOnionMessageContents_Custom_class =
15923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKOnionMessageContents$Custom"));
15924         CHECK(LDKOnionMessageContents_Custom_class != NULL);
15925         LDKOnionMessageContents_Custom_meth = (*env)->GetMethodID(env, LDKOnionMessageContents_Custom_class, "<init>", "(J)V");
15926         CHECK(LDKOnionMessageContents_Custom_meth != NULL);
15927 }
15928 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageContents_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15929         LDKOnionMessageContents *obj = (LDKOnionMessageContents*)untag_ptr(ptr);
15930         switch(obj->tag) {
15931                 case LDKOnionMessageContents_Custom: {
15932                         LDKCustomOnionMessageContents* custom_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15933                         *custom_ret = CustomOnionMessageContents_clone(&obj->custom);
15934                         return (*env)->NewObject(env, LDKOnionMessageContents_Custom_class, LDKOnionMessageContents_Custom_meth, tag_ptr(custom_ret, true));
15935                 }
15936                 default: abort();
15937         }
15938 }
15939 static jclass LDKGossipSync_P2P_class = NULL;
15940 static jmethodID LDKGossipSync_P2P_meth = NULL;
15941 static jclass LDKGossipSync_Rapid_class = NULL;
15942 static jmethodID LDKGossipSync_Rapid_meth = NULL;
15943 static jclass LDKGossipSync_None_class = NULL;
15944 static jmethodID LDKGossipSync_None_meth = NULL;
15945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
15946         LDKGossipSync_P2P_class =
15947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
15948         CHECK(LDKGossipSync_P2P_class != NULL);
15949         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
15950         CHECK(LDKGossipSync_P2P_meth != NULL);
15951         LDKGossipSync_Rapid_class =
15952                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
15953         CHECK(LDKGossipSync_Rapid_class != NULL);
15954         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
15955         CHECK(LDKGossipSync_Rapid_meth != NULL);
15956         LDKGossipSync_None_class =
15957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
15958         CHECK(LDKGossipSync_None_class != NULL);
15959         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
15960         CHECK(LDKGossipSync_None_meth != NULL);
15961 }
15962 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15963         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15964         switch(obj->tag) {
15965                 case LDKGossipSync_P2P: {
15966                         LDKP2PGossipSync p2p_var = obj->p2p;
15967                         int64_t p2p_ref = 0;
15968                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15969                         p2p_ref = tag_ptr(p2p_var.inner, false);
15970                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
15971                 }
15972                 case LDKGossipSync_Rapid: {
15973                         LDKRapidGossipSync rapid_var = obj->rapid;
15974                         int64_t rapid_ref = 0;
15975                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15976                         rapid_ref = tag_ptr(rapid_var.inner, false);
15977                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
15978                 }
15979                 case LDKGossipSync_None: {
15980                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
15981                 }
15982                 default: abort();
15983         }
15984 }
15985 static jclass LDKFallback_SegWitProgram_class = NULL;
15986 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
15987 static jclass LDKFallback_PubKeyHash_class = NULL;
15988 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
15989 static jclass LDKFallback_ScriptHash_class = NULL;
15990 static jmethodID LDKFallback_ScriptHash_meth = NULL;
15991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
15992         LDKFallback_SegWitProgram_class =
15993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
15994         CHECK(LDKFallback_SegWitProgram_class != NULL);
15995         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
15996         CHECK(LDKFallback_SegWitProgram_meth != NULL);
15997         LDKFallback_PubKeyHash_class =
15998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
15999         CHECK(LDKFallback_PubKeyHash_class != NULL);
16000         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
16001         CHECK(LDKFallback_PubKeyHash_meth != NULL);
16002         LDKFallback_ScriptHash_class =
16003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
16004         CHECK(LDKFallback_ScriptHash_class != NULL);
16005         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
16006         CHECK(LDKFallback_ScriptHash_meth != NULL);
16007 }
16008 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
16009         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
16010         switch(obj->tag) {
16011                 case LDKFallback_SegWitProgram: {
16012                         uint8_t version_val = obj->seg_wit_program.version._0;
16013                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
16014                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
16015                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
16016                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
16017                 }
16018                 case LDKFallback_PubKeyHash: {
16019                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
16020                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
16021                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
16022                 }
16023                 case LDKFallback_ScriptHash: {
16024                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
16025                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
16026                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
16027                 }
16028                 default: abort();
16029         }
16030 }
16031 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
16032         LDKStr ret_str = _ldk_get_compiled_version();
16033         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16034         Str_free(ret_str);
16035         return ret_conv;
16036 }
16037
16038 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
16039         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
16040         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16041         Str_free(ret_str);
16042         return ret_conv;
16043 }
16044
16045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1le_1bytes(JNIEnv *env, jclass clz, int8_tArray val) {
16046         LDKU128 val_ref;
16047         CHECK((*env)->GetArrayLength(env, val) == 16);
16048         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
16049         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
16050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_le_bytes(val_ref).data);
16051         return ret_arr;
16052 }
16053
16054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1new(JNIEnv *env, jclass clz, int8_tArray le_bytes) {
16055         LDKSixteenBytes le_bytes_ref;
16056         CHECK((*env)->GetArrayLength(env, le_bytes) == 16);
16057         (*env)->GetByteArrayRegion(env, le_bytes, 0, 16, le_bytes_ref.data);
16058         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
16059         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_new(le_bytes_ref).le_bytes);
16060         return ret_arr;
16061 }
16062
16063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
16064         LDKThirtyTwoBytes big_endian_bytes_ref;
16065         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
16066         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
16067         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
16068         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
16069         return tag_ptr(ret_ref, true);
16070 }
16071
16072 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
16073         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
16074         *ret_copy = Bech32Error_clone(arg);
16075         int64_t ret_ref = tag_ptr(ret_copy, true);
16076         return ret_ref;
16077 }
16078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16079         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
16080         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
16081         return ret_conv;
16082 }
16083
16084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16085         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
16086         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
16087         *ret_copy = Bech32Error_clone(orig_conv);
16088         int64_t ret_ref = tag_ptr(ret_copy, true);
16089         return ret_ref;
16090 }
16091
16092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
16093         if (!ptr_is_owned(o)) return;
16094         void* o_ptr = untag_ptr(o);
16095         CHECK_ACCESS(o_ptr);
16096         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
16097         FREE(untag_ptr(o));
16098         Bech32Error_free(o_conv);
16099 }
16100
16101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16102         LDKTransaction _res_ref;
16103         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16104         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
16105         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16106         _res_ref.data_is_owned = true;
16107         Transaction_free(_res_ref);
16108 }
16109
16110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Witness_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16111         LDKWitness _res_ref;
16112         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16113         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
16114         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16115         _res_ref.data_is_owned = true;
16116         Witness_free(_res_ref);
16117 }
16118
16119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
16120         LDKCVec_u8Z script_pubkey_ref;
16121         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
16122         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
16123         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
16124         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16125         *ret_ref = TxOut_new(script_pubkey_ref, value);
16126         return tag_ptr(ret_ref, true);
16127 }
16128
16129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
16130         if (!ptr_is_owned(_res)) return;
16131         void* _res_ptr = untag_ptr(_res);
16132         CHECK_ACCESS(_res_ptr);
16133         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
16134         FREE(untag_ptr(_res));
16135         TxOut_free(_res_conv);
16136 }
16137
16138 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
16139         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16140         *ret_ref = TxOut_clone(arg);
16141         return tag_ptr(ret_ref, true);
16142 }
16143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16144         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
16145         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
16146         return ret_conv;
16147 }
16148
16149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16150         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
16151         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16152         *ret_ref = TxOut_clone(orig_conv);
16153         return tag_ptr(ret_ref, true);
16154 }
16155
16156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
16157         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
16158         Str_free(dummy);
16159 }
16160
16161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16162         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16163         *ret_copy = COption_DurationZ_some(o);
16164         int64_t ret_ref = tag_ptr(ret_copy, true);
16165         return ret_ref;
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1none(JNIEnv *env, jclass clz) {
16169         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16170         *ret_copy = COption_DurationZ_none();
16171         int64_t ret_ref = tag_ptr(ret_copy, true);
16172         return ret_ref;
16173 }
16174
16175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16176         if (!ptr_is_owned(_res)) return;
16177         void* _res_ptr = untag_ptr(_res);
16178         CHECK_ACCESS(_res_ptr);
16179         LDKCOption_DurationZ _res_conv = *(LDKCOption_DurationZ*)(_res_ptr);
16180         FREE(untag_ptr(_res));
16181         COption_DurationZ_free(_res_conv);
16182 }
16183
16184 static inline uint64_t COption_DurationZ_clone_ptr(LDKCOption_DurationZ *NONNULL_PTR arg) {
16185         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16186         *ret_copy = COption_DurationZ_clone(arg);
16187         int64_t ret_ref = tag_ptr(ret_copy, true);
16188         return ret_ref;
16189 }
16190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16191         LDKCOption_DurationZ* arg_conv = (LDKCOption_DurationZ*)untag_ptr(arg);
16192         int64_t ret_conv = COption_DurationZ_clone_ptr(arg_conv);
16193         return ret_conv;
16194 }
16195
16196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16197         LDKCOption_DurationZ* orig_conv = (LDKCOption_DurationZ*)untag_ptr(orig);
16198         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16199         *ret_copy = COption_DurationZ_clone(orig_conv);
16200         int64_t ret_ref = tag_ptr(ret_copy, true);
16201         return ret_ref;
16202 }
16203
16204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BlindedPathZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16205         LDKCVec_BlindedPathZ _res_constr;
16206         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16207         if (_res_constr.datalen > 0)
16208                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedPath), "LDKCVec_BlindedPathZ Elements");
16209         else
16210                 _res_constr.data = NULL;
16211         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16212         for (size_t n = 0; n < _res_constr.datalen; n++) {
16213                 int64_t _res_conv_13 = _res_vals[n];
16214                 LDKBlindedPath _res_conv_13_conv;
16215                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
16216                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
16217                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
16218                 _res_constr.data[n] = _res_conv_13_conv;
16219         }
16220         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16221         CVec_BlindedPathZ_free(_res_constr);
16222 }
16223
16224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16225         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16226         *ret_copy = COption_u64Z_some(o);
16227         int64_t ret_ref = tag_ptr(ret_copy, true);
16228         return ret_ref;
16229 }
16230
16231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16232         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16233         *ret_copy = COption_u64Z_none();
16234         int64_t ret_ref = tag_ptr(ret_copy, true);
16235         return ret_ref;
16236 }
16237
16238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16239         if (!ptr_is_owned(_res)) return;
16240         void* _res_ptr = untag_ptr(_res);
16241         CHECK_ACCESS(_res_ptr);
16242         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16243         FREE(untag_ptr(_res));
16244         COption_u64Z_free(_res_conv);
16245 }
16246
16247 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16248         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16249         *ret_copy = COption_u64Z_clone(arg);
16250         int64_t ret_ref = tag_ptr(ret_copy, true);
16251         return ret_ref;
16252 }
16253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16254         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
16255         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16256         return ret_conv;
16257 }
16258
16259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16260         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
16261         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16262         *ret_copy = COption_u64Z_clone(orig_conv);
16263         int64_t ret_ref = tag_ptr(ret_copy, true);
16264         return ret_ref;
16265 }
16266
16267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
16268         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16269         *ret_conv = CResult_NoneAPIErrorZ_ok();
16270         return tag_ptr(ret_conv, true);
16271 }
16272
16273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16274         void* e_ptr = untag_ptr(e);
16275         CHECK_ACCESS(e_ptr);
16276         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16277         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
16278         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16279         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
16280         return tag_ptr(ret_conv, true);
16281 }
16282
16283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16284         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
16285         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
16286         return ret_conv;
16287 }
16288
16289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16290         if (!ptr_is_owned(_res)) return;
16291         void* _res_ptr = untag_ptr(_res);
16292         CHECK_ACCESS(_res_ptr);
16293         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
16294         FREE(untag_ptr(_res));
16295         CResult_NoneAPIErrorZ_free(_res_conv);
16296 }
16297
16298 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
16299         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16300         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
16301         return tag_ptr(ret_conv, true);
16302 }
16303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16304         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
16305         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
16306         return ret_conv;
16307 }
16308
16309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16310         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
16311         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16312         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
16313         return tag_ptr(ret_conv, true);
16314 }
16315
16316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16317         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
16318         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16319         if (_res_constr.datalen > 0)
16320                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16321         else
16322                 _res_constr.data = NULL;
16323         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16324         for (size_t w = 0; w < _res_constr.datalen; w++) {
16325                 int64_t _res_conv_22 = _res_vals[w];
16326                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
16327                 CHECK_ACCESS(_res_conv_22_ptr);
16328                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
16329                 FREE(untag_ptr(_res_conv_22));
16330                 _res_constr.data[w] = _res_conv_22_conv;
16331         }
16332         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16333         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
16334 }
16335
16336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16337         LDKCVec_APIErrorZ _res_constr;
16338         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16339         if (_res_constr.datalen > 0)
16340                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16341         else
16342                 _res_constr.data = NULL;
16343         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16344         for (size_t k = 0; k < _res_constr.datalen; k++) {
16345                 int64_t _res_conv_10 = _res_vals[k];
16346                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
16347                 CHECK_ACCESS(_res_conv_10_ptr);
16348                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
16349                 FREE(untag_ptr(_res_conv_10));
16350                 _res_constr.data[k] = _res_conv_10_conv;
16351         }
16352         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16353         CVec_APIErrorZ_free(_res_constr);
16354 }
16355
16356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16357         LDKCVec_u8Z _res_ref;
16358         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16359         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
16360         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16361         CVec_u8Z_free(_res_ref);
16362 }
16363
16364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1some(JNIEnv *env, jclass clz, int8_tArray o) {
16365         LDKCVec_u8Z o_ref;
16366         o_ref.datalen = (*env)->GetArrayLength(env, o);
16367         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16368         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16369         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16370         *ret_copy = COption_CVec_u8ZZ_some(o_ref);
16371         int64_t ret_ref = tag_ptr(ret_copy, true);
16372         return ret_ref;
16373 }
16374
16375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1none(JNIEnv *env, jclass clz) {
16376         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16377         *ret_copy = COption_CVec_u8ZZ_none();
16378         int64_t ret_ref = tag_ptr(ret_copy, true);
16379         return ret_ref;
16380 }
16381
16382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16383         if (!ptr_is_owned(_res)) return;
16384         void* _res_ptr = untag_ptr(_res);
16385         CHECK_ACCESS(_res_ptr);
16386         LDKCOption_CVec_u8ZZ _res_conv = *(LDKCOption_CVec_u8ZZ*)(_res_ptr);
16387         FREE(untag_ptr(_res));
16388         COption_CVec_u8ZZ_free(_res_conv);
16389 }
16390
16391 static inline uint64_t COption_CVec_u8ZZ_clone_ptr(LDKCOption_CVec_u8ZZ *NONNULL_PTR arg) {
16392         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16393         *ret_copy = COption_CVec_u8ZZ_clone(arg);
16394         int64_t ret_ref = tag_ptr(ret_copy, true);
16395         return ret_ref;
16396 }
16397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16398         LDKCOption_CVec_u8ZZ* arg_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(arg);
16399         int64_t ret_conv = COption_CVec_u8ZZ_clone_ptr(arg_conv);
16400         return ret_conv;
16401 }
16402
16403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16404         LDKCOption_CVec_u8ZZ* orig_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(orig);
16405         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16406         *ret_copy = COption_CVec_u8ZZ_clone(orig_conv);
16407         int64_t ret_ref = tag_ptr(ret_copy, true);
16408         return ret_ref;
16409 }
16410
16411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16412         LDKRecipientOnionFields o_conv;
16413         o_conv.inner = untag_ptr(o);
16414         o_conv.is_owned = ptr_is_owned(o);
16415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16416         o_conv = RecipientOnionFields_clone(&o_conv);
16417         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16418         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_ok(o_conv);
16419         return tag_ptr(ret_conv, true);
16420 }
16421
16422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16423         void* e_ptr = untag_ptr(e);
16424         CHECK_ACCESS(e_ptr);
16425         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16426         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16427         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16428         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_err(e_conv);
16429         return tag_ptr(ret_conv, true);
16430 }
16431
16432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16433         LDKCResult_RecipientOnionFieldsDecodeErrorZ* o_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(o);
16434         jboolean ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(o_conv);
16435         return ret_conv;
16436 }
16437
16438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16439         if (!ptr_is_owned(_res)) return;
16440         void* _res_ptr = untag_ptr(_res);
16441         CHECK_ACCESS(_res_ptr);
16442         LDKCResult_RecipientOnionFieldsDecodeErrorZ _res_conv = *(LDKCResult_RecipientOnionFieldsDecodeErrorZ*)(_res_ptr);
16443         FREE(untag_ptr(_res));
16444         CResult_RecipientOnionFieldsDecodeErrorZ_free(_res_conv);
16445 }
16446
16447 static inline uint64_t CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR arg) {
16448         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16449         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(arg);
16450         return tag_ptr(ret_conv, true);
16451 }
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16453         LDKCResult_RecipientOnionFieldsDecodeErrorZ* arg_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(arg);
16454         int64_t ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(arg_conv);
16455         return ret_conv;
16456 }
16457
16458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16459         LDKCResult_RecipientOnionFieldsDecodeErrorZ* orig_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(orig);
16460         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16461         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig_conv);
16462         return tag_ptr(ret_conv, true);
16463 }
16464
16465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1some(JNIEnv *env, jclass clz, jclass o) {
16466         LDKHTLCClaim o_conv = LDKHTLCClaim_from_java(env, o);
16467         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
16468         *ret_copy = COption_HTLCClaimZ_some(o_conv);
16469         int64_t ret_ref = tag_ptr(ret_copy, true);
16470         return ret_ref;
16471 }
16472
16473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1none(JNIEnv *env, jclass clz) {
16474         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
16475         *ret_copy = COption_HTLCClaimZ_none();
16476         int64_t ret_ref = tag_ptr(ret_copy, true);
16477         return ret_ref;
16478 }
16479
16480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16481         if (!ptr_is_owned(_res)) return;
16482         void* _res_ptr = untag_ptr(_res);
16483         CHECK_ACCESS(_res_ptr);
16484         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
16485         FREE(untag_ptr(_res));
16486         COption_HTLCClaimZ_free(_res_conv);
16487 }
16488
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
16490         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16491         *ret_conv = CResult_NoneNoneZ_ok();
16492         return tag_ptr(ret_conv, true);
16493 }
16494
16495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
16496         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16497         *ret_conv = CResult_NoneNoneZ_err();
16498         return tag_ptr(ret_conv, true);
16499 }
16500
16501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16502         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
16503         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
16504         return ret_conv;
16505 }
16506
16507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16508         if (!ptr_is_owned(_res)) return;
16509         void* _res_ptr = untag_ptr(_res);
16510         CHECK_ACCESS(_res_ptr);
16511         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
16512         FREE(untag_ptr(_res));
16513         CResult_NoneNoneZ_free(_res_conv);
16514 }
16515
16516 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
16517         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16518         *ret_conv = CResult_NoneNoneZ_clone(arg);
16519         return tag_ptr(ret_conv, true);
16520 }
16521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16522         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
16523         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
16524         return ret_conv;
16525 }
16526
16527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16528         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
16529         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16530         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
16531         return tag_ptr(ret_conv, true);
16532 }
16533
16534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16535         LDKCounterpartyCommitmentSecrets o_conv;
16536         o_conv.inner = untag_ptr(o);
16537         o_conv.is_owned = ptr_is_owned(o);
16538         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16539         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
16540         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16541         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
16542         return tag_ptr(ret_conv, true);
16543 }
16544
16545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16546         void* e_ptr = untag_ptr(e);
16547         CHECK_ACCESS(e_ptr);
16548         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16549         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16550         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16551         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
16552         return tag_ptr(ret_conv, true);
16553 }
16554
16555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16556         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
16557         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
16558         return ret_conv;
16559 }
16560
16561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16562         if (!ptr_is_owned(_res)) return;
16563         void* _res_ptr = untag_ptr(_res);
16564         CHECK_ACCESS(_res_ptr);
16565         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
16566         FREE(untag_ptr(_res));
16567         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
16568 }
16569
16570 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
16571         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16572         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
16573         return tag_ptr(ret_conv, true);
16574 }
16575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16576         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
16577         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
16578         return ret_conv;
16579 }
16580
16581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16582         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
16583         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16584         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
16585         return tag_ptr(ret_conv, true);
16586 }
16587
16588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16589         LDKTxCreationKeys o_conv;
16590         o_conv.inner = untag_ptr(o);
16591         o_conv.is_owned = ptr_is_owned(o);
16592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16593         o_conv = TxCreationKeys_clone(&o_conv);
16594         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16595         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
16596         return tag_ptr(ret_conv, true);
16597 }
16598
16599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16600         void* e_ptr = untag_ptr(e);
16601         CHECK_ACCESS(e_ptr);
16602         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16603         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16604         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16605         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
16606         return tag_ptr(ret_conv, true);
16607 }
16608
16609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16610         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
16611         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
16612         return ret_conv;
16613 }
16614
16615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16616         if (!ptr_is_owned(_res)) return;
16617         void* _res_ptr = untag_ptr(_res);
16618         CHECK_ACCESS(_res_ptr);
16619         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
16620         FREE(untag_ptr(_res));
16621         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
16622 }
16623
16624 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
16625         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16626         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
16627         return tag_ptr(ret_conv, true);
16628 }
16629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16630         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
16631         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
16632         return ret_conv;
16633 }
16634
16635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16636         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
16637         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16638         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
16639         return tag_ptr(ret_conv, true);
16640 }
16641
16642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16643         LDKChannelPublicKeys o_conv;
16644         o_conv.inner = untag_ptr(o);
16645         o_conv.is_owned = ptr_is_owned(o);
16646         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16647         o_conv = ChannelPublicKeys_clone(&o_conv);
16648         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16649         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
16650         return tag_ptr(ret_conv, true);
16651 }
16652
16653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16654         void* e_ptr = untag_ptr(e);
16655         CHECK_ACCESS(e_ptr);
16656         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16657         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16658         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16659         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
16660         return tag_ptr(ret_conv, true);
16661 }
16662
16663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16664         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
16665         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
16666         return ret_conv;
16667 }
16668
16669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16670         if (!ptr_is_owned(_res)) return;
16671         void* _res_ptr = untag_ptr(_res);
16672         CHECK_ACCESS(_res_ptr);
16673         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
16674         FREE(untag_ptr(_res));
16675         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
16676 }
16677
16678 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
16679         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16680         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
16681         return tag_ptr(ret_conv, true);
16682 }
16683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16684         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
16685         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
16686         return ret_conv;
16687 }
16688
16689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16690         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
16691         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16692         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
16693         return tag_ptr(ret_conv, true);
16694 }
16695
16696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
16697         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16698         *ret_copy = COption_u32Z_some(o);
16699         int64_t ret_ref = tag_ptr(ret_copy, true);
16700         return ret_ref;
16701 }
16702
16703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
16704         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16705         *ret_copy = COption_u32Z_none();
16706         int64_t ret_ref = tag_ptr(ret_copy, true);
16707         return ret_ref;
16708 }
16709
16710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16711         if (!ptr_is_owned(_res)) return;
16712         void* _res_ptr = untag_ptr(_res);
16713         CHECK_ACCESS(_res_ptr);
16714         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16715         FREE(untag_ptr(_res));
16716         COption_u32Z_free(_res_conv);
16717 }
16718
16719 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16720         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16721         *ret_copy = COption_u32Z_clone(arg);
16722         int64_t ret_ref = tag_ptr(ret_copy, true);
16723         return ret_ref;
16724 }
16725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16726         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16727         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16728         return ret_conv;
16729 }
16730
16731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16732         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16733         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16734         *ret_copy = COption_u32Z_clone(orig_conv);
16735         int64_t ret_ref = tag_ptr(ret_copy, true);
16736         return ret_ref;
16737 }
16738
16739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16740         LDKHTLCOutputInCommitment o_conv;
16741         o_conv.inner = untag_ptr(o);
16742         o_conv.is_owned = ptr_is_owned(o);
16743         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16744         o_conv = HTLCOutputInCommitment_clone(&o_conv);
16745         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16746         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
16747         return tag_ptr(ret_conv, true);
16748 }
16749
16750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16751         void* e_ptr = untag_ptr(e);
16752         CHECK_ACCESS(e_ptr);
16753         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16754         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16755         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16756         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
16757         return tag_ptr(ret_conv, true);
16758 }
16759
16760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16761         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
16762         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
16763         return ret_conv;
16764 }
16765
16766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16767         if (!ptr_is_owned(_res)) return;
16768         void* _res_ptr = untag_ptr(_res);
16769         CHECK_ACCESS(_res_ptr);
16770         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
16771         FREE(untag_ptr(_res));
16772         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
16773 }
16774
16775 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16776         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16777         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16778         return tag_ptr(ret_conv, true);
16779 }
16780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16781         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16782         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16783         return ret_conv;
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16787         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16788         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16789         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16790         return tag_ptr(ret_conv, true);
16791 }
16792
16793 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16794         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16795         return ret_conv;
16796 }
16797
16798 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16799         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16800         return ret_conv;
16801 }
16802
16803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16804         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16805         COption_NoneZ_free(_res_conv);
16806 }
16807
16808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16809         LDKCounterpartyChannelTransactionParameters o_conv;
16810         o_conv.inner = untag_ptr(o);
16811         o_conv.is_owned = ptr_is_owned(o);
16812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16813         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16814         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16815         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16816         return tag_ptr(ret_conv, true);
16817 }
16818
16819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16820         void* e_ptr = untag_ptr(e);
16821         CHECK_ACCESS(e_ptr);
16822         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16823         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16824         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16825         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16826         return tag_ptr(ret_conv, true);
16827 }
16828
16829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16830         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16831         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16832         return ret_conv;
16833 }
16834
16835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16836         if (!ptr_is_owned(_res)) return;
16837         void* _res_ptr = untag_ptr(_res);
16838         CHECK_ACCESS(_res_ptr);
16839         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16840         FREE(untag_ptr(_res));
16841         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16842 }
16843
16844 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16845         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16846         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16847         return tag_ptr(ret_conv, true);
16848 }
16849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16850         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16851         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16852         return ret_conv;
16853 }
16854
16855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16856         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16857         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16858         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16859         return tag_ptr(ret_conv, true);
16860 }
16861
16862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16863         LDKChannelTransactionParameters o_conv;
16864         o_conv.inner = untag_ptr(o);
16865         o_conv.is_owned = ptr_is_owned(o);
16866         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16867         o_conv = ChannelTransactionParameters_clone(&o_conv);
16868         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16869         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16870         return tag_ptr(ret_conv, true);
16871 }
16872
16873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16874         void* e_ptr = untag_ptr(e);
16875         CHECK_ACCESS(e_ptr);
16876         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16877         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16878         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16879         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16880         return tag_ptr(ret_conv, true);
16881 }
16882
16883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16884         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16885         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16886         return ret_conv;
16887 }
16888
16889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16890         if (!ptr_is_owned(_res)) return;
16891         void* _res_ptr = untag_ptr(_res);
16892         CHECK_ACCESS(_res_ptr);
16893         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16894         FREE(untag_ptr(_res));
16895         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16896 }
16897
16898 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16899         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16900         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16901         return tag_ptr(ret_conv, true);
16902 }
16903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16904         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16905         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16906         return ret_conv;
16907 }
16908
16909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16910         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16911         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16912         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16913         return tag_ptr(ret_conv, true);
16914 }
16915
16916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16917         LDKCVec_SignatureZ _res_constr;
16918         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16919         if (_res_constr.datalen > 0)
16920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16921         else
16922                 _res_constr.data = NULL;
16923         for (size_t i = 0; i < _res_constr.datalen; i++) {
16924                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16925                 LDKSignature _res_conv_8_ref;
16926                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16927                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16928                 _res_constr.data[i] = _res_conv_8_ref;
16929         }
16930         CVec_SignatureZ_free(_res_constr);
16931 }
16932
16933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16934         LDKHolderCommitmentTransaction o_conv;
16935         o_conv.inner = untag_ptr(o);
16936         o_conv.is_owned = ptr_is_owned(o);
16937         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16938         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16939         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16940         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16941         return tag_ptr(ret_conv, true);
16942 }
16943
16944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16945         void* e_ptr = untag_ptr(e);
16946         CHECK_ACCESS(e_ptr);
16947         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16948         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16949         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16950         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16951         return tag_ptr(ret_conv, true);
16952 }
16953
16954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16955         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16956         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16957         return ret_conv;
16958 }
16959
16960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16961         if (!ptr_is_owned(_res)) return;
16962         void* _res_ptr = untag_ptr(_res);
16963         CHECK_ACCESS(_res_ptr);
16964         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16965         FREE(untag_ptr(_res));
16966         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16967 }
16968
16969 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16970         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16971         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16972         return tag_ptr(ret_conv, true);
16973 }
16974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16975         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16976         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16977         return ret_conv;
16978 }
16979
16980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16981         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16982         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16983         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16984         return tag_ptr(ret_conv, true);
16985 }
16986
16987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16988         LDKBuiltCommitmentTransaction o_conv;
16989         o_conv.inner = untag_ptr(o);
16990         o_conv.is_owned = ptr_is_owned(o);
16991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16992         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16993         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16994         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16995         return tag_ptr(ret_conv, true);
16996 }
16997
16998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16999         void* e_ptr = untag_ptr(e);
17000         CHECK_ACCESS(e_ptr);
17001         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17002         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17003         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17004         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
17005         return tag_ptr(ret_conv, true);
17006 }
17007
17008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17009         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
17010         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
17011         return ret_conv;
17012 }
17013
17014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17015         if (!ptr_is_owned(_res)) return;
17016         void* _res_ptr = untag_ptr(_res);
17017         CHECK_ACCESS(_res_ptr);
17018         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
17019         FREE(untag_ptr(_res));
17020         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
17021 }
17022
17023 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
17024         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17025         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
17026         return tag_ptr(ret_conv, true);
17027 }
17028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17029         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
17030         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
17031         return ret_conv;
17032 }
17033
17034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17035         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
17036         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17037         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
17038         return tag_ptr(ret_conv, true);
17039 }
17040
17041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17042         LDKTrustedClosingTransaction o_conv;
17043         o_conv.inner = untag_ptr(o);
17044         o_conv.is_owned = ptr_is_owned(o);
17045         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17046         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
17047         
17048         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
17049         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
17050         return tag_ptr(ret_conv, true);
17051 }
17052
17053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17054         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
17055         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
17056         return tag_ptr(ret_conv, true);
17057 }
17058
17059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17060         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
17061         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
17062         return ret_conv;
17063 }
17064
17065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17066         if (!ptr_is_owned(_res)) return;
17067         void* _res_ptr = untag_ptr(_res);
17068         CHECK_ACCESS(_res_ptr);
17069         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
17070         FREE(untag_ptr(_res));
17071         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
17072 }
17073
17074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17075         LDKCommitmentTransaction o_conv;
17076         o_conv.inner = untag_ptr(o);
17077         o_conv.is_owned = ptr_is_owned(o);
17078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17079         o_conv = CommitmentTransaction_clone(&o_conv);
17080         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17081         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
17082         return tag_ptr(ret_conv, true);
17083 }
17084
17085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17086         void* e_ptr = untag_ptr(e);
17087         CHECK_ACCESS(e_ptr);
17088         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17089         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17090         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17091         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
17092         return tag_ptr(ret_conv, true);
17093 }
17094
17095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17096         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
17097         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
17098         return ret_conv;
17099 }
17100
17101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17102         if (!ptr_is_owned(_res)) return;
17103         void* _res_ptr = untag_ptr(_res);
17104         CHECK_ACCESS(_res_ptr);
17105         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
17106         FREE(untag_ptr(_res));
17107         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
17108 }
17109
17110 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
17111         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17112         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
17113         return tag_ptr(ret_conv, true);
17114 }
17115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17116         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
17117         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
17118         return ret_conv;
17119 }
17120
17121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17122         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
17123         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17124         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
17125         return tag_ptr(ret_conv, true);
17126 }
17127
17128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17129         LDKTrustedCommitmentTransaction o_conv;
17130         o_conv.inner = untag_ptr(o);
17131         o_conv.is_owned = ptr_is_owned(o);
17132         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17133         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
17134         
17135         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17136         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
17137         return tag_ptr(ret_conv, true);
17138 }
17139
17140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17141         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17142         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
17143         return tag_ptr(ret_conv, true);
17144 }
17145
17146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17147         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
17148         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
17149         return ret_conv;
17150 }
17151
17152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17153         if (!ptr_is_owned(_res)) return;
17154         void* _res_ptr = untag_ptr(_res);
17155         CHECK_ACCESS(_res_ptr);
17156         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
17157         FREE(untag_ptr(_res));
17158         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
17159 }
17160
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17162         LDKCVec_SignatureZ o_constr;
17163         o_constr.datalen = (*env)->GetArrayLength(env, o);
17164         if (o_constr.datalen > 0)
17165                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17166         else
17167                 o_constr.data = NULL;
17168         for (size_t i = 0; i < o_constr.datalen; i++) {
17169                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17170                 LDKSignature o_conv_8_ref;
17171                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
17172                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
17173                 o_constr.data[i] = o_conv_8_ref;
17174         }
17175         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17176         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
17177         return tag_ptr(ret_conv, true);
17178 }
17179
17180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
17181         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17182         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
17183         return tag_ptr(ret_conv, true);
17184 }
17185
17186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17187         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
17188         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
17189         return ret_conv;
17190 }
17191
17192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17193         if (!ptr_is_owned(_res)) return;
17194         void* _res_ptr = untag_ptr(_res);
17195         CHECK_ACCESS(_res_ptr);
17196         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
17197         FREE(untag_ptr(_res));
17198         CResult_CVec_SignatureZNoneZ_free(_res_conv);
17199 }
17200
17201 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
17202         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17203         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
17204         return tag_ptr(ret_conv, true);
17205 }
17206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17207         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
17208         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
17209         return ret_conv;
17210 }
17211
17212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17213         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
17214         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17215         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
17216         return tag_ptr(ret_conv, true);
17217 }
17218
17219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17220         LDKShutdownScript o_conv;
17221         o_conv.inner = untag_ptr(o);
17222         o_conv.is_owned = ptr_is_owned(o);
17223         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17224         o_conv = ShutdownScript_clone(&o_conv);
17225         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17226         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
17227         return tag_ptr(ret_conv, true);
17228 }
17229
17230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17231         void* e_ptr = untag_ptr(e);
17232         CHECK_ACCESS(e_ptr);
17233         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17234         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17235         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17236         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
17237         return tag_ptr(ret_conv, true);
17238 }
17239
17240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17241         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
17242         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
17243         return ret_conv;
17244 }
17245
17246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17247         if (!ptr_is_owned(_res)) return;
17248         void* _res_ptr = untag_ptr(_res);
17249         CHECK_ACCESS(_res_ptr);
17250         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
17251         FREE(untag_ptr(_res));
17252         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
17253 }
17254
17255 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
17256         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17257         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
17258         return tag_ptr(ret_conv, true);
17259 }
17260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17261         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
17262         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
17263         return ret_conv;
17264 }
17265
17266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17267         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
17268         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17269         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
17270         return tag_ptr(ret_conv, true);
17271 }
17272
17273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17274         LDKShutdownScript o_conv;
17275         o_conv.inner = untag_ptr(o);
17276         o_conv.is_owned = ptr_is_owned(o);
17277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17278         o_conv = ShutdownScript_clone(&o_conv);
17279         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17280         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
17281         return tag_ptr(ret_conv, true);
17282 }
17283
17284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17285         LDKInvalidShutdownScript e_conv;
17286         e_conv.inner = untag_ptr(e);
17287         e_conv.is_owned = ptr_is_owned(e);
17288         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17289         e_conv = InvalidShutdownScript_clone(&e_conv);
17290         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17291         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
17292         return tag_ptr(ret_conv, true);
17293 }
17294
17295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17296         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
17297         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
17298         return ret_conv;
17299 }
17300
17301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17302         if (!ptr_is_owned(_res)) return;
17303         void* _res_ptr = untag_ptr(_res);
17304         CHECK_ACCESS(_res_ptr);
17305         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
17306         FREE(untag_ptr(_res));
17307         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
17308 }
17309
17310 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
17311         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17312         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
17313         return tag_ptr(ret_conv, true);
17314 }
17315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17316         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
17317         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
17318         return ret_conv;
17319 }
17320
17321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17322         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
17323         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17324         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
17325         return tag_ptr(ret_conv, true);
17326 }
17327
17328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17329         LDKBlindedPayInfo o_conv;
17330         o_conv.inner = untag_ptr(o);
17331         o_conv.is_owned = ptr_is_owned(o);
17332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17333         o_conv = BlindedPayInfo_clone(&o_conv);
17334         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17335         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_ok(o_conv);
17336         return tag_ptr(ret_conv, true);
17337 }
17338
17339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17340         void* e_ptr = untag_ptr(e);
17341         CHECK_ACCESS(e_ptr);
17342         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17343         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17344         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17345         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_err(e_conv);
17346         return tag_ptr(ret_conv, true);
17347 }
17348
17349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17350         LDKCResult_BlindedPayInfoDecodeErrorZ* o_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(o);
17351         jboolean ret_conv = CResult_BlindedPayInfoDecodeErrorZ_is_ok(o_conv);
17352         return ret_conv;
17353 }
17354
17355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17356         if (!ptr_is_owned(_res)) return;
17357         void* _res_ptr = untag_ptr(_res);
17358         CHECK_ACCESS(_res_ptr);
17359         LDKCResult_BlindedPayInfoDecodeErrorZ _res_conv = *(LDKCResult_BlindedPayInfoDecodeErrorZ*)(_res_ptr);
17360         FREE(untag_ptr(_res));
17361         CResult_BlindedPayInfoDecodeErrorZ_free(_res_conv);
17362 }
17363
17364 static inline uint64_t CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR arg) {
17365         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17366         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(arg);
17367         return tag_ptr(ret_conv, true);
17368 }
17369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17370         LDKCResult_BlindedPayInfoDecodeErrorZ* arg_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(arg);
17371         int64_t ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(arg_conv);
17372         return ret_conv;
17373 }
17374
17375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17376         LDKCResult_BlindedPayInfoDecodeErrorZ* orig_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(orig);
17377         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17378         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(orig_conv);
17379         return tag_ptr(ret_conv, true);
17380 }
17381
17382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17383         void* o_ptr = untag_ptr(o);
17384         CHECK_ACCESS(o_ptr);
17385         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
17386         if (o_conv.free == LDKWriteableScore_JCalls_free) {
17387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17388                 LDKWriteableScore_JCalls_cloned(&o_conv);
17389         }
17390         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17391         *ret_copy = COption_WriteableScoreZ_some(o_conv);
17392         int64_t ret_ref = tag_ptr(ret_copy, true);
17393         return ret_ref;
17394 }
17395
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
17397         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17398         *ret_copy = COption_WriteableScoreZ_none();
17399         int64_t ret_ref = tag_ptr(ret_copy, true);
17400         return ret_ref;
17401 }
17402
17403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17404         if (!ptr_is_owned(_res)) return;
17405         void* _res_ptr = untag_ptr(_res);
17406         CHECK_ACCESS(_res_ptr);
17407         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
17408         FREE(untag_ptr(_res));
17409         COption_WriteableScoreZ_free(_res_conv);
17410 }
17411
17412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
17413         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17414         *ret_conv = CResult_NoneErrorZ_ok();
17415         return tag_ptr(ret_conv, true);
17416 }
17417
17418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17419         LDKIOError e_conv = LDKIOError_from_java(env, e);
17420         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17421         *ret_conv = CResult_NoneErrorZ_err(e_conv);
17422         return tag_ptr(ret_conv, true);
17423 }
17424
17425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17426         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
17427         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
17428         return ret_conv;
17429 }
17430
17431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17432         if (!ptr_is_owned(_res)) return;
17433         void* _res_ptr = untag_ptr(_res);
17434         CHECK_ACCESS(_res_ptr);
17435         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17436         FREE(untag_ptr(_res));
17437         CResult_NoneErrorZ_free(_res_conv);
17438 }
17439
17440 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17441         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17442         *ret_conv = CResult_NoneErrorZ_clone(arg);
17443         return tag_ptr(ret_conv, true);
17444 }
17445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17446         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
17447         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17448         return ret_conv;
17449 }
17450
17451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17452         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
17453         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17454         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17455         return tag_ptr(ret_conv, true);
17456 }
17457
17458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17459         LDKCVec_ChannelDetailsZ _res_constr;
17460         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17461         if (_res_constr.datalen > 0)
17462                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17463         else
17464                 _res_constr.data = NULL;
17465         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17466         for (size_t q = 0; q < _res_constr.datalen; q++) {
17467                 int64_t _res_conv_16 = _res_vals[q];
17468                 LDKChannelDetails _res_conv_16_conv;
17469                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17470                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17471                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17472                 _res_constr.data[q] = _res_conv_16_conv;
17473         }
17474         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17475         CVec_ChannelDetailsZ_free(_res_constr);
17476 }
17477
17478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17479         LDKRoute o_conv;
17480         o_conv.inner = untag_ptr(o);
17481         o_conv.is_owned = ptr_is_owned(o);
17482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17483         o_conv = Route_clone(&o_conv);
17484         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17485         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17486         return tag_ptr(ret_conv, true);
17487 }
17488
17489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17490         LDKLightningError e_conv;
17491         e_conv.inner = untag_ptr(e);
17492         e_conv.is_owned = ptr_is_owned(e);
17493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17494         e_conv = LightningError_clone(&e_conv);
17495         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17496         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17497         return tag_ptr(ret_conv, true);
17498 }
17499
17500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17501         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17502         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17503         return ret_conv;
17504 }
17505
17506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17507         if (!ptr_is_owned(_res)) return;
17508         void* _res_ptr = untag_ptr(_res);
17509         CHECK_ACCESS(_res_ptr);
17510         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17511         FREE(untag_ptr(_res));
17512         CResult_RouteLightningErrorZ_free(_res_conv);
17513 }
17514
17515 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17516         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17517         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17518         return tag_ptr(ret_conv, true);
17519 }
17520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17521         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17522         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17523         return ret_conv;
17524 }
17525
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17527         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17528         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17529         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17530         return tag_ptr(ret_conv, true);
17531 }
17532
17533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17534         LDKInFlightHtlcs o_conv;
17535         o_conv.inner = untag_ptr(o);
17536         o_conv.is_owned = ptr_is_owned(o);
17537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17538         o_conv = InFlightHtlcs_clone(&o_conv);
17539         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17540         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17541         return tag_ptr(ret_conv, true);
17542 }
17543
17544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17545         void* e_ptr = untag_ptr(e);
17546         CHECK_ACCESS(e_ptr);
17547         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17548         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17549         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17550         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17551         return tag_ptr(ret_conv, true);
17552 }
17553
17554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17555         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17556         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17557         return ret_conv;
17558 }
17559
17560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17561         if (!ptr_is_owned(_res)) return;
17562         void* _res_ptr = untag_ptr(_res);
17563         CHECK_ACCESS(_res_ptr);
17564         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17565         FREE(untag_ptr(_res));
17566         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17567 }
17568
17569 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17570         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17571         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17572         return tag_ptr(ret_conv, true);
17573 }
17574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17575         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17576         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17577         return ret_conv;
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17581         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17582         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17583         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17584         return tag_ptr(ret_conv, true);
17585 }
17586
17587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17588         LDKRouteHop o_conv;
17589         o_conv.inner = untag_ptr(o);
17590         o_conv.is_owned = ptr_is_owned(o);
17591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17592         o_conv = RouteHop_clone(&o_conv);
17593         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17594         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17595         return tag_ptr(ret_conv, true);
17596 }
17597
17598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17599         void* e_ptr = untag_ptr(e);
17600         CHECK_ACCESS(e_ptr);
17601         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17602         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17603         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17604         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17605         return tag_ptr(ret_conv, true);
17606 }
17607
17608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17609         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17610         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17611         return ret_conv;
17612 }
17613
17614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17615         if (!ptr_is_owned(_res)) return;
17616         void* _res_ptr = untag_ptr(_res);
17617         CHECK_ACCESS(_res_ptr);
17618         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17619         FREE(untag_ptr(_res));
17620         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17621 }
17622
17623 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17624         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17625         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17626         return tag_ptr(ret_conv, true);
17627 }
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17629         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17630         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17631         return ret_conv;
17632 }
17633
17634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17635         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17636         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17637         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17638         return tag_ptr(ret_conv, true);
17639 }
17640
17641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BlindedHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17642         LDKCVec_BlindedHopZ _res_constr;
17643         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17644         if (_res_constr.datalen > 0)
17645                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
17646         else
17647                 _res_constr.data = NULL;
17648         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17649         for (size_t m = 0; m < _res_constr.datalen; m++) {
17650                 int64_t _res_conv_12 = _res_vals[m];
17651                 LDKBlindedHop _res_conv_12_conv;
17652                 _res_conv_12_conv.inner = untag_ptr(_res_conv_12);
17653                 _res_conv_12_conv.is_owned = ptr_is_owned(_res_conv_12);
17654                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv);
17655                 _res_constr.data[m] = _res_conv_12_conv;
17656         }
17657         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17658         CVec_BlindedHopZ_free(_res_constr);
17659 }
17660
17661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17662         LDKBlindedTail o_conv;
17663         o_conv.inner = untag_ptr(o);
17664         o_conv.is_owned = ptr_is_owned(o);
17665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17666         o_conv = BlindedTail_clone(&o_conv);
17667         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17668         *ret_conv = CResult_BlindedTailDecodeErrorZ_ok(o_conv);
17669         return tag_ptr(ret_conv, true);
17670 }
17671
17672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17673         void* e_ptr = untag_ptr(e);
17674         CHECK_ACCESS(e_ptr);
17675         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17676         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17677         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17678         *ret_conv = CResult_BlindedTailDecodeErrorZ_err(e_conv);
17679         return tag_ptr(ret_conv, true);
17680 }
17681
17682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17683         LDKCResult_BlindedTailDecodeErrorZ* o_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(o);
17684         jboolean ret_conv = CResult_BlindedTailDecodeErrorZ_is_ok(o_conv);
17685         return ret_conv;
17686 }
17687
17688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17689         if (!ptr_is_owned(_res)) return;
17690         void* _res_ptr = untag_ptr(_res);
17691         CHECK_ACCESS(_res_ptr);
17692         LDKCResult_BlindedTailDecodeErrorZ _res_conv = *(LDKCResult_BlindedTailDecodeErrorZ*)(_res_ptr);
17693         FREE(untag_ptr(_res));
17694         CResult_BlindedTailDecodeErrorZ_free(_res_conv);
17695 }
17696
17697 static inline uint64_t CResult_BlindedTailDecodeErrorZ_clone_ptr(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR arg) {
17698         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17699         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(arg);
17700         return tag_ptr(ret_conv, true);
17701 }
17702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17703         LDKCResult_BlindedTailDecodeErrorZ* arg_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(arg);
17704         int64_t ret_conv = CResult_BlindedTailDecodeErrorZ_clone_ptr(arg_conv);
17705         return ret_conv;
17706 }
17707
17708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17709         LDKCResult_BlindedTailDecodeErrorZ* orig_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(orig);
17710         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17711         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(orig_conv);
17712         return tag_ptr(ret_conv, true);
17713 }
17714
17715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17716         LDKCVec_RouteHopZ _res_constr;
17717         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17718         if (_res_constr.datalen > 0)
17719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17720         else
17721                 _res_constr.data = NULL;
17722         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17723         for (size_t k = 0; k < _res_constr.datalen; k++) {
17724                 int64_t _res_conv_10 = _res_vals[k];
17725                 LDKRouteHop _res_conv_10_conv;
17726                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17727                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17729                 _res_constr.data[k] = _res_conv_10_conv;
17730         }
17731         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17732         CVec_RouteHopZ_free(_res_constr);
17733 }
17734
17735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PathZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17736         LDKCVec_PathZ _res_constr;
17737         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17738         if (_res_constr.datalen > 0)
17739                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
17740         else
17741                 _res_constr.data = NULL;
17742         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17743         for (size_t g = 0; g < _res_constr.datalen; g++) {
17744                 int64_t _res_conv_6 = _res_vals[g];
17745                 LDKPath _res_conv_6_conv;
17746                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
17747                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
17748                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
17749                 _res_constr.data[g] = _res_conv_6_conv;
17750         }
17751         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17752         CVec_PathZ_free(_res_constr);
17753 }
17754
17755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17756         LDKRoute o_conv;
17757         o_conv.inner = untag_ptr(o);
17758         o_conv.is_owned = ptr_is_owned(o);
17759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17760         o_conv = Route_clone(&o_conv);
17761         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17762         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17763         return tag_ptr(ret_conv, true);
17764 }
17765
17766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17767         void* e_ptr = untag_ptr(e);
17768         CHECK_ACCESS(e_ptr);
17769         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17770         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17771         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17772         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17773         return tag_ptr(ret_conv, true);
17774 }
17775
17776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17777         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
17778         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
17779         return ret_conv;
17780 }
17781
17782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17783         if (!ptr_is_owned(_res)) return;
17784         void* _res_ptr = untag_ptr(_res);
17785         CHECK_ACCESS(_res_ptr);
17786         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
17787         FREE(untag_ptr(_res));
17788         CResult_RouteDecodeErrorZ_free(_res_conv);
17789 }
17790
17791 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
17792         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17793         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
17794         return tag_ptr(ret_conv, true);
17795 }
17796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17797         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
17798         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
17799         return ret_conv;
17800 }
17801
17802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17803         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
17804         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17805         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
17806         return tag_ptr(ret_conv, true);
17807 }
17808
17809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17810         LDKRouteParameters o_conv;
17811         o_conv.inner = untag_ptr(o);
17812         o_conv.is_owned = ptr_is_owned(o);
17813         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17814         o_conv = RouteParameters_clone(&o_conv);
17815         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17816         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
17817         return tag_ptr(ret_conv, true);
17818 }
17819
17820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17821         void* e_ptr = untag_ptr(e);
17822         CHECK_ACCESS(e_ptr);
17823         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17824         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17825         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17826         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
17827         return tag_ptr(ret_conv, true);
17828 }
17829
17830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17831         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
17832         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
17833         return ret_conv;
17834 }
17835
17836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17837         if (!ptr_is_owned(_res)) return;
17838         void* _res_ptr = untag_ptr(_res);
17839         CHECK_ACCESS(_res_ptr);
17840         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
17841         FREE(untag_ptr(_res));
17842         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
17843 }
17844
17845 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
17846         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17847         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
17848         return tag_ptr(ret_conv, true);
17849 }
17850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17851         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
17852         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
17853         return ret_conv;
17854 }
17855
17856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17857         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
17858         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17859         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
17860         return tag_ptr(ret_conv, true);
17861 }
17862
17863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17864         LDKCVec_u64Z _res_constr;
17865         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17866         if (_res_constr.datalen > 0)
17867                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17868         else
17869                 _res_constr.data = NULL;
17870         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17871         for (size_t g = 0; g < _res_constr.datalen; g++) {
17872                 int64_t _res_conv_6 = _res_vals[g];
17873                 _res_constr.data[g] = _res_conv_6;
17874         }
17875         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17876         CVec_u64Z_free(_res_constr);
17877 }
17878
17879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17880         LDKPaymentParameters o_conv;
17881         o_conv.inner = untag_ptr(o);
17882         o_conv.is_owned = ptr_is_owned(o);
17883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17884         o_conv = PaymentParameters_clone(&o_conv);
17885         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17886         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
17887         return tag_ptr(ret_conv, true);
17888 }
17889
17890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17891         void* e_ptr = untag_ptr(e);
17892         CHECK_ACCESS(e_ptr);
17893         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17894         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17895         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17896         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
17897         return tag_ptr(ret_conv, true);
17898 }
17899
17900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17901         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
17902         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
17903         return ret_conv;
17904 }
17905
17906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17907         if (!ptr_is_owned(_res)) return;
17908         void* _res_ptr = untag_ptr(_res);
17909         CHECK_ACCESS(_res_ptr);
17910         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
17911         FREE(untag_ptr(_res));
17912         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
17913 }
17914
17915 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
17916         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17917         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
17918         return tag_ptr(ret_conv, true);
17919 }
17920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17921         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
17922         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
17923         return ret_conv;
17924 }
17925
17926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17927         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
17928         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17929         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
17930         return tag_ptr(ret_conv, true);
17931 }
17932
17933 static inline uint64_t C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR arg) {
17934         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17935         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(arg);
17936         return tag_ptr(ret_conv, true);
17937 }
17938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17939         LDKC2Tuple_BlindedPayInfoBlindedPathZ* arg_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(arg);
17940         int64_t ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(arg_conv);
17941         return ret_conv;
17942 }
17943
17944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17945         LDKC2Tuple_BlindedPayInfoBlindedPathZ* orig_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(orig);
17946         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17947         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig_conv);
17948         return tag_ptr(ret_conv, true);
17949 }
17950
17951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17952         LDKBlindedPayInfo a_conv;
17953         a_conv.inner = untag_ptr(a);
17954         a_conv.is_owned = ptr_is_owned(a);
17955         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17956         a_conv = BlindedPayInfo_clone(&a_conv);
17957         LDKBlindedPath b_conv;
17958         b_conv.inner = untag_ptr(b);
17959         b_conv.is_owned = ptr_is_owned(b);
17960         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17961         b_conv = BlindedPath_clone(&b_conv);
17962         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17963         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_new(a_conv, b_conv);
17964         return tag_ptr(ret_conv, true);
17965 }
17966
17967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17968         if (!ptr_is_owned(_res)) return;
17969         void* _res_ptr = untag_ptr(_res);
17970         CHECK_ACCESS(_res_ptr);
17971         LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_ptr);
17972         FREE(untag_ptr(_res));
17973         C2Tuple_BlindedPayInfoBlindedPathZ_free(_res_conv);
17974 }
17975
17976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlindedPayInfoBlindedPathZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17977         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res_constr;
17978         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17979         if (_res_constr.datalen > 0)
17980                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
17981         else
17982                 _res_constr.data = NULL;
17983         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17984         for (size_t l = 0; l < _res_constr.datalen; l++) {
17985                 int64_t _res_conv_37 = _res_vals[l];
17986                 void* _res_conv_37_ptr = untag_ptr(_res_conv_37);
17987                 CHECK_ACCESS(_res_conv_37_ptr);
17988                 LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_conv_37_ptr);
17989                 FREE(untag_ptr(_res_conv_37));
17990                 _res_constr.data[l] = _res_conv_37_conv;
17991         }
17992         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17993         CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res_constr);
17994 }
17995
17996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17997         LDKCVec_RouteHintZ _res_constr;
17998         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17999         if (_res_constr.datalen > 0)
18000                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18001         else
18002                 _res_constr.data = NULL;
18003         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18004         for (size_t l = 0; l < _res_constr.datalen; l++) {
18005                 int64_t _res_conv_11 = _res_vals[l];
18006                 LDKRouteHint _res_conv_11_conv;
18007                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
18008                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
18009                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
18010                 _res_constr.data[l] = _res_conv_11_conv;
18011         }
18012         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18013         CVec_RouteHintZ_free(_res_constr);
18014 }
18015
18016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18017         LDKCVec_RouteHintHopZ _res_constr;
18018         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18019         if (_res_constr.datalen > 0)
18020                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
18021         else
18022                 _res_constr.data = NULL;
18023         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18024         for (size_t o = 0; o < _res_constr.datalen; o++) {
18025                 int64_t _res_conv_14 = _res_vals[o];
18026                 LDKRouteHintHop _res_conv_14_conv;
18027                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
18028                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
18029                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18030                 _res_constr.data[o] = _res_conv_14_conv;
18031         }
18032         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18033         CVec_RouteHintHopZ_free(_res_constr);
18034 }
18035
18036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18037         LDKRouteHint o_conv;
18038         o_conv.inner = untag_ptr(o);
18039         o_conv.is_owned = ptr_is_owned(o);
18040         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18041         o_conv = RouteHint_clone(&o_conv);
18042         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18043         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
18044         return tag_ptr(ret_conv, true);
18045 }
18046
18047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18048         void* e_ptr = untag_ptr(e);
18049         CHECK_ACCESS(e_ptr);
18050         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18051         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18052         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18053         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
18054         return tag_ptr(ret_conv, true);
18055 }
18056
18057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18058         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
18059         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
18060         return ret_conv;
18061 }
18062
18063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18064         if (!ptr_is_owned(_res)) return;
18065         void* _res_ptr = untag_ptr(_res);
18066         CHECK_ACCESS(_res_ptr);
18067         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
18068         FREE(untag_ptr(_res));
18069         CResult_RouteHintDecodeErrorZ_free(_res_conv);
18070 }
18071
18072 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
18073         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18074         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
18075         return tag_ptr(ret_conv, true);
18076 }
18077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18078         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
18079         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
18080         return ret_conv;
18081 }
18082
18083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18084         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
18085         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18086         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
18087         return tag_ptr(ret_conv, true);
18088 }
18089
18090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18091         LDKRouteHintHop o_conv;
18092         o_conv.inner = untag_ptr(o);
18093         o_conv.is_owned = ptr_is_owned(o);
18094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18095         o_conv = RouteHintHop_clone(&o_conv);
18096         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18097         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
18098         return tag_ptr(ret_conv, true);
18099 }
18100
18101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18102         void* e_ptr = untag_ptr(e);
18103         CHECK_ACCESS(e_ptr);
18104         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18105         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18106         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18107         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
18108         return tag_ptr(ret_conv, true);
18109 }
18110
18111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18112         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
18113         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
18114         return ret_conv;
18115 }
18116
18117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18118         if (!ptr_is_owned(_res)) return;
18119         void* _res_ptr = untag_ptr(_res);
18120         CHECK_ACCESS(_res_ptr);
18121         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
18122         FREE(untag_ptr(_res));
18123         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
18124 }
18125
18126 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
18127         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18128         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
18129         return tag_ptr(ret_conv, true);
18130 }
18131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18132         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
18133         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
18134         return ret_conv;
18135 }
18136
18137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18138         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
18139         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18140         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
18141         return tag_ptr(ret_conv, true);
18142 }
18143
18144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18145         LDKCVec_PublicKeyZ _res_constr;
18146         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18147         if (_res_constr.datalen > 0)
18148                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
18149         else
18150                 _res_constr.data = NULL;
18151         for (size_t i = 0; i < _res_constr.datalen; i++) {
18152                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18153                 LDKPublicKey _res_conv_8_ref;
18154                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
18155                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
18156                 _res_constr.data[i] = _res_conv_8_ref;
18157         }
18158         CVec_PublicKeyZ_free(_res_constr);
18159 }
18160
18161 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18162         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18163         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18164         return tag_ptr(ret_conv, true);
18165 }
18166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18167         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18168         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18169         return ret_conv;
18170 }
18171
18172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18173         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18174         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18175         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18176         return tag_ptr(ret_conv, true);
18177 }
18178
18179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18180         LDKTransaction b_ref;
18181         b_ref.datalen = (*env)->GetArrayLength(env, b);
18182         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18183         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18184         b_ref.data_is_owned = true;
18185         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18186         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18187         return tag_ptr(ret_conv, true);
18188 }
18189
18190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18191         if (!ptr_is_owned(_res)) return;
18192         void* _res_ptr = untag_ptr(_res);
18193         CHECK_ACCESS(_res_ptr);
18194         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18195         FREE(untag_ptr(_res));
18196         C2Tuple_usizeTransactionZ_free(_res_conv);
18197 }
18198
18199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18200         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18201         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18202         if (_res_constr.datalen > 0)
18203                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18204         else
18205                 _res_constr.data = NULL;
18206         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18207         for (size_t c = 0; c < _res_constr.datalen; c++) {
18208                 int64_t _res_conv_28 = _res_vals[c];
18209                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18210                 CHECK_ACCESS(_res_conv_28_ptr);
18211                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18212                 FREE(untag_ptr(_res_conv_28));
18213                 _res_constr.data[c] = _res_conv_28_conv;
18214         }
18215         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18216         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18217 }
18218
18219 static inline uint64_t C2Tuple_TxidBlockHashZ_clone_ptr(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR arg) {
18220         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18221         *ret_conv = C2Tuple_TxidBlockHashZ_clone(arg);
18222         return tag_ptr(ret_conv, true);
18223 }
18224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18225         LDKC2Tuple_TxidBlockHashZ* arg_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(arg);
18226         int64_t ret_conv = C2Tuple_TxidBlockHashZ_clone_ptr(arg_conv);
18227         return ret_conv;
18228 }
18229
18230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18231         LDKC2Tuple_TxidBlockHashZ* orig_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(orig);
18232         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18233         *ret_conv = C2Tuple_TxidBlockHashZ_clone(orig_conv);
18234         return tag_ptr(ret_conv, true);
18235 }
18236
18237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18238         LDKThirtyTwoBytes a_ref;
18239         CHECK((*env)->GetArrayLength(env, a) == 32);
18240         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18241         LDKThirtyTwoBytes b_ref;
18242         CHECK((*env)->GetArrayLength(env, b) == 32);
18243         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18244         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18245         *ret_conv = C2Tuple_TxidBlockHashZ_new(a_ref, b_ref);
18246         return tag_ptr(ret_conv, true);
18247 }
18248
18249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18250         if (!ptr_is_owned(_res)) return;
18251         void* _res_ptr = untag_ptr(_res);
18252         CHECK_ACCESS(_res_ptr);
18253         LDKC2Tuple_TxidBlockHashZ _res_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_ptr);
18254         FREE(untag_ptr(_res));
18255         C2Tuple_TxidBlockHashZ_free(_res_conv);
18256 }
18257
18258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidBlockHashZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18259         LDKCVec_C2Tuple_TxidBlockHashZZ _res_constr;
18260         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18261         if (_res_constr.datalen > 0)
18262                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
18263         else
18264                 _res_constr.data = NULL;
18265         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18266         for (size_t z = 0; z < _res_constr.datalen; z++) {
18267                 int64_t _res_conv_25 = _res_vals[z];
18268                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18269                 CHECK_ACCESS(_res_conv_25_ptr);
18270                 LDKC2Tuple_TxidBlockHashZ _res_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_conv_25_ptr);
18271                 FREE(untag_ptr(_res_conv_25));
18272                 _res_constr.data[z] = _res_conv_25_conv;
18273         }
18274         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18275         CVec_C2Tuple_TxidBlockHashZZ_free(_res_constr);
18276 }
18277
18278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18279         LDKCVec_MonitorEventZ _res_constr;
18280         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18281         if (_res_constr.datalen > 0)
18282                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18283         else
18284                 _res_constr.data = NULL;
18285         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18286         for (size_t o = 0; o < _res_constr.datalen; o++) {
18287                 int64_t _res_conv_14 = _res_vals[o];
18288                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18289                 CHECK_ACCESS(_res_conv_14_ptr);
18290                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18291                 FREE(untag_ptr(_res_conv_14));
18292                 _res_constr.data[o] = _res_conv_14_conv;
18293         }
18294         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18295         CVec_MonitorEventZ_free(_res_constr);
18296 }
18297
18298 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18299         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18300         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18301         return tag_ptr(ret_conv, true);
18302 }
18303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18304         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18305         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18306         return ret_conv;
18307 }
18308
18309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18310         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18311         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18312         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18313         return tag_ptr(ret_conv, true);
18314 }
18315
18316 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) {
18317         LDKOutPoint a_conv;
18318         a_conv.inner = untag_ptr(a);
18319         a_conv.is_owned = ptr_is_owned(a);
18320         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18321         a_conv = OutPoint_clone(&a_conv);
18322         LDKCVec_MonitorEventZ b_constr;
18323         b_constr.datalen = (*env)->GetArrayLength(env, b);
18324         if (b_constr.datalen > 0)
18325                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18326         else
18327                 b_constr.data = NULL;
18328         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18329         for (size_t o = 0; o < b_constr.datalen; o++) {
18330                 int64_t b_conv_14 = b_vals[o];
18331                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18332                 CHECK_ACCESS(b_conv_14_ptr);
18333                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18334                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18335                 b_constr.data[o] = b_conv_14_conv;
18336         }
18337         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18338         LDKPublicKey c_ref;
18339         CHECK((*env)->GetArrayLength(env, c) == 33);
18340         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
18341         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18342         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18343         return tag_ptr(ret_conv, true);
18344 }
18345
18346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18347         if (!ptr_is_owned(_res)) return;
18348         void* _res_ptr = untag_ptr(_res);
18349         CHECK_ACCESS(_res_ptr);
18350         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18351         FREE(untag_ptr(_res));
18352         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18353 }
18354
18355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18356         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18357         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18358         if (_res_constr.datalen > 0)
18359                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18360         else
18361                 _res_constr.data = NULL;
18362         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18363         for (size_t x = 0; x < _res_constr.datalen; x++) {
18364                 int64_t _res_conv_49 = _res_vals[x];
18365                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18366                 CHECK_ACCESS(_res_conv_49_ptr);
18367                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18368                 FREE(untag_ptr(_res_conv_49));
18369                 _res_constr.data[x] = _res_conv_49_conv;
18370         }
18371         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18372         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18373 }
18374
18375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18376         LDKFixedPenaltyScorer o_conv;
18377         o_conv.inner = untag_ptr(o);
18378         o_conv.is_owned = ptr_is_owned(o);
18379         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18380         o_conv = FixedPenaltyScorer_clone(&o_conv);
18381         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18382         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18383         return tag_ptr(ret_conv, true);
18384 }
18385
18386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18387         void* e_ptr = untag_ptr(e);
18388         CHECK_ACCESS(e_ptr);
18389         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18390         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18391         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18392         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18393         return tag_ptr(ret_conv, true);
18394 }
18395
18396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18397         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18398         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18399         return ret_conv;
18400 }
18401
18402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18403         if (!ptr_is_owned(_res)) return;
18404         void* _res_ptr = untag_ptr(_res);
18405         CHECK_ACCESS(_res_ptr);
18406         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18407         FREE(untag_ptr(_res));
18408         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18409 }
18410
18411 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18412         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18413         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18414         return tag_ptr(ret_conv, true);
18415 }
18416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18417         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18418         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18419         return ret_conv;
18420 }
18421
18422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18423         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18424         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18425         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18426         return tag_ptr(ret_conv, true);
18427 }
18428
18429 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18430         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18431         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18432         return tag_ptr(ret_conv, true);
18433 }
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18435         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18436         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18437         return ret_conv;
18438 }
18439
18440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18441         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18442         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18443         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18444         return tag_ptr(ret_conv, true);
18445 }
18446
18447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18448         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18449         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18450         return tag_ptr(ret_conv, true);
18451 }
18452
18453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18454         if (!ptr_is_owned(_res)) return;
18455         void* _res_ptr = untag_ptr(_res);
18456         CHECK_ACCESS(_res_ptr);
18457         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18458         FREE(untag_ptr(_res));
18459         C2Tuple_u64u64Z_free(_res_conv);
18460 }
18461
18462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18463         void* o_ptr = untag_ptr(o);
18464         CHECK_ACCESS(o_ptr);
18465         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18466         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18467         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18468         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18469         int64_t ret_ref = tag_ptr(ret_copy, true);
18470         return ret_ref;
18471 }
18472
18473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
18474         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18475         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18476         int64_t ret_ref = tag_ptr(ret_copy, true);
18477         return ret_ref;
18478 }
18479
18480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18481         if (!ptr_is_owned(_res)) return;
18482         void* _res_ptr = untag_ptr(_res);
18483         CHECK_ACCESS(_res_ptr);
18484         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18485         FREE(untag_ptr(_res));
18486         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18487 }
18488
18489 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18490         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18491         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18492         int64_t ret_ref = tag_ptr(ret_copy, true);
18493         return ret_ref;
18494 }
18495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18496         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18497         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18498         return ret_conv;
18499 }
18500
18501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18502         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18503         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18504         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18505         int64_t ret_ref = tag_ptr(ret_copy, true);
18506         return ret_ref;
18507 }
18508
18509 static inline uint64_t C2Tuple_Z_clone_ptr(LDKC2Tuple_Z *NONNULL_PTR arg) {
18510         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18511         *ret_conv = C2Tuple_Z_clone(arg);
18512         return tag_ptr(ret_conv, true);
18513 }
18514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18515         LDKC2Tuple_Z* arg_conv = (LDKC2Tuple_Z*)untag_ptr(arg);
18516         int64_t ret_conv = C2Tuple_Z_clone_ptr(arg_conv);
18517         return ret_conv;
18518 }
18519
18520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18521         LDKC2Tuple_Z* orig_conv = (LDKC2Tuple_Z*)untag_ptr(orig);
18522         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18523         *ret_conv = C2Tuple_Z_clone(orig_conv);
18524         return tag_ptr(ret_conv, true);
18525 }
18526
18527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18528         LDKEightU16s a_ref;
18529         CHECK((*env)->GetArrayLength(env, a) == 8);
18530         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18531         LDKEightU16s b_ref;
18532         CHECK((*env)->GetArrayLength(env, b) == 8);
18533         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18534         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18535         *ret_conv = C2Tuple_Z_new(a_ref, b_ref);
18536         return tag_ptr(ret_conv, true);
18537 }
18538
18539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18540         if (!ptr_is_owned(_res)) return;
18541         void* _res_ptr = untag_ptr(_res);
18542         CHECK_ACCESS(_res_ptr);
18543         LDKC2Tuple_Z _res_conv = *(LDKC2Tuple_Z*)(_res_ptr);
18544         FREE(untag_ptr(_res));
18545         C2Tuple_Z_free(_res_conv);
18546 }
18547
18548 static inline uint64_t C2Tuple__u168_u168Z_clone_ptr(LDKC2Tuple__u168_u168Z *NONNULL_PTR arg) {
18549         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18550         *ret_conv = C2Tuple__u168_u168Z_clone(arg);
18551         return tag_ptr(ret_conv, true);
18552 }
18553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18554         LDKC2Tuple__u168_u168Z* arg_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(arg);
18555         int64_t ret_conv = C2Tuple__u168_u168Z_clone_ptr(arg_conv);
18556         return ret_conv;
18557 }
18558
18559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18560         LDKC2Tuple__u168_u168Z* orig_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(orig);
18561         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18562         *ret_conv = C2Tuple__u168_u168Z_clone(orig_conv);
18563         return tag_ptr(ret_conv, true);
18564 }
18565
18566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18567         LDKEightU16s a_ref;
18568         CHECK((*env)->GetArrayLength(env, a) == 8);
18569         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18570         LDKEightU16s b_ref;
18571         CHECK((*env)->GetArrayLength(env, b) == 8);
18572         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18573         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18574         *ret_conv = C2Tuple__u168_u168Z_new(a_ref, b_ref);
18575         return tag_ptr(ret_conv, true);
18576 }
18577
18578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18579         if (!ptr_is_owned(_res)) return;
18580         void* _res_ptr = untag_ptr(_res);
18581         CHECK_ACCESS(_res_ptr);
18582         LDKC2Tuple__u168_u168Z _res_conv = *(LDKC2Tuple__u168_u168Z*)(_res_ptr);
18583         FREE(untag_ptr(_res));
18584         C2Tuple__u168_u168Z_free(_res_conv);
18585 }
18586
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18588         void* o_ptr = untag_ptr(o);
18589         CHECK_ACCESS(o_ptr);
18590         LDKC2Tuple__u168_u168Z o_conv = *(LDKC2Tuple__u168_u168Z*)(o_ptr);
18591         o_conv = C2Tuple__u168_u168Z_clone((LDKC2Tuple__u168_u168Z*)untag_ptr(o));
18592         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18593         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_some(o_conv);
18594         int64_t ret_ref = tag_ptr(ret_copy, true);
18595         return ret_ref;
18596 }
18597
18598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1none(JNIEnv *env, jclass clz) {
18599         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18600         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_none();
18601         int64_t ret_ref = tag_ptr(ret_copy, true);
18602         return ret_ref;
18603 }
18604
18605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18606         if (!ptr_is_owned(_res)) return;
18607         void* _res_ptr = untag_ptr(_res);
18608         CHECK_ACCESS(_res_ptr);
18609         LDKCOption_C2Tuple_EightU16sEightU16sZZ _res_conv = *(LDKCOption_C2Tuple_EightU16sEightU16sZZ*)(_res_ptr);
18610         FREE(untag_ptr(_res));
18611         COption_C2Tuple_EightU16sEightU16sZZ_free(_res_conv);
18612 }
18613
18614 static inline uint64_t COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(LDKCOption_C2Tuple_EightU16sEightU16sZZ *NONNULL_PTR arg) {
18615         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18616         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(arg);
18617         int64_t ret_ref = tag_ptr(ret_copy, true);
18618         return ret_ref;
18619 }
18620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18621         LDKCOption_C2Tuple_EightU16sEightU16sZZ* arg_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(arg);
18622         int64_t ret_conv = COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(arg_conv);
18623         return ret_conv;
18624 }
18625
18626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18627         LDKCOption_C2Tuple_EightU16sEightU16sZZ* orig_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(orig);
18628         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18629         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(orig_conv);
18630         int64_t ret_ref = tag_ptr(ret_copy, true);
18631         return ret_ref;
18632 }
18633
18634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18635         LDKCVec_NodeIdZ _res_constr;
18636         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18637         if (_res_constr.datalen > 0)
18638                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18639         else
18640                 _res_constr.data = NULL;
18641         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18642         for (size_t i = 0; i < _res_constr.datalen; i++) {
18643                 int64_t _res_conv_8 = _res_vals[i];
18644                 LDKNodeId _res_conv_8_conv;
18645                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18646                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18648                 _res_constr.data[i] = _res_conv_8_conv;
18649         }
18650         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18651         CVec_NodeIdZ_free(_res_constr);
18652 }
18653
18654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18655         LDKProbabilisticScorer o_conv;
18656         o_conv.inner = untag_ptr(o);
18657         o_conv.is_owned = ptr_is_owned(o);
18658         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18659         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18660         
18661         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18662         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18663         return tag_ptr(ret_conv, true);
18664 }
18665
18666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18667         void* e_ptr = untag_ptr(e);
18668         CHECK_ACCESS(e_ptr);
18669         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18670         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18671         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18672         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18673         return tag_ptr(ret_conv, true);
18674 }
18675
18676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18677         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18678         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18679         return ret_conv;
18680 }
18681
18682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18683         if (!ptr_is_owned(_res)) return;
18684         void* _res_ptr = untag_ptr(_res);
18685         CHECK_ACCESS(_res_ptr);
18686         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18687         FREE(untag_ptr(_res));
18688         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18689 }
18690
18691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18692         LDKInitFeatures o_conv;
18693         o_conv.inner = untag_ptr(o);
18694         o_conv.is_owned = ptr_is_owned(o);
18695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18696         o_conv = InitFeatures_clone(&o_conv);
18697         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18698         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18699         return tag_ptr(ret_conv, true);
18700 }
18701
18702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18703         void* e_ptr = untag_ptr(e);
18704         CHECK_ACCESS(e_ptr);
18705         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18706         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18707         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18708         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18709         return tag_ptr(ret_conv, true);
18710 }
18711
18712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18713         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18714         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18715         return ret_conv;
18716 }
18717
18718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18719         if (!ptr_is_owned(_res)) return;
18720         void* _res_ptr = untag_ptr(_res);
18721         CHECK_ACCESS(_res_ptr);
18722         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18723         FREE(untag_ptr(_res));
18724         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18725 }
18726
18727 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18728         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18729         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18730         return tag_ptr(ret_conv, true);
18731 }
18732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18733         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18734         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18735         return ret_conv;
18736 }
18737
18738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18739         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18740         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18741         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18742         return tag_ptr(ret_conv, true);
18743 }
18744
18745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18746         LDKChannelFeatures o_conv;
18747         o_conv.inner = untag_ptr(o);
18748         o_conv.is_owned = ptr_is_owned(o);
18749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18750         o_conv = ChannelFeatures_clone(&o_conv);
18751         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18752         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18753         return tag_ptr(ret_conv, true);
18754 }
18755
18756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18757         void* e_ptr = untag_ptr(e);
18758         CHECK_ACCESS(e_ptr);
18759         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18760         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18761         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18762         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18763         return tag_ptr(ret_conv, true);
18764 }
18765
18766 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18767         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18768         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18769         return ret_conv;
18770 }
18771
18772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18773         if (!ptr_is_owned(_res)) return;
18774         void* _res_ptr = untag_ptr(_res);
18775         CHECK_ACCESS(_res_ptr);
18776         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18777         FREE(untag_ptr(_res));
18778         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18779 }
18780
18781 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18782         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18783         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18784         return tag_ptr(ret_conv, true);
18785 }
18786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18787         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18788         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18789         return ret_conv;
18790 }
18791
18792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18793         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18794         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18795         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18796         return tag_ptr(ret_conv, true);
18797 }
18798
18799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18800         LDKNodeFeatures o_conv;
18801         o_conv.inner = untag_ptr(o);
18802         o_conv.is_owned = ptr_is_owned(o);
18803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18804         o_conv = NodeFeatures_clone(&o_conv);
18805         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18806         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18807         return tag_ptr(ret_conv, true);
18808 }
18809
18810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18811         void* e_ptr = untag_ptr(e);
18812         CHECK_ACCESS(e_ptr);
18813         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18814         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18815         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18816         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18817         return tag_ptr(ret_conv, true);
18818 }
18819
18820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18821         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18822         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18823         return ret_conv;
18824 }
18825
18826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18827         if (!ptr_is_owned(_res)) return;
18828         void* _res_ptr = untag_ptr(_res);
18829         CHECK_ACCESS(_res_ptr);
18830         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18831         FREE(untag_ptr(_res));
18832         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18833 }
18834
18835 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18836         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18837         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18838         return tag_ptr(ret_conv, true);
18839 }
18840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18841         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18842         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18843         return ret_conv;
18844 }
18845
18846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18847         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18848         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18849         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18850         return tag_ptr(ret_conv, true);
18851 }
18852
18853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18854         LDKInvoiceFeatures o_conv;
18855         o_conv.inner = untag_ptr(o);
18856         o_conv.is_owned = ptr_is_owned(o);
18857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18858         o_conv = InvoiceFeatures_clone(&o_conv);
18859         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18860         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18861         return tag_ptr(ret_conv, true);
18862 }
18863
18864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18865         void* e_ptr = untag_ptr(e);
18866         CHECK_ACCESS(e_ptr);
18867         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18868         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18869         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18870         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18871         return tag_ptr(ret_conv, true);
18872 }
18873
18874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18875         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18876         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18877         return ret_conv;
18878 }
18879
18880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18881         if (!ptr_is_owned(_res)) return;
18882         void* _res_ptr = untag_ptr(_res);
18883         CHECK_ACCESS(_res_ptr);
18884         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18885         FREE(untag_ptr(_res));
18886         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18887 }
18888
18889 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18890         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18891         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18892         return tag_ptr(ret_conv, true);
18893 }
18894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18895         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18896         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18897         return ret_conv;
18898 }
18899
18900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18901         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18902         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18903         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18904         return tag_ptr(ret_conv, true);
18905 }
18906
18907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18908         LDKBlindedHopFeatures o_conv;
18909         o_conv.inner = untag_ptr(o);
18910         o_conv.is_owned = ptr_is_owned(o);
18911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18912         o_conv = BlindedHopFeatures_clone(&o_conv);
18913         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18914         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_ok(o_conv);
18915         return tag_ptr(ret_conv, true);
18916 }
18917
18918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18919         void* e_ptr = untag_ptr(e);
18920         CHECK_ACCESS(e_ptr);
18921         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18922         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18923         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18924         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_err(e_conv);
18925         return tag_ptr(ret_conv, true);
18926 }
18927
18928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18929         LDKCResult_BlindedHopFeaturesDecodeErrorZ* o_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(o);
18930         jboolean ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o_conv);
18931         return ret_conv;
18932 }
18933
18934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18935         if (!ptr_is_owned(_res)) return;
18936         void* _res_ptr = untag_ptr(_res);
18937         CHECK_ACCESS(_res_ptr);
18938         LDKCResult_BlindedHopFeaturesDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopFeaturesDecodeErrorZ*)(_res_ptr);
18939         FREE(untag_ptr(_res));
18940         CResult_BlindedHopFeaturesDecodeErrorZ_free(_res_conv);
18941 }
18942
18943 static inline uint64_t CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18944         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18945         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(arg);
18946         return tag_ptr(ret_conv, true);
18947 }
18948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18949         LDKCResult_BlindedHopFeaturesDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(arg);
18950         int64_t ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18951         return ret_conv;
18952 }
18953
18954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18955         LDKCResult_BlindedHopFeaturesDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(orig);
18956         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18957         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig_conv);
18958         return tag_ptr(ret_conv, true);
18959 }
18960
18961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18962         LDKChannelTypeFeatures o_conv;
18963         o_conv.inner = untag_ptr(o);
18964         o_conv.is_owned = ptr_is_owned(o);
18965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18966         o_conv = ChannelTypeFeatures_clone(&o_conv);
18967         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18968         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18969         return tag_ptr(ret_conv, true);
18970 }
18971
18972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18973         void* e_ptr = untag_ptr(e);
18974         CHECK_ACCESS(e_ptr);
18975         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18976         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18977         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18978         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18979         return tag_ptr(ret_conv, true);
18980 }
18981
18982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18983         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18984         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18985         return ret_conv;
18986 }
18987
18988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18989         if (!ptr_is_owned(_res)) return;
18990         void* _res_ptr = untag_ptr(_res);
18991         CHECK_ACCESS(_res_ptr);
18992         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18993         FREE(untag_ptr(_res));
18994         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18995 }
18996
18997 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18998         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18999         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
19000         return tag_ptr(ret_conv, true);
19001 }
19002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19003         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
19004         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19005         return ret_conv;
19006 }
19007
19008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19009         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
19010         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19011         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
19012         return tag_ptr(ret_conv, true);
19013 }
19014
19015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19016         void* o_ptr = untag_ptr(o);
19017         CHECK_ACCESS(o_ptr);
19018         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
19019         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
19020         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19021         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
19022         return tag_ptr(ret_conv, true);
19023 }
19024
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19026         void* e_ptr = untag_ptr(e);
19027         CHECK_ACCESS(e_ptr);
19028         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19029         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19030         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19031         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
19032         return tag_ptr(ret_conv, true);
19033 }
19034
19035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19036         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
19037         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
19038         return ret_conv;
19039 }
19040
19041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19042         if (!ptr_is_owned(_res)) return;
19043         void* _res_ptr = untag_ptr(_res);
19044         CHECK_ACCESS(_res_ptr);
19045         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
19046         FREE(untag_ptr(_res));
19047         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
19048 }
19049
19050 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
19051         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19052         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
19053         return tag_ptr(ret_conv, true);
19054 }
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19056         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
19057         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
19058         return ret_conv;
19059 }
19060
19061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19062         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
19063         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19064         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
19065         return tag_ptr(ret_conv, true);
19066 }
19067
19068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19069         void* o_ptr = untag_ptr(o);
19070         CHECK_ACCESS(o_ptr);
19071         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
19072         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
19073         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19074         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
19075         int64_t ret_ref = tag_ptr(ret_copy, true);
19076         return ret_ref;
19077 }
19078
19079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
19080         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19081         *ret_copy = COption_NetworkUpdateZ_none();
19082         int64_t ret_ref = tag_ptr(ret_copy, true);
19083         return ret_ref;
19084 }
19085
19086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19087         if (!ptr_is_owned(_res)) return;
19088         void* _res_ptr = untag_ptr(_res);
19089         CHECK_ACCESS(_res_ptr);
19090         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
19091         FREE(untag_ptr(_res));
19092         COption_NetworkUpdateZ_free(_res_conv);
19093 }
19094
19095 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
19096         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19097         *ret_copy = COption_NetworkUpdateZ_clone(arg);
19098         int64_t ret_ref = tag_ptr(ret_copy, true);
19099         return ret_ref;
19100 }
19101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19102         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
19103         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
19104         return ret_conv;
19105 }
19106
19107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19108         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
19109         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19110         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
19111         int64_t ret_ref = tag_ptr(ret_copy, true);
19112         return ret_ref;
19113 }
19114
19115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19116         void* o_ptr = untag_ptr(o);
19117         CHECK_ACCESS(o_ptr);
19118         LDKPathFailure o_conv = *(LDKPathFailure*)(o_ptr);
19119         o_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(o));
19120         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19121         *ret_copy = COption_PathFailureZ_some(o_conv);
19122         int64_t ret_ref = tag_ptr(ret_copy, true);
19123         return ret_ref;
19124 }
19125
19126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1none(JNIEnv *env, jclass clz) {
19127         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19128         *ret_copy = COption_PathFailureZ_none();
19129         int64_t ret_ref = tag_ptr(ret_copy, true);
19130         return ret_ref;
19131 }
19132
19133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19134         if (!ptr_is_owned(_res)) return;
19135         void* _res_ptr = untag_ptr(_res);
19136         CHECK_ACCESS(_res_ptr);
19137         LDKCOption_PathFailureZ _res_conv = *(LDKCOption_PathFailureZ*)(_res_ptr);
19138         FREE(untag_ptr(_res));
19139         COption_PathFailureZ_free(_res_conv);
19140 }
19141
19142 static inline uint64_t COption_PathFailureZ_clone_ptr(LDKCOption_PathFailureZ *NONNULL_PTR arg) {
19143         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19144         *ret_copy = COption_PathFailureZ_clone(arg);
19145         int64_t ret_ref = tag_ptr(ret_copy, true);
19146         return ret_ref;
19147 }
19148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19149         LDKCOption_PathFailureZ* arg_conv = (LDKCOption_PathFailureZ*)untag_ptr(arg);
19150         int64_t ret_conv = COption_PathFailureZ_clone_ptr(arg_conv);
19151         return ret_conv;
19152 }
19153
19154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19155         LDKCOption_PathFailureZ* orig_conv = (LDKCOption_PathFailureZ*)untag_ptr(orig);
19156         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19157         *ret_copy = COption_PathFailureZ_clone(orig_conv);
19158         int64_t ret_ref = tag_ptr(ret_copy, true);
19159         return ret_ref;
19160 }
19161
19162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19163         void* o_ptr = untag_ptr(o);
19164         CHECK_ACCESS(o_ptr);
19165         LDKCOption_PathFailureZ o_conv = *(LDKCOption_PathFailureZ*)(o_ptr);
19166         o_conv = COption_PathFailureZ_clone((LDKCOption_PathFailureZ*)untag_ptr(o));
19167         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19168         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_ok(o_conv);
19169         return tag_ptr(ret_conv, true);
19170 }
19171
19172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19173         void* e_ptr = untag_ptr(e);
19174         CHECK_ACCESS(e_ptr);
19175         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19176         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19177         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19178         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_err(e_conv);
19179         return tag_ptr(ret_conv, true);
19180 }
19181
19182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19183         LDKCResult_COption_PathFailureZDecodeErrorZ* o_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(o);
19184         jboolean ret_conv = CResult_COption_PathFailureZDecodeErrorZ_is_ok(o_conv);
19185         return ret_conv;
19186 }
19187
19188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19189         if (!ptr_is_owned(_res)) return;
19190         void* _res_ptr = untag_ptr(_res);
19191         CHECK_ACCESS(_res_ptr);
19192         LDKCResult_COption_PathFailureZDecodeErrorZ _res_conv = *(LDKCResult_COption_PathFailureZDecodeErrorZ*)(_res_ptr);
19193         FREE(untag_ptr(_res));
19194         CResult_COption_PathFailureZDecodeErrorZ_free(_res_conv);
19195 }
19196
19197 static inline uint64_t CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR arg) {
19198         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19199         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(arg);
19200         return tag_ptr(ret_conv, true);
19201 }
19202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19203         LDKCResult_COption_PathFailureZDecodeErrorZ* arg_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(arg);
19204         int64_t ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(arg_conv);
19205         return ret_conv;
19206 }
19207
19208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19209         LDKCResult_COption_PathFailureZDecodeErrorZ* orig_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(orig);
19210         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19211         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(orig_conv);
19212         return tag_ptr(ret_conv, true);
19213 }
19214
19215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19216         void* o_ptr = untag_ptr(o);
19217         CHECK_ACCESS(o_ptr);
19218         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
19219         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
19220         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19221         *ret_copy = COption_ClosureReasonZ_some(o_conv);
19222         int64_t ret_ref = tag_ptr(ret_copy, true);
19223         return ret_ref;
19224 }
19225
19226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
19227         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19228         *ret_copy = COption_ClosureReasonZ_none();
19229         int64_t ret_ref = tag_ptr(ret_copy, true);
19230         return ret_ref;
19231 }
19232
19233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19234         if (!ptr_is_owned(_res)) return;
19235         void* _res_ptr = untag_ptr(_res);
19236         CHECK_ACCESS(_res_ptr);
19237         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
19238         FREE(untag_ptr(_res));
19239         COption_ClosureReasonZ_free(_res_conv);
19240 }
19241
19242 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
19243         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19244         *ret_copy = COption_ClosureReasonZ_clone(arg);
19245         int64_t ret_ref = tag_ptr(ret_copy, true);
19246         return ret_ref;
19247 }
19248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19249         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
19250         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
19251         return ret_conv;
19252 }
19253
19254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19255         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
19256         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19257         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
19258         int64_t ret_ref = tag_ptr(ret_copy, true);
19259         return ret_ref;
19260 }
19261
19262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19263         void* o_ptr = untag_ptr(o);
19264         CHECK_ACCESS(o_ptr);
19265         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
19266         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
19267         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19268         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
19269         return tag_ptr(ret_conv, true);
19270 }
19271
19272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19273         void* e_ptr = untag_ptr(e);
19274         CHECK_ACCESS(e_ptr);
19275         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19276         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19277         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19278         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
19279         return tag_ptr(ret_conv, true);
19280 }
19281
19282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19283         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
19284         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
19285         return ret_conv;
19286 }
19287
19288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19289         if (!ptr_is_owned(_res)) return;
19290         void* _res_ptr = untag_ptr(_res);
19291         CHECK_ACCESS(_res_ptr);
19292         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
19293         FREE(untag_ptr(_res));
19294         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
19295 }
19296
19297 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
19298         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19299         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
19300         return tag_ptr(ret_conv, true);
19301 }
19302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19303         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
19304         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
19305         return ret_conv;
19306 }
19307
19308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19309         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
19310         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19311         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
19312         return tag_ptr(ret_conv, true);
19313 }
19314
19315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19316         void* o_ptr = untag_ptr(o);
19317         CHECK_ACCESS(o_ptr);
19318         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
19319         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
19320         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19321         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
19322         int64_t ret_ref = tag_ptr(ret_copy, true);
19323         return ret_ref;
19324 }
19325
19326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
19327         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19328         *ret_copy = COption_HTLCDestinationZ_none();
19329         int64_t ret_ref = tag_ptr(ret_copy, true);
19330         return ret_ref;
19331 }
19332
19333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19334         if (!ptr_is_owned(_res)) return;
19335         void* _res_ptr = untag_ptr(_res);
19336         CHECK_ACCESS(_res_ptr);
19337         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
19338         FREE(untag_ptr(_res));
19339         COption_HTLCDestinationZ_free(_res_conv);
19340 }
19341
19342 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
19343         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19344         *ret_copy = COption_HTLCDestinationZ_clone(arg);
19345         int64_t ret_ref = tag_ptr(ret_copy, true);
19346         return ret_ref;
19347 }
19348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19349         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
19350         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
19351         return ret_conv;
19352 }
19353
19354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19355         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
19356         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19357         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
19358         int64_t ret_ref = tag_ptr(ret_copy, true);
19359         return ret_ref;
19360 }
19361
19362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19363         void* o_ptr = untag_ptr(o);
19364         CHECK_ACCESS(o_ptr);
19365         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
19366         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
19367         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19368         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
19369         return tag_ptr(ret_conv, true);
19370 }
19371
19372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19373         void* e_ptr = untag_ptr(e);
19374         CHECK_ACCESS(e_ptr);
19375         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19376         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19377         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19378         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
19379         return tag_ptr(ret_conv, true);
19380 }
19381
19382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19383         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
19384         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
19385         return ret_conv;
19386 }
19387
19388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19389         if (!ptr_is_owned(_res)) return;
19390         void* _res_ptr = untag_ptr(_res);
19391         CHECK_ACCESS(_res_ptr);
19392         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
19393         FREE(untag_ptr(_res));
19394         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
19395 }
19396
19397 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
19398         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19399         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
19400         return tag_ptr(ret_conv, true);
19401 }
19402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19403         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
19404         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
19405         return ret_conv;
19406 }
19407
19408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19409         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
19410         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19411         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
19412         return tag_ptr(ret_conv, true);
19413 }
19414
19415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
19416         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_java(env, o);
19417         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19418         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_ok(o_conv);
19419         return tag_ptr(ret_conv, true);
19420 }
19421
19422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19423         void* e_ptr = untag_ptr(e);
19424         CHECK_ACCESS(e_ptr);
19425         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19426         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19427         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19428         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_err(e_conv);
19429         return tag_ptr(ret_conv, true);
19430 }
19431
19432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19433         LDKCResult_PaymentFailureReasonDecodeErrorZ* o_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(o);
19434         jboolean ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o_conv);
19435         return ret_conv;
19436 }
19437
19438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19439         if (!ptr_is_owned(_res)) return;
19440         void* _res_ptr = untag_ptr(_res);
19441         CHECK_ACCESS(_res_ptr);
19442         LDKCResult_PaymentFailureReasonDecodeErrorZ _res_conv = *(LDKCResult_PaymentFailureReasonDecodeErrorZ*)(_res_ptr);
19443         FREE(untag_ptr(_res));
19444         CResult_PaymentFailureReasonDecodeErrorZ_free(_res_conv);
19445 }
19446
19447 static inline uint64_t CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR arg) {
19448         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19449         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(arg);
19450         return tag_ptr(ret_conv, true);
19451 }
19452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19453         LDKCResult_PaymentFailureReasonDecodeErrorZ* arg_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(arg);
19454         int64_t ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(arg_conv);
19455         return ret_conv;
19456 }
19457
19458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19459         LDKCResult_PaymentFailureReasonDecodeErrorZ* orig_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(orig);
19460         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19461         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(orig_conv);
19462         return tag_ptr(ret_conv, true);
19463 }
19464
19465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1some(JNIEnv *env, jclass clz, int8_tArray o) {
19466         LDKU128 o_ref;
19467         CHECK((*env)->GetArrayLength(env, o) == 16);
19468         (*env)->GetByteArrayRegion(env, o, 0, 16, o_ref.le_bytes);
19469         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19470         *ret_copy = COption_u128Z_some(o_ref);
19471         int64_t ret_ref = tag_ptr(ret_copy, true);
19472         return ret_ref;
19473 }
19474
19475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1none(JNIEnv *env, jclass clz) {
19476         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19477         *ret_copy = COption_u128Z_none();
19478         int64_t ret_ref = tag_ptr(ret_copy, true);
19479         return ret_ref;
19480 }
19481
19482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19483         if (!ptr_is_owned(_res)) return;
19484         void* _res_ptr = untag_ptr(_res);
19485         CHECK_ACCESS(_res_ptr);
19486         LDKCOption_u128Z _res_conv = *(LDKCOption_u128Z*)(_res_ptr);
19487         FREE(untag_ptr(_res));
19488         COption_u128Z_free(_res_conv);
19489 }
19490
19491 static inline uint64_t COption_u128Z_clone_ptr(LDKCOption_u128Z *NONNULL_PTR arg) {
19492         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19493         *ret_copy = COption_u128Z_clone(arg);
19494         int64_t ret_ref = tag_ptr(ret_copy, true);
19495         return ret_ref;
19496 }
19497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19498         LDKCOption_u128Z* arg_conv = (LDKCOption_u128Z*)untag_ptr(arg);
19499         int64_t ret_conv = COption_u128Z_clone_ptr(arg_conv);
19500         return ret_conv;
19501 }
19502
19503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19504         LDKCOption_u128Z* orig_conv = (LDKCOption_u128Z*)untag_ptr(orig);
19505         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19506         *ret_copy = COption_u128Z_clone(orig_conv);
19507         int64_t ret_ref = tag_ptr(ret_copy, true);
19508         return ret_ref;
19509 }
19510
19511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1some(JNIEnv *env, jclass clz, jclass o) {
19512         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_java(env, o);
19513         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19514         *ret_copy = COption_PaymentFailureReasonZ_some(o_conv);
19515         int64_t ret_ref = tag_ptr(ret_copy, true);
19516         return ret_ref;
19517 }
19518
19519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1none(JNIEnv *env, jclass clz) {
19520         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19521         *ret_copy = COption_PaymentFailureReasonZ_none();
19522         int64_t ret_ref = tag_ptr(ret_copy, true);
19523         return ret_ref;
19524 }
19525
19526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19527         if (!ptr_is_owned(_res)) return;
19528         void* _res_ptr = untag_ptr(_res);
19529         CHECK_ACCESS(_res_ptr);
19530         LDKCOption_PaymentFailureReasonZ _res_conv = *(LDKCOption_PaymentFailureReasonZ*)(_res_ptr);
19531         FREE(untag_ptr(_res));
19532         COption_PaymentFailureReasonZ_free(_res_conv);
19533 }
19534
19535 static inline uint64_t COption_PaymentFailureReasonZ_clone_ptr(LDKCOption_PaymentFailureReasonZ *NONNULL_PTR arg) {
19536         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19537         *ret_copy = COption_PaymentFailureReasonZ_clone(arg);
19538         int64_t ret_ref = tag_ptr(ret_copy, true);
19539         return ret_ref;
19540 }
19541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19542         LDKCOption_PaymentFailureReasonZ* arg_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(arg);
19543         int64_t ret_conv = COption_PaymentFailureReasonZ_clone_ptr(arg_conv);
19544         return ret_conv;
19545 }
19546
19547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19548         LDKCOption_PaymentFailureReasonZ* orig_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(orig);
19549         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19550         *ret_copy = COption_PaymentFailureReasonZ_clone(orig_conv);
19551         int64_t ret_ref = tag_ptr(ret_copy, true);
19552         return ret_ref;
19553 }
19554
19555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19556         LDKCVec_SpendableOutputDescriptorZ _res_constr;
19557         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19558         if (_res_constr.datalen > 0)
19559                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19560         else
19561                 _res_constr.data = NULL;
19562         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19563         for (size_t b = 0; b < _res_constr.datalen; b++) {
19564                 int64_t _res_conv_27 = _res_vals[b];
19565                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
19566                 CHECK_ACCESS(_res_conv_27_ptr);
19567                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
19568                 FREE(untag_ptr(_res_conv_27));
19569                 _res_constr.data[b] = _res_conv_27_conv;
19570         }
19571         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19572         CVec_SpendableOutputDescriptorZ_free(_res_constr);
19573 }
19574
19575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19576         void* o_ptr = untag_ptr(o);
19577         CHECK_ACCESS(o_ptr);
19578         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
19579         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
19580         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19581         *ret_copy = COption_EventZ_some(o_conv);
19582         int64_t ret_ref = tag_ptr(ret_copy, true);
19583         return ret_ref;
19584 }
19585
19586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
19587         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19588         *ret_copy = COption_EventZ_none();
19589         int64_t ret_ref = tag_ptr(ret_copy, true);
19590         return ret_ref;
19591 }
19592
19593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19594         if (!ptr_is_owned(_res)) return;
19595         void* _res_ptr = untag_ptr(_res);
19596         CHECK_ACCESS(_res_ptr);
19597         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
19598         FREE(untag_ptr(_res));
19599         COption_EventZ_free(_res_conv);
19600 }
19601
19602 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
19603         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19604         *ret_copy = COption_EventZ_clone(arg);
19605         int64_t ret_ref = tag_ptr(ret_copy, true);
19606         return ret_ref;
19607 }
19608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19609         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
19610         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
19611         return ret_conv;
19612 }
19613
19614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19615         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
19616         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19617         *ret_copy = COption_EventZ_clone(orig_conv);
19618         int64_t ret_ref = tag_ptr(ret_copy, true);
19619         return ret_ref;
19620 }
19621
19622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19623         void* o_ptr = untag_ptr(o);
19624         CHECK_ACCESS(o_ptr);
19625         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
19626         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
19627         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19628         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
19629         return tag_ptr(ret_conv, true);
19630 }
19631
19632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19633         void* e_ptr = untag_ptr(e);
19634         CHECK_ACCESS(e_ptr);
19635         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19636         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19637         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19638         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
19639         return tag_ptr(ret_conv, true);
19640 }
19641
19642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19643         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
19644         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
19645         return ret_conv;
19646 }
19647
19648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19649         if (!ptr_is_owned(_res)) return;
19650         void* _res_ptr = untag_ptr(_res);
19651         CHECK_ACCESS(_res_ptr);
19652         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
19653         FREE(untag_ptr(_res));
19654         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
19655 }
19656
19657 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
19658         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19659         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
19660         return tag_ptr(ret_conv, true);
19661 }
19662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19663         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
19664         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
19665         return ret_conv;
19666 }
19667
19668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19669         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
19670         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19671         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
19672         return tag_ptr(ret_conv, true);
19673 }
19674
19675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19676         LDKCVec_MessageSendEventZ _res_constr;
19677         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19678         if (_res_constr.datalen > 0)
19679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
19680         else
19681                 _res_constr.data = NULL;
19682         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19683         for (size_t s = 0; s < _res_constr.datalen; s++) {
19684                 int64_t _res_conv_18 = _res_vals[s];
19685                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
19686                 CHECK_ACCESS(_res_conv_18_ptr);
19687                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
19688                 FREE(untag_ptr(_res_conv_18));
19689                 _res_constr.data[s] = _res_conv_18_conv;
19690         }
19691         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19692         CVec_MessageSendEventZ_free(_res_constr);
19693 }
19694
19695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChainHashZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19696         LDKCVec_ChainHashZ _res_constr;
19697         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19698         if (_res_constr.datalen > 0)
19699                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ChainHashZ Elements");
19700         else
19701                 _res_constr.data = NULL;
19702         for (size_t i = 0; i < _res_constr.datalen; i++) {
19703                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19704                 LDKThirtyTwoBytes _res_conv_8_ref;
19705                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19706                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19707                 _res_constr.data[i] = _res_conv_8_ref;
19708         }
19709         CVec_ChainHashZ_free(_res_constr);
19710 }
19711
19712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19713         LDKPublicKey o_ref;
19714         CHECK((*env)->GetArrayLength(env, o) == 33);
19715         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
19716         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19717         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
19718         return tag_ptr(ret_conv, true);
19719 }
19720
19721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19722         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19723         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19724         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
19725         return tag_ptr(ret_conv, true);
19726 }
19727
19728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19729         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
19730         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
19731         return ret_conv;
19732 }
19733
19734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19735         if (!ptr_is_owned(_res)) return;
19736         void* _res_ptr = untag_ptr(_res);
19737         CHECK_ACCESS(_res_ptr);
19738         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
19739         FREE(untag_ptr(_res));
19740         CResult_PublicKeyErrorZ_free(_res_conv);
19741 }
19742
19743 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
19744         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19745         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
19746         return tag_ptr(ret_conv, true);
19747 }
19748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19749         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
19750         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
19751         return ret_conv;
19752 }
19753
19754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19755         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
19756         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19757         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
19758         return tag_ptr(ret_conv, true);
19759 }
19760
19761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19762         LDKNodeId o_conv;
19763         o_conv.inner = untag_ptr(o);
19764         o_conv.is_owned = ptr_is_owned(o);
19765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19766         o_conv = NodeId_clone(&o_conv);
19767         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19768         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19769         return tag_ptr(ret_conv, true);
19770 }
19771
19772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19773         void* e_ptr = untag_ptr(e);
19774         CHECK_ACCESS(e_ptr);
19775         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19776         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19777         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19778         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19779         return tag_ptr(ret_conv, true);
19780 }
19781
19782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19783         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
19784         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19785         return ret_conv;
19786 }
19787
19788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19789         if (!ptr_is_owned(_res)) return;
19790         void* _res_ptr = untag_ptr(_res);
19791         CHECK_ACCESS(_res_ptr);
19792         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19793         FREE(untag_ptr(_res));
19794         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19795 }
19796
19797 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19798         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19799         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19800         return tag_ptr(ret_conv, true);
19801 }
19802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19803         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
19804         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19805         return ret_conv;
19806 }
19807
19808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19809         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
19810         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19811         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19812         return tag_ptr(ret_conv, true);
19813 }
19814
19815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19816         void* o_ptr = untag_ptr(o);
19817         CHECK_ACCESS(o_ptr);
19818         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19819         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19820         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19821         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19822         return tag_ptr(ret_conv, true);
19823 }
19824
19825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19826         void* e_ptr = untag_ptr(e);
19827         CHECK_ACCESS(e_ptr);
19828         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19829         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19830         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19831         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19832         return tag_ptr(ret_conv, true);
19833 }
19834
19835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19836         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19837         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19838         return ret_conv;
19839 }
19840
19841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19842         if (!ptr_is_owned(_res)) return;
19843         void* _res_ptr = untag_ptr(_res);
19844         CHECK_ACCESS(_res_ptr);
19845         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19846         FREE(untag_ptr(_res));
19847         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19848 }
19849
19850 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19851         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19852         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19853         return tag_ptr(ret_conv, true);
19854 }
19855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19856         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19857         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19858         return ret_conv;
19859 }
19860
19861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19862         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19863         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19864         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19865         return tag_ptr(ret_conv, true);
19866 }
19867
19868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19869         void* o_ptr = untag_ptr(o);
19870         CHECK_ACCESS(o_ptr);
19871         LDKUtxoLookup o_conv = *(LDKUtxoLookup*)(o_ptr);
19872         if (o_conv.free == LDKUtxoLookup_JCalls_free) {
19873                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19874                 LDKUtxoLookup_JCalls_cloned(&o_conv);
19875         }
19876         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19877         *ret_copy = COption_UtxoLookupZ_some(o_conv);
19878         int64_t ret_ref = tag_ptr(ret_copy, true);
19879         return ret_ref;
19880 }
19881
19882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1none(JNIEnv *env, jclass clz) {
19883         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19884         *ret_copy = COption_UtxoLookupZ_none();
19885         int64_t ret_ref = tag_ptr(ret_copy, true);
19886         return ret_ref;
19887 }
19888
19889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19890         if (!ptr_is_owned(_res)) return;
19891         void* _res_ptr = untag_ptr(_res);
19892         CHECK_ACCESS(_res_ptr);
19893         LDKCOption_UtxoLookupZ _res_conv = *(LDKCOption_UtxoLookupZ*)(_res_ptr);
19894         FREE(untag_ptr(_res));
19895         COption_UtxoLookupZ_free(_res_conv);
19896 }
19897
19898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19899         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19900         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19901         return tag_ptr(ret_conv, true);
19902 }
19903
19904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19905         LDKLightningError e_conv;
19906         e_conv.inner = untag_ptr(e);
19907         e_conv.is_owned = ptr_is_owned(e);
19908         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19909         e_conv = LightningError_clone(&e_conv);
19910         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19911         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19912         return tag_ptr(ret_conv, true);
19913 }
19914
19915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19916         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19917         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19918         return ret_conv;
19919 }
19920
19921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19922         if (!ptr_is_owned(_res)) return;
19923         void* _res_ptr = untag_ptr(_res);
19924         CHECK_ACCESS(_res_ptr);
19925         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19926         FREE(untag_ptr(_res));
19927         CResult_boolLightningErrorZ_free(_res_conv);
19928 }
19929
19930 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19931         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19932         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19933         return tag_ptr(ret_conv, true);
19934 }
19935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19936         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19937         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19938         return ret_conv;
19939 }
19940
19941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19942         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19943         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19944         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19945         return tag_ptr(ret_conv, true);
19946 }
19947
19948 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19949         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19950         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19951         return tag_ptr(ret_conv, true);
19952 }
19953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19954         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19955         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19956         return ret_conv;
19957 }
19958
19959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19960         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19961         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19962         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19963         return tag_ptr(ret_conv, true);
19964 }
19965
19966 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) {
19967         LDKChannelAnnouncement a_conv;
19968         a_conv.inner = untag_ptr(a);
19969         a_conv.is_owned = ptr_is_owned(a);
19970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19971         a_conv = ChannelAnnouncement_clone(&a_conv);
19972         LDKChannelUpdate b_conv;
19973         b_conv.inner = untag_ptr(b);
19974         b_conv.is_owned = ptr_is_owned(b);
19975         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19976         b_conv = ChannelUpdate_clone(&b_conv);
19977         LDKChannelUpdate c_conv;
19978         c_conv.inner = untag_ptr(c);
19979         c_conv.is_owned = ptr_is_owned(c);
19980         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19981         c_conv = ChannelUpdate_clone(&c_conv);
19982         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19983         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19984         return tag_ptr(ret_conv, true);
19985 }
19986
19987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19988         if (!ptr_is_owned(_res)) return;
19989         void* _res_ptr = untag_ptr(_res);
19990         CHECK_ACCESS(_res_ptr);
19991         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19992         FREE(untag_ptr(_res));
19993         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19994 }
19995
19996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19997         void* o_ptr = untag_ptr(o);
19998         CHECK_ACCESS(o_ptr);
19999         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
20000         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
20001         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20002         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
20003         int64_t ret_ref = tag_ptr(ret_copy, true);
20004         return ret_ref;
20005 }
20006
20007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
20008         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20009         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
20010         int64_t ret_ref = tag_ptr(ret_copy, true);
20011         return ret_ref;
20012 }
20013
20014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20015         if (!ptr_is_owned(_res)) return;
20016         void* _res_ptr = untag_ptr(_res);
20017         CHECK_ACCESS(_res_ptr);
20018         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
20019         FREE(untag_ptr(_res));
20020         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
20021 }
20022
20023 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
20024         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20025         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
20026         int64_t ret_ref = tag_ptr(ret_copy, true);
20027         return ret_ref;
20028 }
20029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20030         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
20031         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
20032         return ret_conv;
20033 }
20034
20035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20036         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
20037         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20038         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
20039         int64_t ret_ref = tag_ptr(ret_copy, true);
20040         return ret_ref;
20041 }
20042
20043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
20044         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20045         *ret_conv = CResult_NoneLightningErrorZ_ok();
20046         return tag_ptr(ret_conv, true);
20047 }
20048
20049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20050         LDKLightningError e_conv;
20051         e_conv.inner = untag_ptr(e);
20052         e_conv.is_owned = ptr_is_owned(e);
20053         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20054         e_conv = LightningError_clone(&e_conv);
20055         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20056         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
20057         return tag_ptr(ret_conv, true);
20058 }
20059
20060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20061         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
20062         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
20063         return ret_conv;
20064 }
20065
20066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20067         if (!ptr_is_owned(_res)) return;
20068         void* _res_ptr = untag_ptr(_res);
20069         CHECK_ACCESS(_res_ptr);
20070         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
20071         FREE(untag_ptr(_res));
20072         CResult_NoneLightningErrorZ_free(_res_conv);
20073 }
20074
20075 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
20076         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20077         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
20078         return tag_ptr(ret_conv, true);
20079 }
20080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20081         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
20082         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
20083         return ret_conv;
20084 }
20085
20086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20087         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
20088         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20089         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
20090         return tag_ptr(ret_conv, true);
20091 }
20092
20093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20094         LDKChannelUpdateInfo o_conv;
20095         o_conv.inner = untag_ptr(o);
20096         o_conv.is_owned = ptr_is_owned(o);
20097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20098         o_conv = ChannelUpdateInfo_clone(&o_conv);
20099         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20100         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20101         return tag_ptr(ret_conv, true);
20102 }
20103
20104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20105         void* e_ptr = untag_ptr(e);
20106         CHECK_ACCESS(e_ptr);
20107         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20108         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20109         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20110         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20111         return tag_ptr(ret_conv, true);
20112 }
20113
20114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20115         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
20116         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20117         return ret_conv;
20118 }
20119
20120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20121         if (!ptr_is_owned(_res)) return;
20122         void* _res_ptr = untag_ptr(_res);
20123         CHECK_ACCESS(_res_ptr);
20124         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20125         FREE(untag_ptr(_res));
20126         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20127 }
20128
20129 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20130         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20131         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20132         return tag_ptr(ret_conv, true);
20133 }
20134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20135         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
20136         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20137         return ret_conv;
20138 }
20139
20140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20141         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
20142         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20143         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20144         return tag_ptr(ret_conv, true);
20145 }
20146
20147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20148         LDKChannelInfo o_conv;
20149         o_conv.inner = untag_ptr(o);
20150         o_conv.is_owned = ptr_is_owned(o);
20151         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20152         o_conv = ChannelInfo_clone(&o_conv);
20153         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20154         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20155         return tag_ptr(ret_conv, true);
20156 }
20157
20158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20159         void* e_ptr = untag_ptr(e);
20160         CHECK_ACCESS(e_ptr);
20161         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20162         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20163         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20164         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20165         return tag_ptr(ret_conv, true);
20166 }
20167
20168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20169         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
20170         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20171         return ret_conv;
20172 }
20173
20174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20175         if (!ptr_is_owned(_res)) return;
20176         void* _res_ptr = untag_ptr(_res);
20177         CHECK_ACCESS(_res_ptr);
20178         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20179         FREE(untag_ptr(_res));
20180         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20181 }
20182
20183 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20184         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20185         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20186         return tag_ptr(ret_conv, true);
20187 }
20188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20189         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
20190         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20191         return ret_conv;
20192 }
20193
20194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20195         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
20196         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20197         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20198         return tag_ptr(ret_conv, true);
20199 }
20200
20201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20202         LDKRoutingFees o_conv;
20203         o_conv.inner = untag_ptr(o);
20204         o_conv.is_owned = ptr_is_owned(o);
20205         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20206         o_conv = RoutingFees_clone(&o_conv);
20207         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20208         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20209         return tag_ptr(ret_conv, true);
20210 }
20211
20212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20213         void* e_ptr = untag_ptr(e);
20214         CHECK_ACCESS(e_ptr);
20215         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20216         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20217         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20218         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20219         return tag_ptr(ret_conv, true);
20220 }
20221
20222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20223         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
20224         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20225         return ret_conv;
20226 }
20227
20228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20229         if (!ptr_is_owned(_res)) return;
20230         void* _res_ptr = untag_ptr(_res);
20231         CHECK_ACCESS(_res_ptr);
20232         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20233         FREE(untag_ptr(_res));
20234         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20235 }
20236
20237 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20238         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20239         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20240         return tag_ptr(ret_conv, true);
20241 }
20242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20243         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
20244         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20245         return ret_conv;
20246 }
20247
20248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20249         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
20250         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20251         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20252         return tag_ptr(ret_conv, true);
20253 }
20254
20255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20256         LDKCVec_NetAddressZ _res_constr;
20257         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20258         if (_res_constr.datalen > 0)
20259                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20260         else
20261                 _res_constr.data = NULL;
20262         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20263         for (size_t m = 0; m < _res_constr.datalen; m++) {
20264                 int64_t _res_conv_12 = _res_vals[m];
20265                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
20266                 CHECK_ACCESS(_res_conv_12_ptr);
20267                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
20268                 FREE(untag_ptr(_res_conv_12));
20269                 _res_constr.data[m] = _res_conv_12_conv;
20270         }
20271         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20272         CVec_NetAddressZ_free(_res_constr);
20273 }
20274
20275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20276         LDKNodeAnnouncementInfo o_conv;
20277         o_conv.inner = untag_ptr(o);
20278         o_conv.is_owned = ptr_is_owned(o);
20279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20280         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20281         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20282         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20283         return tag_ptr(ret_conv, true);
20284 }
20285
20286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20287         void* e_ptr = untag_ptr(e);
20288         CHECK_ACCESS(e_ptr);
20289         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20290         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20291         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20292         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20293         return tag_ptr(ret_conv, true);
20294 }
20295
20296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20297         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
20298         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20299         return ret_conv;
20300 }
20301
20302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20303         if (!ptr_is_owned(_res)) return;
20304         void* _res_ptr = untag_ptr(_res);
20305         CHECK_ACCESS(_res_ptr);
20306         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20307         FREE(untag_ptr(_res));
20308         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20309 }
20310
20311 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20312         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20313         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20314         return tag_ptr(ret_conv, true);
20315 }
20316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20317         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
20318         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20319         return ret_conv;
20320 }
20321
20322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20323         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
20324         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20325         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20326         return tag_ptr(ret_conv, true);
20327 }
20328
20329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20330         LDKNodeAlias o_conv;
20331         o_conv.inner = untag_ptr(o);
20332         o_conv.is_owned = ptr_is_owned(o);
20333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20334         o_conv = NodeAlias_clone(&o_conv);
20335         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20336         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
20337         return tag_ptr(ret_conv, true);
20338 }
20339
20340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20341         void* e_ptr = untag_ptr(e);
20342         CHECK_ACCESS(e_ptr);
20343         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20344         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20345         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20346         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
20347         return tag_ptr(ret_conv, true);
20348 }
20349
20350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20351         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
20352         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
20353         return ret_conv;
20354 }
20355
20356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20357         if (!ptr_is_owned(_res)) return;
20358         void* _res_ptr = untag_ptr(_res);
20359         CHECK_ACCESS(_res_ptr);
20360         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
20361         FREE(untag_ptr(_res));
20362         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
20363 }
20364
20365 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
20366         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20367         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
20368         return tag_ptr(ret_conv, true);
20369 }
20370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20371         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
20372         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
20373         return ret_conv;
20374 }
20375
20376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20377         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
20378         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20379         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
20380         return tag_ptr(ret_conv, true);
20381 }
20382
20383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20384         LDKNodeInfo o_conv;
20385         o_conv.inner = untag_ptr(o);
20386         o_conv.is_owned = ptr_is_owned(o);
20387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20388         o_conv = NodeInfo_clone(&o_conv);
20389         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20390         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20391         return tag_ptr(ret_conv, true);
20392 }
20393
20394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20395         void* e_ptr = untag_ptr(e);
20396         CHECK_ACCESS(e_ptr);
20397         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20398         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20399         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20400         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20401         return tag_ptr(ret_conv, true);
20402 }
20403
20404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20405         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
20406         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20407         return ret_conv;
20408 }
20409
20410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20411         if (!ptr_is_owned(_res)) return;
20412         void* _res_ptr = untag_ptr(_res);
20413         CHECK_ACCESS(_res_ptr);
20414         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20415         FREE(untag_ptr(_res));
20416         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20417 }
20418
20419 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20420         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20421         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20422         return tag_ptr(ret_conv, true);
20423 }
20424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20425         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
20426         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20427         return ret_conv;
20428 }
20429
20430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20431         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
20432         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20433         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20434         return tag_ptr(ret_conv, true);
20435 }
20436
20437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20438         LDKNetworkGraph o_conv;
20439         o_conv.inner = untag_ptr(o);
20440         o_conv.is_owned = ptr_is_owned(o);
20441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20442         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
20443         
20444         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20445         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20446         return tag_ptr(ret_conv, true);
20447 }
20448
20449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20450         void* e_ptr = untag_ptr(e);
20451         CHECK_ACCESS(e_ptr);
20452         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20453         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20454         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20455         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20456         return tag_ptr(ret_conv, true);
20457 }
20458
20459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20460         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
20461         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20462         return ret_conv;
20463 }
20464
20465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20466         if (!ptr_is_owned(_res)) return;
20467         void* _res_ptr = untag_ptr(_res);
20468         CHECK_ACCESS(_res_ptr);
20469         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20470         FREE(untag_ptr(_res));
20471         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20472 }
20473
20474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20475         LDKCVec_NetAddressZ o_constr;
20476         o_constr.datalen = (*env)->GetArrayLength(env, o);
20477         if (o_constr.datalen > 0)
20478                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20479         else
20480                 o_constr.data = NULL;
20481         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20482         for (size_t m = 0; m < o_constr.datalen; m++) {
20483                 int64_t o_conv_12 = o_vals[m];
20484                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
20485                 CHECK_ACCESS(o_conv_12_ptr);
20486                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20487                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
20488                 o_constr.data[m] = o_conv_12_conv;
20489         }
20490         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20491         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20492         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20493         int64_t ret_ref = tag_ptr(ret_copy, true);
20494         return ret_ref;
20495 }
20496
20497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20498         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20499         *ret_copy = COption_CVec_NetAddressZZ_none();
20500         int64_t ret_ref = tag_ptr(ret_copy, true);
20501         return ret_ref;
20502 }
20503
20504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20505         if (!ptr_is_owned(_res)) return;
20506         void* _res_ptr = untag_ptr(_res);
20507         CHECK_ACCESS(_res_ptr);
20508         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20509         FREE(untag_ptr(_res));
20510         COption_CVec_NetAddressZZ_free(_res_conv);
20511 }
20512
20513 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20514         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20515         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20516         int64_t ret_ref = tag_ptr(ret_copy, true);
20517         return ret_ref;
20518 }
20519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20520         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
20521         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20522         return ret_conv;
20523 }
20524
20525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20526         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
20527         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20528         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
20529         int64_t ret_ref = tag_ptr(ret_copy, true);
20530         return ret_ref;
20531 }
20532
20533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20534         LDKDelayedPaymentOutputDescriptor o_conv;
20535         o_conv.inner = untag_ptr(o);
20536         o_conv.is_owned = ptr_is_owned(o);
20537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20538         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
20539         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20540         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
20541         return tag_ptr(ret_conv, true);
20542 }
20543
20544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20545         void* e_ptr = untag_ptr(e);
20546         CHECK_ACCESS(e_ptr);
20547         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20548         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20549         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20550         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
20551         return tag_ptr(ret_conv, true);
20552 }
20553
20554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20555         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20556         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20557         return ret_conv;
20558 }
20559
20560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20561         if (!ptr_is_owned(_res)) return;
20562         void* _res_ptr = untag_ptr(_res);
20563         CHECK_ACCESS(_res_ptr);
20564         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
20565         FREE(untag_ptr(_res));
20566         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
20567 }
20568
20569 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20570         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20571         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
20572         return tag_ptr(ret_conv, true);
20573 }
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20575         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20576         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20577         return ret_conv;
20578 }
20579
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20581         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20582         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20583         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
20584         return tag_ptr(ret_conv, true);
20585 }
20586
20587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20588         LDKStaticPaymentOutputDescriptor o_conv;
20589         o_conv.inner = untag_ptr(o);
20590         o_conv.is_owned = ptr_is_owned(o);
20591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20592         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
20593         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20594         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
20595         return tag_ptr(ret_conv, true);
20596 }
20597
20598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20599         void* e_ptr = untag_ptr(e);
20600         CHECK_ACCESS(e_ptr);
20601         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20602         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20603         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20604         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
20605         return tag_ptr(ret_conv, true);
20606 }
20607
20608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20609         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20610         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20611         return ret_conv;
20612 }
20613
20614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20615         if (!ptr_is_owned(_res)) return;
20616         void* _res_ptr = untag_ptr(_res);
20617         CHECK_ACCESS(_res_ptr);
20618         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
20619         FREE(untag_ptr(_res));
20620         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
20621 }
20622
20623 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20624         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20625         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
20626         return tag_ptr(ret_conv, true);
20627 }
20628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20629         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20630         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20631         return ret_conv;
20632 }
20633
20634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20635         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20636         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20637         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
20638         return tag_ptr(ret_conv, true);
20639 }
20640
20641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20642         void* o_ptr = untag_ptr(o);
20643         CHECK_ACCESS(o_ptr);
20644         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
20645         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
20646         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20647         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
20648         return tag_ptr(ret_conv, true);
20649 }
20650
20651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20652         void* e_ptr = untag_ptr(e);
20653         CHECK_ACCESS(e_ptr);
20654         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20655         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20656         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20657         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
20658         return tag_ptr(ret_conv, true);
20659 }
20660
20661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20662         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20663         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20664         return ret_conv;
20665 }
20666
20667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20668         if (!ptr_is_owned(_res)) return;
20669         void* _res_ptr = untag_ptr(_res);
20670         CHECK_ACCESS(_res_ptr);
20671         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
20672         FREE(untag_ptr(_res));
20673         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
20674 }
20675
20676 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20677         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20678         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
20679         return tag_ptr(ret_conv, true);
20680 }
20681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20682         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20683         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20684         return ret_conv;
20685 }
20686
20687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20688         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20689         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20690         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
20691         return tag_ptr(ret_conv, true);
20692 }
20693
20694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20695         LDKCVec_PaymentPreimageZ _res_constr;
20696         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20697         if (_res_constr.datalen > 0)
20698                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
20699         else
20700                 _res_constr.data = NULL;
20701         for (size_t i = 0; i < _res_constr.datalen; i++) {
20702                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20703                 LDKThirtyTwoBytes _res_conv_8_ref;
20704                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20705                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20706                 _res_constr.data[i] = _res_conv_8_ref;
20707         }
20708         CVec_PaymentPreimageZ_free(_res_constr);
20709 }
20710
20711 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
20712         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20713         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
20714         return tag_ptr(ret_conv, true);
20715 }
20716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20717         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
20718         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
20719         return ret_conv;
20720 }
20721
20722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20723         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
20724         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20725         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
20726         return tag_ptr(ret_conv, true);
20727 }
20728
20729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
20730         LDKSignature a_ref;
20731         CHECK((*env)->GetArrayLength(env, a) == 64);
20732         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
20733         LDKCVec_SignatureZ b_constr;
20734         b_constr.datalen = (*env)->GetArrayLength(env, b);
20735         if (b_constr.datalen > 0)
20736                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20737         else
20738                 b_constr.data = NULL;
20739         for (size_t i = 0; i < b_constr.datalen; i++) {
20740                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
20741                 LDKSignature b_conv_8_ref;
20742                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
20743                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
20744                 b_constr.data[i] = b_conv_8_ref;
20745         }
20746         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20747         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
20748         return tag_ptr(ret_conv, true);
20749 }
20750
20751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20752         if (!ptr_is_owned(_res)) return;
20753         void* _res_ptr = untag_ptr(_res);
20754         CHECK_ACCESS(_res_ptr);
20755         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
20756         FREE(untag_ptr(_res));
20757         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
20758 }
20759
20760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20761         void* o_ptr = untag_ptr(o);
20762         CHECK_ACCESS(o_ptr);
20763         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
20764         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
20765         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20766         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
20767         return tag_ptr(ret_conv, true);
20768 }
20769
20770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
20771         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20772         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
20773         return tag_ptr(ret_conv, true);
20774 }
20775
20776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20777         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
20778         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
20779         return ret_conv;
20780 }
20781
20782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20783         if (!ptr_is_owned(_res)) return;
20784         void* _res_ptr = untag_ptr(_res);
20785         CHECK_ACCESS(_res_ptr);
20786         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
20787         FREE(untag_ptr(_res));
20788         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
20789 }
20790
20791 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
20792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20793         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
20794         return tag_ptr(ret_conv, true);
20795 }
20796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20797         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
20798         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
20799         return ret_conv;
20800 }
20801
20802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20803         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
20804         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20805         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
20806         return tag_ptr(ret_conv, true);
20807 }
20808
20809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20810         LDKSignature o_ref;
20811         CHECK((*env)->GetArrayLength(env, o) == 64);
20812         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
20813         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20814         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
20815         return tag_ptr(ret_conv, true);
20816 }
20817
20818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20819         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20820         *ret_conv = CResult_SignatureNoneZ_err();
20821         return tag_ptr(ret_conv, true);
20822 }
20823
20824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20825         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
20826         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
20827         return ret_conv;
20828 }
20829
20830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20831         if (!ptr_is_owned(_res)) return;
20832         void* _res_ptr = untag_ptr(_res);
20833         CHECK_ACCESS(_res_ptr);
20834         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
20835         FREE(untag_ptr(_res));
20836         CResult_SignatureNoneZ_free(_res_conv);
20837 }
20838
20839 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
20840         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20841         *ret_conv = CResult_SignatureNoneZ_clone(arg);
20842         return tag_ptr(ret_conv, true);
20843 }
20844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20845         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
20846         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
20847         return ret_conv;
20848 }
20849
20850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20851         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
20852         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20853         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
20854         return tag_ptr(ret_conv, true);
20855 }
20856
20857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20858         LDKPublicKey o_ref;
20859         CHECK((*env)->GetArrayLength(env, o) == 33);
20860         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
20861         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20862         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
20863         return tag_ptr(ret_conv, true);
20864 }
20865
20866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20867         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20868         *ret_conv = CResult_PublicKeyNoneZ_err();
20869         return tag_ptr(ret_conv, true);
20870 }
20871
20872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20873         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
20874         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
20875         return ret_conv;
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20879         if (!ptr_is_owned(_res)) return;
20880         void* _res_ptr = untag_ptr(_res);
20881         CHECK_ACCESS(_res_ptr);
20882         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
20883         FREE(untag_ptr(_res));
20884         CResult_PublicKeyNoneZ_free(_res_conv);
20885 }
20886
20887 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
20888         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20889         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
20890         return tag_ptr(ret_conv, true);
20891 }
20892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20893         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
20894         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
20895         return ret_conv;
20896 }
20897
20898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20899         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
20900         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20901         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
20902         return tag_ptr(ret_conv, true);
20903 }
20904
20905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20906         void* o_ptr = untag_ptr(o);
20907         CHECK_ACCESS(o_ptr);
20908         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
20909         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
20910         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20911         *ret_copy = COption_ScalarZ_some(o_conv);
20912         int64_t ret_ref = tag_ptr(ret_copy, true);
20913         return ret_ref;
20914 }
20915
20916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
20917         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20918         *ret_copy = COption_ScalarZ_none();
20919         int64_t ret_ref = tag_ptr(ret_copy, true);
20920         return ret_ref;
20921 }
20922
20923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20924         if (!ptr_is_owned(_res)) return;
20925         void* _res_ptr = untag_ptr(_res);
20926         CHECK_ACCESS(_res_ptr);
20927         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
20928         FREE(untag_ptr(_res));
20929         COption_ScalarZ_free(_res_conv);
20930 }
20931
20932 static inline uint64_t COption_ScalarZ_clone_ptr(LDKCOption_ScalarZ *NONNULL_PTR arg) {
20933         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20934         *ret_copy = COption_ScalarZ_clone(arg);
20935         int64_t ret_ref = tag_ptr(ret_copy, true);
20936         return ret_ref;
20937 }
20938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20939         LDKCOption_ScalarZ* arg_conv = (LDKCOption_ScalarZ*)untag_ptr(arg);
20940         int64_t ret_conv = COption_ScalarZ_clone_ptr(arg_conv);
20941         return ret_conv;
20942 }
20943
20944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20945         LDKCOption_ScalarZ* orig_conv = (LDKCOption_ScalarZ*)untag_ptr(orig);
20946         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20947         *ret_copy = COption_ScalarZ_clone(orig_conv);
20948         int64_t ret_ref = tag_ptr(ret_copy, true);
20949         return ret_ref;
20950 }
20951
20952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20953         LDKThirtyTwoBytes o_ref;
20954         CHECK((*env)->GetArrayLength(env, o) == 32);
20955         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20956         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20957         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20958         return tag_ptr(ret_conv, true);
20959 }
20960
20961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20962         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20963         *ret_conv = CResult_SharedSecretNoneZ_err();
20964         return tag_ptr(ret_conv, true);
20965 }
20966
20967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20968         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20969         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20970         return ret_conv;
20971 }
20972
20973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20974         if (!ptr_is_owned(_res)) return;
20975         void* _res_ptr = untag_ptr(_res);
20976         CHECK_ACCESS(_res_ptr);
20977         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20978         FREE(untag_ptr(_res));
20979         CResult_SharedSecretNoneZ_free(_res_conv);
20980 }
20981
20982 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20983         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20984         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20985         return tag_ptr(ret_conv, true);
20986 }
20987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20988         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20989         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20990         return ret_conv;
20991 }
20992
20993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20994         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20995         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20996         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20997         return tag_ptr(ret_conv, true);
20998 }
20999
21000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21001         LDKCVec_U5Z _res_constr;
21002         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21003         if (_res_constr.datalen > 0)
21004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
21005         else
21006                 _res_constr.data = NULL;
21007         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
21008         for (size_t h = 0; h < _res_constr.datalen; h++) {
21009                 int8_t _res_conv_7 = _res_vals[h];
21010                 
21011                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
21012         }
21013         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
21014         CVec_U5Z_free(_res_constr);
21015 }
21016
21017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21018         LDKRecoverableSignature o_ref;
21019         CHECK((*env)->GetArrayLength(env, o) == 68);
21020         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
21021         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21022         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
21023         return tag_ptr(ret_conv, true);
21024 }
21025
21026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
21027         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21028         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
21029         return tag_ptr(ret_conv, true);
21030 }
21031
21032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21033         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
21034         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
21035         return ret_conv;
21036 }
21037
21038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21039         if (!ptr_is_owned(_res)) return;
21040         void* _res_ptr = untag_ptr(_res);
21041         CHECK_ACCESS(_res_ptr);
21042         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
21043         FREE(untag_ptr(_res));
21044         CResult_RecoverableSignatureNoneZ_free(_res_conv);
21045 }
21046
21047 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
21048         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21049         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
21050         return tag_ptr(ret_conv, true);
21051 }
21052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21053         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
21054         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
21055         return ret_conv;
21056 }
21057
21058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21059         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
21060         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21061         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
21062         return tag_ptr(ret_conv, true);
21063 }
21064
21065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21066         void* o_ptr = untag_ptr(o);
21067         CHECK_ACCESS(o_ptr);
21068         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
21069         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
21070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21071                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
21072         }
21073         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21074         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
21075         return tag_ptr(ret_conv, true);
21076 }
21077
21078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21079         void* e_ptr = untag_ptr(e);
21080         CHECK_ACCESS(e_ptr);
21081         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21082         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21083         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21084         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
21085         return tag_ptr(ret_conv, true);
21086 }
21087
21088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21089         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
21090         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
21091         return ret_conv;
21092 }
21093
21094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21095         if (!ptr_is_owned(_res)) return;
21096         void* _res_ptr = untag_ptr(_res);
21097         CHECK_ACCESS(_res_ptr);
21098         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
21099         FREE(untag_ptr(_res));
21100         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
21101 }
21102
21103 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
21104         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21105         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
21106         return tag_ptr(ret_conv, true);
21107 }
21108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21109         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
21110         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
21111         return ret_conv;
21112 }
21113
21114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21115         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
21116         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21117         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
21118         return tag_ptr(ret_conv, true);
21119 }
21120
21121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21122         LDKCVec_CVec_u8ZZ _res_constr;
21123         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21124         if (_res_constr.datalen > 0)
21125                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21126         else
21127                 _res_constr.data = NULL;
21128         for (size_t i = 0; i < _res_constr.datalen; i++) {
21129                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21130                 LDKCVec_u8Z _res_conv_8_ref;
21131                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21132                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21133                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21134                 _res_constr.data[i] = _res_conv_8_ref;
21135         }
21136         CVec_CVec_u8ZZ_free(_res_constr);
21137 }
21138
21139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
21140         LDKCVec_CVec_u8ZZ o_constr;
21141         o_constr.datalen = (*env)->GetArrayLength(env, o);
21142         if (o_constr.datalen > 0)
21143                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21144         else
21145                 o_constr.data = NULL;
21146         for (size_t i = 0; i < o_constr.datalen; i++) {
21147                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
21148                 LDKCVec_u8Z o_conv_8_ref;
21149                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
21150                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21151                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
21152                 o_constr.data[i] = o_conv_8_ref;
21153         }
21154         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21155         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
21156         return tag_ptr(ret_conv, true);
21157 }
21158
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
21160         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21161         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
21162         return tag_ptr(ret_conv, true);
21163 }
21164
21165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21166         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
21167         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
21168         return ret_conv;
21169 }
21170
21171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21172         if (!ptr_is_owned(_res)) return;
21173         void* _res_ptr = untag_ptr(_res);
21174         CHECK_ACCESS(_res_ptr);
21175         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
21176         FREE(untag_ptr(_res));
21177         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
21178 }
21179
21180 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
21181         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21182         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
21183         return tag_ptr(ret_conv, true);
21184 }
21185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21186         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
21187         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
21188         return ret_conv;
21189 }
21190
21191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21192         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
21193         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21194         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
21195         return tag_ptr(ret_conv, true);
21196 }
21197
21198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21199         LDKInMemorySigner o_conv;
21200         o_conv.inner = untag_ptr(o);
21201         o_conv.is_owned = ptr_is_owned(o);
21202         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21203         o_conv = InMemorySigner_clone(&o_conv);
21204         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21205         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
21206         return tag_ptr(ret_conv, true);
21207 }
21208
21209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21210         void* e_ptr = untag_ptr(e);
21211         CHECK_ACCESS(e_ptr);
21212         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21213         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21214         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21215         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
21216         return tag_ptr(ret_conv, true);
21217 }
21218
21219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21220         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
21221         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
21222         return ret_conv;
21223 }
21224
21225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21226         if (!ptr_is_owned(_res)) return;
21227         void* _res_ptr = untag_ptr(_res);
21228         CHECK_ACCESS(_res_ptr);
21229         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
21230         FREE(untag_ptr(_res));
21231         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
21232 }
21233
21234 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
21235         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21236         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
21237         return tag_ptr(ret_conv, true);
21238 }
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21240         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
21241         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
21242         return ret_conv;
21243 }
21244
21245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21246         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
21247         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21248         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
21249         return tag_ptr(ret_conv, true);
21250 }
21251
21252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21253         LDKCVec_TxOutZ _res_constr;
21254         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21255         if (_res_constr.datalen > 0)
21256                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
21257         else
21258                 _res_constr.data = NULL;
21259         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21260         for (size_t h = 0; h < _res_constr.datalen; h++) {
21261                 int64_t _res_conv_7 = _res_vals[h];
21262                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
21263                 CHECK_ACCESS(_res_conv_7_ptr);
21264                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
21265                 FREE(untag_ptr(_res_conv_7));
21266                 _res_constr.data[h] = _res_conv_7_conv;
21267         }
21268         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21269         CVec_TxOutZ_free(_res_constr);
21270 }
21271
21272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21273         LDKTransaction o_ref;
21274         o_ref.datalen = (*env)->GetArrayLength(env, o);
21275         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
21276         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21277         o_ref.data_is_owned = true;
21278         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21279         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
21280         return tag_ptr(ret_conv, true);
21281 }
21282
21283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
21284         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21285         *ret_conv = CResult_TransactionNoneZ_err();
21286         return tag_ptr(ret_conv, true);
21287 }
21288
21289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21290         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
21291         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
21292         return ret_conv;
21293 }
21294
21295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21296         if (!ptr_is_owned(_res)) return;
21297         void* _res_ptr = untag_ptr(_res);
21298         CHECK_ACCESS(_res_ptr);
21299         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
21300         FREE(untag_ptr(_res));
21301         CResult_TransactionNoneZ_free(_res_conv);
21302 }
21303
21304 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
21305         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21306         *ret_conv = CResult_TransactionNoneZ_clone(arg);
21307         return tag_ptr(ret_conv, true);
21308 }
21309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21310         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
21311         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
21312         return ret_conv;
21313 }
21314
21315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21316         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
21317         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21318         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
21319         return tag_ptr(ret_conv, true);
21320 }
21321
21322 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
21323         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21324         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
21325         return tag_ptr(ret_conv, true);
21326 }
21327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21328         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
21329         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
21330         return ret_conv;
21331 }
21332
21333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21334         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
21335         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21336         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
21337         return tag_ptr(ret_conv, true);
21338 }
21339
21340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21341         LDKThirtyTwoBytes a_ref;
21342         CHECK((*env)->GetArrayLength(env, a) == 32);
21343         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21344         LDKChannelMonitor b_conv;
21345         b_conv.inner = untag_ptr(b);
21346         b_conv.is_owned = ptr_is_owned(b);
21347         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21348         b_conv = ChannelMonitor_clone(&b_conv);
21349         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21350         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
21351         return tag_ptr(ret_conv, true);
21352 }
21353
21354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21355         if (!ptr_is_owned(_res)) return;
21356         void* _res_ptr = untag_ptr(_res);
21357         CHECK_ACCESS(_res_ptr);
21358         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
21359         FREE(untag_ptr(_res));
21360         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
21361 }
21362
21363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21364         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
21365         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21366         if (_res_constr.datalen > 0)
21367                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21368         else
21369                 _res_constr.data = NULL;
21370         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21371         for (size_t j = 0; j < _res_constr.datalen; j++) {
21372                 int64_t _res_conv_35 = _res_vals[j];
21373                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21374                 CHECK_ACCESS(_res_conv_35_ptr);
21375                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
21376                 FREE(untag_ptr(_res_conv_35));
21377                 _res_constr.data[j] = _res_conv_35_conv;
21378         }
21379         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21380         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
21381 }
21382
21383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
21384         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
21385         o_constr.datalen = (*env)->GetArrayLength(env, o);
21386         if (o_constr.datalen > 0)
21387                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21388         else
21389                 o_constr.data = NULL;
21390         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
21391         for (size_t j = 0; j < o_constr.datalen; j++) {
21392                 int64_t o_conv_35 = o_vals[j];
21393                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
21394                 CHECK_ACCESS(o_conv_35_ptr);
21395                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
21396                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
21397                 o_constr.data[j] = o_conv_35_conv;
21398         }
21399         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
21400         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21401         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
21402         return tag_ptr(ret_conv, true);
21403 }
21404
21405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21406         LDKIOError e_conv = LDKIOError_from_java(env, e);
21407         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21408         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
21409         return tag_ptr(ret_conv, true);
21410 }
21411
21412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21413         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
21414         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
21415         return ret_conv;
21416 }
21417
21418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21419         if (!ptr_is_owned(_res)) return;
21420         void* _res_ptr = untag_ptr(_res);
21421         CHECK_ACCESS(_res_ptr);
21422         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
21423         FREE(untag_ptr(_res));
21424         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
21425 }
21426
21427 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
21428         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21429         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
21430         return tag_ptr(ret_conv, true);
21431 }
21432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21433         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
21434         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
21435         return ret_conv;
21436 }
21437
21438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21439         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
21440         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21441         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
21442         return tag_ptr(ret_conv, true);
21443 }
21444
21445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
21446         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21447         *ret_copy = COption_u16Z_some(o);
21448         int64_t ret_ref = tag_ptr(ret_copy, true);
21449         return ret_ref;
21450 }
21451
21452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
21453         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21454         *ret_copy = COption_u16Z_none();
21455         int64_t ret_ref = tag_ptr(ret_copy, true);
21456         return ret_ref;
21457 }
21458
21459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
21460         if (!ptr_is_owned(_res)) return;
21461         void* _res_ptr = untag_ptr(_res);
21462         CHECK_ACCESS(_res_ptr);
21463         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
21464         FREE(untag_ptr(_res));
21465         COption_u16Z_free(_res_conv);
21466 }
21467
21468 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
21469         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21470         *ret_copy = COption_u16Z_clone(arg);
21471         int64_t ret_ref = tag_ptr(ret_copy, true);
21472         return ret_ref;
21473 }
21474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21475         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
21476         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
21477         return ret_conv;
21478 }
21479
21480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21481         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
21482         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21483         *ret_copy = COption_u16Z_clone(orig_conv);
21484         int64_t ret_ref = tag_ptr(ret_copy, true);
21485         return ret_ref;
21486 }
21487
21488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21489         LDKThirtyTwoBytes o_ref;
21490         CHECK((*env)->GetArrayLength(env, o) == 32);
21491         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21492         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21493         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
21494         return tag_ptr(ret_conv, true);
21495 }
21496
21497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21498         void* e_ptr = untag_ptr(e);
21499         CHECK_ACCESS(e_ptr);
21500         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21501         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21502         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21503         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
21504         return tag_ptr(ret_conv, true);
21505 }
21506
21507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21508         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
21509         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
21510         return ret_conv;
21511 }
21512
21513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21514         if (!ptr_is_owned(_res)) return;
21515         void* _res_ptr = untag_ptr(_res);
21516         CHECK_ACCESS(_res_ptr);
21517         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
21518         FREE(untag_ptr(_res));
21519         CResult__u832APIErrorZ_free(_res_conv);
21520 }
21521
21522 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
21523         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21524         *ret_conv = CResult__u832APIErrorZ_clone(arg);
21525         return tag_ptr(ret_conv, true);
21526 }
21527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21528         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
21529         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
21530         return ret_conv;
21531 }
21532
21533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21534         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
21535         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21536         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
21537         return tag_ptr(ret_conv, true);
21538 }
21539
21540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RecentPaymentDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21541         LDKCVec_RecentPaymentDetailsZ _res_constr;
21542         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21543         if (_res_constr.datalen > 0)
21544                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
21545         else
21546                 _res_constr.data = NULL;
21547         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21548         for (size_t w = 0; w < _res_constr.datalen; w++) {
21549                 int64_t _res_conv_22 = _res_vals[w];
21550                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
21551                 CHECK_ACCESS(_res_conv_22_ptr);
21552                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
21553                 FREE(untag_ptr(_res_conv_22));
21554                 _res_constr.data[w] = _res_conv_22_conv;
21555         }
21556         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21557         CVec_RecentPaymentDetailsZ_free(_res_constr);
21558 }
21559
21560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21561         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21562         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
21563         return tag_ptr(ret_conv, true);
21564 }
21565
21566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21567         void* e_ptr = untag_ptr(e);
21568         CHECK_ACCESS(e_ptr);
21569         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21570         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21571         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21572         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
21573         return tag_ptr(ret_conv, true);
21574 }
21575
21576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21577         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
21578         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
21579         return ret_conv;
21580 }
21581
21582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21583         if (!ptr_is_owned(_res)) return;
21584         void* _res_ptr = untag_ptr(_res);
21585         CHECK_ACCESS(_res_ptr);
21586         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
21587         FREE(untag_ptr(_res));
21588         CResult_NonePaymentSendFailureZ_free(_res_conv);
21589 }
21590
21591 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
21592         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21593         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
21594         return tag_ptr(ret_conv, true);
21595 }
21596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21597         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
21598         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
21599         return ret_conv;
21600 }
21601
21602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21603         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
21604         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21605         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
21606         return tag_ptr(ret_conv, true);
21607 }
21608
21609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21610         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21611         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
21612         return tag_ptr(ret_conv, true);
21613 }
21614
21615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21616         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21617         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21618         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
21619         return tag_ptr(ret_conv, true);
21620 }
21621
21622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21623         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
21624         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
21625         return ret_conv;
21626 }
21627
21628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21629         if (!ptr_is_owned(_res)) return;
21630         void* _res_ptr = untag_ptr(_res);
21631         CHECK_ACCESS(_res_ptr);
21632         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
21633         FREE(untag_ptr(_res));
21634         CResult_NoneRetryableSendFailureZ_free(_res_conv);
21635 }
21636
21637 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
21638         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21639         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
21640         return tag_ptr(ret_conv, true);
21641 }
21642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21643         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
21644         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
21645         return ret_conv;
21646 }
21647
21648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21649         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
21650         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21651         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
21652         return tag_ptr(ret_conv, true);
21653 }
21654
21655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21656         LDKThirtyTwoBytes o_ref;
21657         CHECK((*env)->GetArrayLength(env, o) == 32);
21658         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21659         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21660         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
21661         return tag_ptr(ret_conv, true);
21662 }
21663
21664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21665         void* e_ptr = untag_ptr(e);
21666         CHECK_ACCESS(e_ptr);
21667         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21668         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21669         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21670         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21671         return tag_ptr(ret_conv, true);
21672 }
21673
21674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21675         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21676         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21677         return ret_conv;
21678 }
21679
21680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21681         if (!ptr_is_owned(_res)) return;
21682         void* _res_ptr = untag_ptr(_res);
21683         CHECK_ACCESS(_res_ptr);
21684         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21685         FREE(untag_ptr(_res));
21686         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21687 }
21688
21689 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21690         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21691         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21692         return tag_ptr(ret_conv, true);
21693 }
21694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21695         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21696         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21697         return ret_conv;
21698 }
21699
21700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21701         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21702         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21703         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21704         return tag_ptr(ret_conv, true);
21705 }
21706
21707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21708         LDKThirtyTwoBytes o_ref;
21709         CHECK((*env)->GetArrayLength(env, o) == 32);
21710         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21711         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21712         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_ok(o_ref);
21713         return tag_ptr(ret_conv, true);
21714 }
21715
21716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21717         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21718         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21719         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_err(e_conv);
21720         return tag_ptr(ret_conv, true);
21721 }
21722
21723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21724         LDKCResult_PaymentHashRetryableSendFailureZ* o_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(o);
21725         jboolean ret_conv = CResult_PaymentHashRetryableSendFailureZ_is_ok(o_conv);
21726         return ret_conv;
21727 }
21728
21729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21730         if (!ptr_is_owned(_res)) return;
21731         void* _res_ptr = untag_ptr(_res);
21732         CHECK_ACCESS(_res_ptr);
21733         LDKCResult_PaymentHashRetryableSendFailureZ _res_conv = *(LDKCResult_PaymentHashRetryableSendFailureZ*)(_res_ptr);
21734         FREE(untag_ptr(_res));
21735         CResult_PaymentHashRetryableSendFailureZ_free(_res_conv);
21736 }
21737
21738 static inline uint64_t CResult_PaymentHashRetryableSendFailureZ_clone_ptr(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR arg) {
21739         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21740         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(arg);
21741         return tag_ptr(ret_conv, true);
21742 }
21743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21744         LDKCResult_PaymentHashRetryableSendFailureZ* arg_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(arg);
21745         int64_t ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone_ptr(arg_conv);
21746         return ret_conv;
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21750         LDKCResult_PaymentHashRetryableSendFailureZ* orig_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(orig);
21751         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21752         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(orig_conv);
21753         return tag_ptr(ret_conv, true);
21754 }
21755
21756 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21757         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21758         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21759         return tag_ptr(ret_conv, true);
21760 }
21761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21762         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21763         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21764         return ret_conv;
21765 }
21766
21767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21768         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21769         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21770         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21771         return tag_ptr(ret_conv, true);
21772 }
21773
21774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21775         LDKThirtyTwoBytes a_ref;
21776         CHECK((*env)->GetArrayLength(env, a) == 32);
21777         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21778         LDKThirtyTwoBytes b_ref;
21779         CHECK((*env)->GetArrayLength(env, b) == 32);
21780         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21781         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21782         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21783         return tag_ptr(ret_conv, true);
21784 }
21785
21786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21787         if (!ptr_is_owned(_res)) return;
21788         void* _res_ptr = untag_ptr(_res);
21789         CHECK_ACCESS(_res_ptr);
21790         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21791         FREE(untag_ptr(_res));
21792         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21793 }
21794
21795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21796         void* o_ptr = untag_ptr(o);
21797         CHECK_ACCESS(o_ptr);
21798         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21799         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21800         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21801         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21802         return tag_ptr(ret_conv, true);
21803 }
21804
21805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21806         void* e_ptr = untag_ptr(e);
21807         CHECK_ACCESS(e_ptr);
21808         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21809         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21810         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21811         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21812         return tag_ptr(ret_conv, true);
21813 }
21814
21815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21816         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21817         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21818         return ret_conv;
21819 }
21820
21821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21822         if (!ptr_is_owned(_res)) return;
21823         void* _res_ptr = untag_ptr(_res);
21824         CHECK_ACCESS(_res_ptr);
21825         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21826         FREE(untag_ptr(_res));
21827         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21828 }
21829
21830 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21831         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21832         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21833         return tag_ptr(ret_conv, true);
21834 }
21835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21836         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21837         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21838         return ret_conv;
21839 }
21840
21841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21842         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21843         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21844         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21845         return tag_ptr(ret_conv, true);
21846 }
21847
21848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21849         LDKCVec_ThirtyTwoBytesZ _res_constr;
21850         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21851         if (_res_constr.datalen > 0)
21852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21853         else
21854                 _res_constr.data = NULL;
21855         for (size_t i = 0; i < _res_constr.datalen; i++) {
21856                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21857                 LDKThirtyTwoBytes _res_conv_8_ref;
21858                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21859                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21860                 _res_constr.data[i] = _res_conv_8_ref;
21861         }
21862         CVec_ThirtyTwoBytesZ_free(_res_constr);
21863 }
21864
21865 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21866         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21867         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21868         return tag_ptr(ret_conv, true);
21869 }
21870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21871         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21872         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21873         return ret_conv;
21874 }
21875
21876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21877         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21878         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21879         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21880         return tag_ptr(ret_conv, true);
21881 }
21882
21883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21884         LDKThirtyTwoBytes a_ref;
21885         CHECK((*env)->GetArrayLength(env, a) == 32);
21886         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21887         LDKThirtyTwoBytes b_ref;
21888         CHECK((*env)->GetArrayLength(env, b) == 32);
21889         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21890         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21891         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21892         return tag_ptr(ret_conv, true);
21893 }
21894
21895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21896         if (!ptr_is_owned(_res)) return;
21897         void* _res_ptr = untag_ptr(_res);
21898         CHECK_ACCESS(_res_ptr);
21899         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21900         FREE(untag_ptr(_res));
21901         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21902 }
21903
21904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21905         void* o_ptr = untag_ptr(o);
21906         CHECK_ACCESS(o_ptr);
21907         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21908         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21909         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21910         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21911         return tag_ptr(ret_conv, true);
21912 }
21913
21914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21915         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21916         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21917         return tag_ptr(ret_conv, true);
21918 }
21919
21920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21921         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21922         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21923         return ret_conv;
21924 }
21925
21926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21927         if (!ptr_is_owned(_res)) return;
21928         void* _res_ptr = untag_ptr(_res);
21929         CHECK_ACCESS(_res_ptr);
21930         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21931         FREE(untag_ptr(_res));
21932         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21933 }
21934
21935 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21936         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21937         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21938         return tag_ptr(ret_conv, true);
21939 }
21940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21941         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21942         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21943         return ret_conv;
21944 }
21945
21946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21947         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21948         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21949         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21950         return tag_ptr(ret_conv, true);
21951 }
21952
21953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21954         void* o_ptr = untag_ptr(o);
21955         CHECK_ACCESS(o_ptr);
21956         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21957         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21958         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21959         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21960         return tag_ptr(ret_conv, true);
21961 }
21962
21963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21964         void* e_ptr = untag_ptr(e);
21965         CHECK_ACCESS(e_ptr);
21966         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21967         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21968         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21969         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21970         return tag_ptr(ret_conv, true);
21971 }
21972
21973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21974         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21975         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21976         return ret_conv;
21977 }
21978
21979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21980         if (!ptr_is_owned(_res)) return;
21981         void* _res_ptr = untag_ptr(_res);
21982         CHECK_ACCESS(_res_ptr);
21983         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21984         FREE(untag_ptr(_res));
21985         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21986 }
21987
21988 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21989         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21990         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21991         return tag_ptr(ret_conv, true);
21992 }
21993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21994         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21995         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21996         return ret_conv;
21997 }
21998
21999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22000         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
22001         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
22002         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
22003         return tag_ptr(ret_conv, true);
22004 }
22005
22006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22007         LDKThirtyTwoBytes o_ref;
22008         CHECK((*env)->GetArrayLength(env, o) == 32);
22009         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22010         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22011         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
22012         return tag_ptr(ret_conv, true);
22013 }
22014
22015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
22016         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22017         *ret_conv = CResult_PaymentSecretNoneZ_err();
22018         return tag_ptr(ret_conv, true);
22019 }
22020
22021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22022         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
22023         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
22024         return ret_conv;
22025 }
22026
22027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22028         if (!ptr_is_owned(_res)) return;
22029         void* _res_ptr = untag_ptr(_res);
22030         CHECK_ACCESS(_res_ptr);
22031         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
22032         FREE(untag_ptr(_res));
22033         CResult_PaymentSecretNoneZ_free(_res_conv);
22034 }
22035
22036 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
22037         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22038         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
22039         return tag_ptr(ret_conv, true);
22040 }
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22042         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
22043         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
22044         return ret_conv;
22045 }
22046
22047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22048         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
22049         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22050         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
22051         return tag_ptr(ret_conv, true);
22052 }
22053
22054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22055         LDKThirtyTwoBytes o_ref;
22056         CHECK((*env)->GetArrayLength(env, o) == 32);
22057         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22058         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22059         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
22060         return tag_ptr(ret_conv, true);
22061 }
22062
22063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22064         void* e_ptr = untag_ptr(e);
22065         CHECK_ACCESS(e_ptr);
22066         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22067         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22068         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22069         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
22070         return tag_ptr(ret_conv, true);
22071 }
22072
22073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22074         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
22075         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
22076         return ret_conv;
22077 }
22078
22079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22080         if (!ptr_is_owned(_res)) return;
22081         void* _res_ptr = untag_ptr(_res);
22082         CHECK_ACCESS(_res_ptr);
22083         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
22084         FREE(untag_ptr(_res));
22085         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
22086 }
22087
22088 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
22089         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22090         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
22091         return tag_ptr(ret_conv, true);
22092 }
22093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22094         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
22095         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
22096         return ret_conv;
22097 }
22098
22099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22100         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
22101         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22102         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
22103         return tag_ptr(ret_conv, true);
22104 }
22105
22106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22107         LDKThirtyTwoBytes o_ref;
22108         CHECK((*env)->GetArrayLength(env, o) == 32);
22109         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22110         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22111         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
22112         return tag_ptr(ret_conv, true);
22113 }
22114
22115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22116         void* e_ptr = untag_ptr(e);
22117         CHECK_ACCESS(e_ptr);
22118         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22119         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22120         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22121         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
22122         return tag_ptr(ret_conv, true);
22123 }
22124
22125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22126         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
22127         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
22128         return ret_conv;
22129 }
22130
22131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22132         if (!ptr_is_owned(_res)) return;
22133         void* _res_ptr = untag_ptr(_res);
22134         CHECK_ACCESS(_res_ptr);
22135         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
22136         FREE(untag_ptr(_res));
22137         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
22138 }
22139
22140 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
22141         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22142         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
22143         return tag_ptr(ret_conv, true);
22144 }
22145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22146         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
22147         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
22148         return ret_conv;
22149 }
22150
22151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22152         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
22153         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22154         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
22155         return tag_ptr(ret_conv, true);
22156 }
22157
22158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22159         LDKCounterpartyForwardingInfo o_conv;
22160         o_conv.inner = untag_ptr(o);
22161         o_conv.is_owned = ptr_is_owned(o);
22162         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22163         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
22164         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22165         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
22166         return tag_ptr(ret_conv, true);
22167 }
22168
22169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22170         void* e_ptr = untag_ptr(e);
22171         CHECK_ACCESS(e_ptr);
22172         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22173         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22174         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22175         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
22176         return tag_ptr(ret_conv, true);
22177 }
22178
22179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22180         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
22181         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
22182         return ret_conv;
22183 }
22184
22185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22186         if (!ptr_is_owned(_res)) return;
22187         void* _res_ptr = untag_ptr(_res);
22188         CHECK_ACCESS(_res_ptr);
22189         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
22190         FREE(untag_ptr(_res));
22191         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
22192 }
22193
22194 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
22195         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22196         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
22197         return tag_ptr(ret_conv, true);
22198 }
22199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22200         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
22201         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
22202         return ret_conv;
22203 }
22204
22205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22206         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
22207         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22208         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
22209         return tag_ptr(ret_conv, true);
22210 }
22211
22212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22213         LDKChannelCounterparty o_conv;
22214         o_conv.inner = untag_ptr(o);
22215         o_conv.is_owned = ptr_is_owned(o);
22216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22217         o_conv = ChannelCounterparty_clone(&o_conv);
22218         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22219         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
22220         return tag_ptr(ret_conv, true);
22221 }
22222
22223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22224         void* e_ptr = untag_ptr(e);
22225         CHECK_ACCESS(e_ptr);
22226         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22227         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22228         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22229         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
22230         return tag_ptr(ret_conv, true);
22231 }
22232
22233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22234         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
22235         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
22236         return ret_conv;
22237 }
22238
22239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22240         if (!ptr_is_owned(_res)) return;
22241         void* _res_ptr = untag_ptr(_res);
22242         CHECK_ACCESS(_res_ptr);
22243         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
22244         FREE(untag_ptr(_res));
22245         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
22246 }
22247
22248 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
22249         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22250         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
22251         return tag_ptr(ret_conv, true);
22252 }
22253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22254         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
22255         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
22256         return ret_conv;
22257 }
22258
22259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22260         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
22261         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22262         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
22263         return tag_ptr(ret_conv, true);
22264 }
22265
22266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22267         LDKChannelDetails o_conv;
22268         o_conv.inner = untag_ptr(o);
22269         o_conv.is_owned = ptr_is_owned(o);
22270         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22271         o_conv = ChannelDetails_clone(&o_conv);
22272         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22273         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
22274         return tag_ptr(ret_conv, true);
22275 }
22276
22277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22278         void* e_ptr = untag_ptr(e);
22279         CHECK_ACCESS(e_ptr);
22280         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22281         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22282         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22283         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
22284         return tag_ptr(ret_conv, true);
22285 }
22286
22287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22288         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
22289         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
22290         return ret_conv;
22291 }
22292
22293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22294         if (!ptr_is_owned(_res)) return;
22295         void* _res_ptr = untag_ptr(_res);
22296         CHECK_ACCESS(_res_ptr);
22297         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
22298         FREE(untag_ptr(_res));
22299         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
22300 }
22301
22302 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
22303         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22304         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
22305         return tag_ptr(ret_conv, true);
22306 }
22307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22308         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
22309         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
22310         return ret_conv;
22311 }
22312
22313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22314         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
22315         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22316         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
22317         return tag_ptr(ret_conv, true);
22318 }
22319
22320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22321         LDKPhantomRouteHints o_conv;
22322         o_conv.inner = untag_ptr(o);
22323         o_conv.is_owned = ptr_is_owned(o);
22324         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22325         o_conv = PhantomRouteHints_clone(&o_conv);
22326         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22327         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
22328         return tag_ptr(ret_conv, true);
22329 }
22330
22331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22332         void* e_ptr = untag_ptr(e);
22333         CHECK_ACCESS(e_ptr);
22334         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22335         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22336         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22337         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
22338         return tag_ptr(ret_conv, true);
22339 }
22340
22341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22342         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
22343         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
22344         return ret_conv;
22345 }
22346
22347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22348         if (!ptr_is_owned(_res)) return;
22349         void* _res_ptr = untag_ptr(_res);
22350         CHECK_ACCESS(_res_ptr);
22351         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
22352         FREE(untag_ptr(_res));
22353         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
22354 }
22355
22356 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
22357         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22358         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
22359         return tag_ptr(ret_conv, true);
22360 }
22361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22362         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
22363         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
22364         return ret_conv;
22365 }
22366
22367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22368         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
22369         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22370         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
22371         return tag_ptr(ret_conv, true);
22372 }
22373
22374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22375         LDKCVec_ChannelMonitorZ _res_constr;
22376         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22377         if (_res_constr.datalen > 0)
22378                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22379         else
22380                 _res_constr.data = NULL;
22381         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22382         for (size_t q = 0; q < _res_constr.datalen; q++) {
22383                 int64_t _res_conv_16 = _res_vals[q];
22384                 LDKChannelMonitor _res_conv_16_conv;
22385                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
22386                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
22387                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22388                 _res_constr.data[q] = _res_conv_16_conv;
22389         }
22390         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22391         CVec_ChannelMonitorZ_free(_res_constr);
22392 }
22393
22394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22395         LDKThirtyTwoBytes a_ref;
22396         CHECK((*env)->GetArrayLength(env, a) == 32);
22397         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22398         LDKChannelManager b_conv;
22399         b_conv.inner = untag_ptr(b);
22400         b_conv.is_owned = ptr_is_owned(b);
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22402         // WARNING: we need a move here but no clone is available for LDKChannelManager
22403         
22404         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
22405         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
22406         return tag_ptr(ret_conv, true);
22407 }
22408
22409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22410         if (!ptr_is_owned(_res)) return;
22411         void* _res_ptr = untag_ptr(_res);
22412         CHECK_ACCESS(_res_ptr);
22413         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
22414         FREE(untag_ptr(_res));
22415         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
22416 }
22417
22418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22419         void* o_ptr = untag_ptr(o);
22420         CHECK_ACCESS(o_ptr);
22421         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
22422         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
22423         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22424         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
22425         return tag_ptr(ret_conv, true);
22426 }
22427
22428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22429         void* e_ptr = untag_ptr(e);
22430         CHECK_ACCESS(e_ptr);
22431         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22432         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22433         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22434         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
22435         return tag_ptr(ret_conv, true);
22436 }
22437
22438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22439         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
22440         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
22441         return ret_conv;
22442 }
22443
22444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22445         if (!ptr_is_owned(_res)) return;
22446         void* _res_ptr = untag_ptr(_res);
22447         CHECK_ACCESS(_res_ptr);
22448         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
22449         FREE(untag_ptr(_res));
22450         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
22451 }
22452
22453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22454         LDKChannelConfig o_conv;
22455         o_conv.inner = untag_ptr(o);
22456         o_conv.is_owned = ptr_is_owned(o);
22457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22458         o_conv = ChannelConfig_clone(&o_conv);
22459         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22460         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
22461         return tag_ptr(ret_conv, true);
22462 }
22463
22464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22465         void* e_ptr = untag_ptr(e);
22466         CHECK_ACCESS(e_ptr);
22467         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22468         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22469         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22470         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
22471         return tag_ptr(ret_conv, true);
22472 }
22473
22474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22475         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
22476         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
22477         return ret_conv;
22478 }
22479
22480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22481         if (!ptr_is_owned(_res)) return;
22482         void* _res_ptr = untag_ptr(_res);
22483         CHECK_ACCESS(_res_ptr);
22484         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
22485         FREE(untag_ptr(_res));
22486         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
22487 }
22488
22489 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
22490         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22491         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
22492         return tag_ptr(ret_conv, true);
22493 }
22494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22495         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
22496         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
22497         return ret_conv;
22498 }
22499
22500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22501         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
22502         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22503         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
22504         return tag_ptr(ret_conv, true);
22505 }
22506
22507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22508         void* o_ptr = untag_ptr(o);
22509         CHECK_ACCESS(o_ptr);
22510         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
22511         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
22512         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22513         *ret_copy = COption_APIErrorZ_some(o_conv);
22514         int64_t ret_ref = tag_ptr(ret_copy, true);
22515         return ret_ref;
22516 }
22517
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1none(JNIEnv *env, jclass clz) {
22519         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22520         *ret_copy = COption_APIErrorZ_none();
22521         int64_t ret_ref = tag_ptr(ret_copy, true);
22522         return ret_ref;
22523 }
22524
22525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22526         if (!ptr_is_owned(_res)) return;
22527         void* _res_ptr = untag_ptr(_res);
22528         CHECK_ACCESS(_res_ptr);
22529         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
22530         FREE(untag_ptr(_res));
22531         COption_APIErrorZ_free(_res_conv);
22532 }
22533
22534 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
22535         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22536         *ret_copy = COption_APIErrorZ_clone(arg);
22537         int64_t ret_ref = tag_ptr(ret_copy, true);
22538         return ret_ref;
22539 }
22540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22541         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
22542         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
22543         return ret_conv;
22544 }
22545
22546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22547         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
22548         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22549         *ret_copy = COption_APIErrorZ_clone(orig_conv);
22550         int64_t ret_ref = tag_ptr(ret_copy, true);
22551         return ret_ref;
22552 }
22553
22554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22555         void* o_ptr = untag_ptr(o);
22556         CHECK_ACCESS(o_ptr);
22557         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
22558         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
22559         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22560         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
22561         return tag_ptr(ret_conv, true);
22562 }
22563
22564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22565         void* e_ptr = untag_ptr(e);
22566         CHECK_ACCESS(e_ptr);
22567         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22568         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22569         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22570         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
22571         return tag_ptr(ret_conv, true);
22572 }
22573
22574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22575         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
22576         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
22577         return ret_conv;
22578 }
22579
22580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22581         if (!ptr_is_owned(_res)) return;
22582         void* _res_ptr = untag_ptr(_res);
22583         CHECK_ACCESS(_res_ptr);
22584         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
22585         FREE(untag_ptr(_res));
22586         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
22587 }
22588
22589 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
22590         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22591         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
22592         return tag_ptr(ret_conv, true);
22593 }
22594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22595         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
22596         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
22597         return ret_conv;
22598 }
22599
22600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22601         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
22602         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22603         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
22604         return tag_ptr(ret_conv, true);
22605 }
22606
22607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22608         LDKUntrustedString o_conv;
22609         o_conv.inner = untag_ptr(o);
22610         o_conv.is_owned = ptr_is_owned(o);
22611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22612         o_conv = UntrustedString_clone(&o_conv);
22613         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22614         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
22615         return tag_ptr(ret_conv, true);
22616 }
22617
22618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22619         void* e_ptr = untag_ptr(e);
22620         CHECK_ACCESS(e_ptr);
22621         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22622         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22623         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22624         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
22625         return tag_ptr(ret_conv, true);
22626 }
22627
22628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22629         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
22630         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
22631         return ret_conv;
22632 }
22633
22634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22635         if (!ptr_is_owned(_res)) return;
22636         void* _res_ptr = untag_ptr(_res);
22637         CHECK_ACCESS(_res_ptr);
22638         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
22639         FREE(untag_ptr(_res));
22640         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
22641 }
22642
22643 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
22644         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22645         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
22646         return tag_ptr(ret_conv, true);
22647 }
22648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22649         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
22650         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
22651         return ret_conv;
22652 }
22653
22654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22655         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
22656         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22657         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
22658         return tag_ptr(ret_conv, true);
22659 }
22660
22661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22662         LDKOutPoint o_conv;
22663         o_conv.inner = untag_ptr(o);
22664         o_conv.is_owned = ptr_is_owned(o);
22665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22666         o_conv = OutPoint_clone(&o_conv);
22667         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22668         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
22669         return tag_ptr(ret_conv, true);
22670 }
22671
22672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22673         void* e_ptr = untag_ptr(e);
22674         CHECK_ACCESS(e_ptr);
22675         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22676         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22677         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22678         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
22679         return tag_ptr(ret_conv, true);
22680 }
22681
22682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22683         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
22684         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
22685         return ret_conv;
22686 }
22687
22688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22689         if (!ptr_is_owned(_res)) return;
22690         void* _res_ptr = untag_ptr(_res);
22691         CHECK_ACCESS(_res_ptr);
22692         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
22693         FREE(untag_ptr(_res));
22694         CResult_OutPointDecodeErrorZ_free(_res_conv);
22695 }
22696
22697 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
22698         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22699         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
22700         return tag_ptr(ret_conv, true);
22701 }
22702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22703         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
22704         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
22705         return ret_conv;
22706 }
22707
22708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22709         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
22710         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22711         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
22712         return tag_ptr(ret_conv, true);
22713 }
22714
22715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22716         void* o_ptr = untag_ptr(o);
22717         CHECK_ACCESS(o_ptr);
22718         LDKType o_conv = *(LDKType*)(o_ptr);
22719         if (o_conv.free == LDKType_JCalls_free) {
22720                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22721                 LDKType_JCalls_cloned(&o_conv);
22722         }
22723         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22724         *ret_copy = COption_TypeZ_some(o_conv);
22725         int64_t ret_ref = tag_ptr(ret_copy, true);
22726         return ret_ref;
22727 }
22728
22729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
22730         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22731         *ret_copy = COption_TypeZ_none();
22732         int64_t ret_ref = tag_ptr(ret_copy, true);
22733         return ret_ref;
22734 }
22735
22736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22737         if (!ptr_is_owned(_res)) return;
22738         void* _res_ptr = untag_ptr(_res);
22739         CHECK_ACCESS(_res_ptr);
22740         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22741         FREE(untag_ptr(_res));
22742         COption_TypeZ_free(_res_conv);
22743 }
22744
22745 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22746         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22747         *ret_copy = COption_TypeZ_clone(arg);
22748         int64_t ret_ref = tag_ptr(ret_copy, true);
22749         return ret_ref;
22750 }
22751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22752         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22753         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22754         return ret_conv;
22755 }
22756
22757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22758         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22759         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22760         *ret_copy = COption_TypeZ_clone(orig_conv);
22761         int64_t ret_ref = tag_ptr(ret_copy, true);
22762         return ret_ref;
22763 }
22764
22765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22766         void* o_ptr = untag_ptr(o);
22767         CHECK_ACCESS(o_ptr);
22768         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22769         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22770         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22771         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22772         return tag_ptr(ret_conv, true);
22773 }
22774
22775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22776         void* e_ptr = untag_ptr(e);
22777         CHECK_ACCESS(e_ptr);
22778         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22779         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22780         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22781         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22782         return tag_ptr(ret_conv, true);
22783 }
22784
22785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22786         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22787         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22788         return ret_conv;
22789 }
22790
22791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22792         if (!ptr_is_owned(_res)) return;
22793         void* _res_ptr = untag_ptr(_res);
22794         CHECK_ACCESS(_res_ptr);
22795         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22796         FREE(untag_ptr(_res));
22797         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22798 }
22799
22800 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22801         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22802         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22803         return tag_ptr(ret_conv, true);
22804 }
22805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22806         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22807         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22808         return ret_conv;
22809 }
22810
22811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22812         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22813         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22814         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22815         return tag_ptr(ret_conv, true);
22816 }
22817
22818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22819         LDKThirtyTwoBytes o_ref;
22820         CHECK((*env)->GetArrayLength(env, o) == 32);
22821         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22822         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22823         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
22824         return tag_ptr(ret_conv, true);
22825 }
22826
22827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22828         void* e_ptr = untag_ptr(e);
22829         CHECK_ACCESS(e_ptr);
22830         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22831         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22832         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22833         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
22834         return tag_ptr(ret_conv, true);
22835 }
22836
22837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22838         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
22839         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
22840         return ret_conv;
22841 }
22842
22843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22844         if (!ptr_is_owned(_res)) return;
22845         void* _res_ptr = untag_ptr(_res);
22846         CHECK_ACCESS(_res_ptr);
22847         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
22848         FREE(untag_ptr(_res));
22849         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
22850 }
22851
22852 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
22853         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22854         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
22855         return tag_ptr(ret_conv, true);
22856 }
22857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22858         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
22859         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
22860         return ret_conv;
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22864         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
22865         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22866         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
22867         return tag_ptr(ret_conv, true);
22868 }
22869
22870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22871         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22872         *ret_conv = CResult_NonePaymentErrorZ_ok();
22873         return tag_ptr(ret_conv, true);
22874 }
22875
22876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22877         void* e_ptr = untag_ptr(e);
22878         CHECK_ACCESS(e_ptr);
22879         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22880         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22881         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22882         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22883         return tag_ptr(ret_conv, true);
22884 }
22885
22886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22887         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22888         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22889         return ret_conv;
22890 }
22891
22892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22893         if (!ptr_is_owned(_res)) return;
22894         void* _res_ptr = untag_ptr(_res);
22895         CHECK_ACCESS(_res_ptr);
22896         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22897         FREE(untag_ptr(_res));
22898         CResult_NonePaymentErrorZ_free(_res_conv);
22899 }
22900
22901 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22902         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22903         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22904         return tag_ptr(ret_conv, true);
22905 }
22906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22907         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22908         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22909         return ret_conv;
22910 }
22911
22912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22913         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22914         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22915         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22916         return tag_ptr(ret_conv, true);
22917 }
22918
22919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22920         LDKStr o_conv = java_to_owned_str(env, o);
22921         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22922         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22923         return tag_ptr(ret_conv, true);
22924 }
22925
22926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22927         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22928         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22929         *ret_conv = CResult_StringErrorZ_err(e_conv);
22930         return tag_ptr(ret_conv, true);
22931 }
22932
22933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22934         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22935         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22936         return ret_conv;
22937 }
22938
22939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22940         if (!ptr_is_owned(_res)) return;
22941         void* _res_ptr = untag_ptr(_res);
22942         CHECK_ACCESS(_res_ptr);
22943         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22944         FREE(untag_ptr(_res));
22945         CResult_StringErrorZ_free(_res_conv);
22946 }
22947
22948 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22949         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22950         *ret_conv = CResult_StringErrorZ_clone(arg);
22951         return tag_ptr(ret_conv, true);
22952 }
22953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22954         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22955         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22956         return ret_conv;
22957 }
22958
22959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22960         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22961         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22962         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22963         return tag_ptr(ret_conv, true);
22964 }
22965
22966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22967         LDKChannelMonitorUpdate o_conv;
22968         o_conv.inner = untag_ptr(o);
22969         o_conv.is_owned = ptr_is_owned(o);
22970         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22971         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22972         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22973         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22974         return tag_ptr(ret_conv, true);
22975 }
22976
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22978         void* e_ptr = untag_ptr(e);
22979         CHECK_ACCESS(e_ptr);
22980         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22981         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22982         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22983         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22984         return tag_ptr(ret_conv, true);
22985 }
22986
22987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22988         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22989         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22990         return ret_conv;
22991 }
22992
22993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22994         if (!ptr_is_owned(_res)) return;
22995         void* _res_ptr = untag_ptr(_res);
22996         CHECK_ACCESS(_res_ptr);
22997         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22998         FREE(untag_ptr(_res));
22999         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
23000 }
23001
23002 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
23003         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23004         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
23005         return tag_ptr(ret_conv, true);
23006 }
23007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23008         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
23009         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
23010         return ret_conv;
23011 }
23012
23013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23014         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
23015         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23016         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
23017         return tag_ptr(ret_conv, true);
23018 }
23019
23020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23021         void* o_ptr = untag_ptr(o);
23022         CHECK_ACCESS(o_ptr);
23023         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
23024         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
23025         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23026         *ret_copy = COption_MonitorEventZ_some(o_conv);
23027         int64_t ret_ref = tag_ptr(ret_copy, true);
23028         return ret_ref;
23029 }
23030
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
23032         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23033         *ret_copy = COption_MonitorEventZ_none();
23034         int64_t ret_ref = tag_ptr(ret_copy, true);
23035         return ret_ref;
23036 }
23037
23038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23039         if (!ptr_is_owned(_res)) return;
23040         void* _res_ptr = untag_ptr(_res);
23041         CHECK_ACCESS(_res_ptr);
23042         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
23043         FREE(untag_ptr(_res));
23044         COption_MonitorEventZ_free(_res_conv);
23045 }
23046
23047 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
23048         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23049         *ret_copy = COption_MonitorEventZ_clone(arg);
23050         int64_t ret_ref = tag_ptr(ret_copy, true);
23051         return ret_ref;
23052 }
23053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23054         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
23055         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
23056         return ret_conv;
23057 }
23058
23059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23060         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
23061         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23062         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
23063         int64_t ret_ref = tag_ptr(ret_copy, true);
23064         return ret_ref;
23065 }
23066
23067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23068         void* o_ptr = untag_ptr(o);
23069         CHECK_ACCESS(o_ptr);
23070         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
23071         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
23072         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23073         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
23074         return tag_ptr(ret_conv, true);
23075 }
23076
23077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23078         void* e_ptr = untag_ptr(e);
23079         CHECK_ACCESS(e_ptr);
23080         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23081         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23082         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23083         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
23084         return tag_ptr(ret_conv, true);
23085 }
23086
23087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23088         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
23089         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
23090         return ret_conv;
23091 }
23092
23093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23094         if (!ptr_is_owned(_res)) return;
23095         void* _res_ptr = untag_ptr(_res);
23096         CHECK_ACCESS(_res_ptr);
23097         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
23098         FREE(untag_ptr(_res));
23099         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
23100 }
23101
23102 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
23103         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23104         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
23105         return tag_ptr(ret_conv, true);
23106 }
23107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23108         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
23109         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
23110         return ret_conv;
23111 }
23112
23113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23114         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
23115         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23116         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
23117         return tag_ptr(ret_conv, true);
23118 }
23119
23120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23121         LDKHTLCUpdate o_conv;
23122         o_conv.inner = untag_ptr(o);
23123         o_conv.is_owned = ptr_is_owned(o);
23124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23125         o_conv = HTLCUpdate_clone(&o_conv);
23126         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23127         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
23128         return tag_ptr(ret_conv, true);
23129 }
23130
23131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23132         void* e_ptr = untag_ptr(e);
23133         CHECK_ACCESS(e_ptr);
23134         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23135         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23136         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23137         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
23138         return tag_ptr(ret_conv, true);
23139 }
23140
23141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23142         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
23143         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
23144         return ret_conv;
23145 }
23146
23147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23148         if (!ptr_is_owned(_res)) return;
23149         void* _res_ptr = untag_ptr(_res);
23150         CHECK_ACCESS(_res_ptr);
23151         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
23152         FREE(untag_ptr(_res));
23153         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
23154 }
23155
23156 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
23157         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23158         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
23159         return tag_ptr(ret_conv, true);
23160 }
23161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23162         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
23163         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
23164         return ret_conv;
23165 }
23166
23167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23168         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
23169         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23170         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
23171         return tag_ptr(ret_conv, true);
23172 }
23173
23174 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
23175         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23176         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
23177         return tag_ptr(ret_conv, true);
23178 }
23179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23180         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
23181         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
23182         return ret_conv;
23183 }
23184
23185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23186         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
23187         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23188         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
23189         return tag_ptr(ret_conv, true);
23190 }
23191
23192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
23193         LDKOutPoint a_conv;
23194         a_conv.inner = untag_ptr(a);
23195         a_conv.is_owned = ptr_is_owned(a);
23196         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23197         a_conv = OutPoint_clone(&a_conv);
23198         LDKCVec_u8Z b_ref;
23199         b_ref.datalen = (*env)->GetArrayLength(env, b);
23200         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23201         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23202         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23203         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
23204         return tag_ptr(ret_conv, true);
23205 }
23206
23207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23208         if (!ptr_is_owned(_res)) return;
23209         void* _res_ptr = untag_ptr(_res);
23210         CHECK_ACCESS(_res_ptr);
23211         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
23212         FREE(untag_ptr(_res));
23213         C2Tuple_OutPointScriptZ_free(_res_conv);
23214 }
23215
23216 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
23217         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23218         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
23219         return tag_ptr(ret_conv, true);
23220 }
23221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23222         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
23223         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
23224         return ret_conv;
23225 }
23226
23227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23228         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
23229         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23230         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
23231         return tag_ptr(ret_conv, true);
23232 }
23233
23234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
23235         LDKCVec_u8Z b_ref;
23236         b_ref.datalen = (*env)->GetArrayLength(env, b);
23237         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23238         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23239         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23240         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
23241         return tag_ptr(ret_conv, true);
23242 }
23243
23244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23245         if (!ptr_is_owned(_res)) return;
23246         void* _res_ptr = untag_ptr(_res);
23247         CHECK_ACCESS(_res_ptr);
23248         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
23249         FREE(untag_ptr(_res));
23250         C2Tuple_u32ScriptZ_free(_res_conv);
23251 }
23252
23253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23254         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
23255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23256         if (_res_constr.datalen > 0)
23257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23258         else
23259                 _res_constr.data = NULL;
23260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23261         for (size_t v = 0; v < _res_constr.datalen; v++) {
23262                 int64_t _res_conv_21 = _res_vals[v];
23263                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
23264                 CHECK_ACCESS(_res_conv_21_ptr);
23265                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
23266                 FREE(untag_ptr(_res_conv_21));
23267                 _res_constr.data[v] = _res_conv_21_conv;
23268         }
23269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23270         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
23271 }
23272
23273 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
23274         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23275         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
23276         return tag_ptr(ret_conv, true);
23277 }
23278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23279         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
23280         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
23281         return ret_conv;
23282 }
23283
23284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23285         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
23286         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23287         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
23288         return tag_ptr(ret_conv, true);
23289 }
23290
23291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23292         LDKThirtyTwoBytes a_ref;
23293         CHECK((*env)->GetArrayLength(env, a) == 32);
23294         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23295         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
23296         b_constr.datalen = (*env)->GetArrayLength(env, b);
23297         if (b_constr.datalen > 0)
23298                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23299         else
23300                 b_constr.data = NULL;
23301         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23302         for (size_t v = 0; v < b_constr.datalen; v++) {
23303                 int64_t b_conv_21 = b_vals[v];
23304                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
23305                 CHECK_ACCESS(b_conv_21_ptr);
23306                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
23307                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
23308                 b_constr.data[v] = b_conv_21_conv;
23309         }
23310         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23311         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23312         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
23313         return tag_ptr(ret_conv, true);
23314 }
23315
23316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23317         if (!ptr_is_owned(_res)) return;
23318         void* _res_ptr = untag_ptr(_res);
23319         CHECK_ACCESS(_res_ptr);
23320         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
23321         FREE(untag_ptr(_res));
23322         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
23323 }
23324
23325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23326         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
23327         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23328         if (_res_constr.datalen > 0)
23329                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
23330         else
23331                 _res_constr.data = NULL;
23332         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23333         for (size_t o = 0; o < _res_constr.datalen; o++) {
23334                 int64_t _res_conv_40 = _res_vals[o];
23335                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23336                 CHECK_ACCESS(_res_conv_40_ptr);
23337                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
23338                 FREE(untag_ptr(_res_conv_40));
23339                 _res_constr.data[o] = _res_conv_40_conv;
23340         }
23341         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23342         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
23343 }
23344
23345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23346         LDKCVec_EventZ _res_constr;
23347         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23348         if (_res_constr.datalen > 0)
23349                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
23350         else
23351                 _res_constr.data = NULL;
23352         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23353         for (size_t h = 0; h < _res_constr.datalen; h++) {
23354                 int64_t _res_conv_7 = _res_vals[h];
23355                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
23356                 CHECK_ACCESS(_res_conv_7_ptr);
23357                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
23358                 FREE(untag_ptr(_res_conv_7));
23359                 _res_constr.data[h] = _res_conv_7_conv;
23360         }
23361         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23362         CVec_EventZ_free(_res_constr);
23363 }
23364
23365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
23366         LDKCVec_TransactionZ _res_constr;
23367         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23368         if (_res_constr.datalen > 0)
23369                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
23370         else
23371                 _res_constr.data = NULL;
23372         for (size_t i = 0; i < _res_constr.datalen; i++) {
23373                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
23374                 LDKTransaction _res_conv_8_ref;
23375                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
23376                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
23377                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
23378                 _res_conv_8_ref.data_is_owned = true;
23379                 _res_constr.data[i] = _res_conv_8_ref;
23380         }
23381         CVec_TransactionZ_free(_res_constr);
23382 }
23383
23384 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
23385         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23386         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
23387         return tag_ptr(ret_conv, true);
23388 }
23389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23390         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
23391         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
23392         return ret_conv;
23393 }
23394
23395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23396         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
23397         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23398         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
23399         return tag_ptr(ret_conv, true);
23400 }
23401
23402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
23403         void* b_ptr = untag_ptr(b);
23404         CHECK_ACCESS(b_ptr);
23405         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
23406         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
23407         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23408         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
23409         return tag_ptr(ret_conv, true);
23410 }
23411
23412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23413         if (!ptr_is_owned(_res)) return;
23414         void* _res_ptr = untag_ptr(_res);
23415         CHECK_ACCESS(_res_ptr);
23416         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
23417         FREE(untag_ptr(_res));
23418         C2Tuple_u32TxOutZ_free(_res_conv);
23419 }
23420
23421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23422         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
23423         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23424         if (_res_constr.datalen > 0)
23425                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23426         else
23427                 _res_constr.data = NULL;
23428         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23429         for (size_t u = 0; u < _res_constr.datalen; u++) {
23430                 int64_t _res_conv_20 = _res_vals[u];
23431                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
23432                 CHECK_ACCESS(_res_conv_20_ptr);
23433                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
23434                 FREE(untag_ptr(_res_conv_20));
23435                 _res_constr.data[u] = _res_conv_20_conv;
23436         }
23437         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23438         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
23439 }
23440
23441 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
23442         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23443         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
23444         return tag_ptr(ret_conv, true);
23445 }
23446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23447         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
23448         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
23449         return ret_conv;
23450 }
23451
23452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23453         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
23454         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23455         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
23456         return tag_ptr(ret_conv, true);
23457 }
23458
23459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23460         LDKThirtyTwoBytes a_ref;
23461         CHECK((*env)->GetArrayLength(env, a) == 32);
23462         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23463         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
23464         b_constr.datalen = (*env)->GetArrayLength(env, b);
23465         if (b_constr.datalen > 0)
23466                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23467         else
23468                 b_constr.data = NULL;
23469         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23470         for (size_t u = 0; u < b_constr.datalen; u++) {
23471                 int64_t b_conv_20 = b_vals[u];
23472                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
23473                 CHECK_ACCESS(b_conv_20_ptr);
23474                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
23475                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
23476                 b_constr.data[u] = b_conv_20_conv;
23477         }
23478         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23479         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23480         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
23481         return tag_ptr(ret_conv, true);
23482 }
23483
23484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23485         if (!ptr_is_owned(_res)) return;
23486         void* _res_ptr = untag_ptr(_res);
23487         CHECK_ACCESS(_res_ptr);
23488         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
23489         FREE(untag_ptr(_res));
23490         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
23491 }
23492
23493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23494         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
23495         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23496         if (_res_constr.datalen > 0)
23497                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
23498         else
23499                 _res_constr.data = NULL;
23500         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23501         for (size_t n = 0; n < _res_constr.datalen; n++) {
23502                 int64_t _res_conv_39 = _res_vals[n];
23503                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
23504                 CHECK_ACCESS(_res_conv_39_ptr);
23505                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
23506                 FREE(untag_ptr(_res_conv_39));
23507                 _res_constr.data[n] = _res_conv_39_conv;
23508         }
23509         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23510         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
23511 }
23512
23513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23514         LDKCVec_BalanceZ _res_constr;
23515         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23516         if (_res_constr.datalen > 0)
23517                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
23518         else
23519                 _res_constr.data = NULL;
23520         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23521         for (size_t j = 0; j < _res_constr.datalen; j++) {
23522                 int64_t _res_conv_9 = _res_vals[j];
23523                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
23524                 CHECK_ACCESS(_res_conv_9_ptr);
23525                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
23526                 FREE(untag_ptr(_res_conv_9));
23527                 _res_constr.data[j] = _res_conv_9_conv;
23528         }
23529         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23530         CVec_BalanceZ_free(_res_constr);
23531 }
23532
23533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23534         void* o_ptr = untag_ptr(o);
23535         CHECK_ACCESS(o_ptr);
23536         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
23537         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
23538         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23539         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
23540         return tag_ptr(ret_conv, true);
23541 }
23542
23543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23544         void* e_ptr = untag_ptr(e);
23545         CHECK_ACCESS(e_ptr);
23546         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23547         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23548         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23549         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
23550         return tag_ptr(ret_conv, true);
23551 }
23552
23553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23554         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
23555         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
23556         return ret_conv;
23557 }
23558
23559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23560         if (!ptr_is_owned(_res)) return;
23561         void* _res_ptr = untag_ptr(_res);
23562         CHECK_ACCESS(_res_ptr);
23563         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
23564         FREE(untag_ptr(_res));
23565         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
23566 }
23567
23568 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
23569         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23570         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
23571         return tag_ptr(ret_conv, true);
23572 }
23573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23574         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
23575         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
23576         return ret_conv;
23577 }
23578
23579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23580         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
23581         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23582         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
23583         return tag_ptr(ret_conv, true);
23584 }
23585
23586 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
23587         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23588         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
23589         return tag_ptr(ret_conv, true);
23590 }
23591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23592         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
23593         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
23594         return ret_conv;
23595 }
23596
23597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23598         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
23599         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23600         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
23601         return tag_ptr(ret_conv, true);
23602 }
23603
23604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23605         LDKPublicKey a_ref;
23606         CHECK((*env)->GetArrayLength(env, a) == 33);
23607         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23608         void* b_ptr = untag_ptr(b);
23609         CHECK_ACCESS(b_ptr);
23610         LDKType b_conv = *(LDKType*)(b_ptr);
23611         if (b_conv.free == LDKType_JCalls_free) {
23612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23613                 LDKType_JCalls_cloned(&b_conv);
23614         }
23615         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23616         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
23617         return tag_ptr(ret_conv, true);
23618 }
23619
23620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23621         if (!ptr_is_owned(_res)) return;
23622         void* _res_ptr = untag_ptr(_res);
23623         CHECK_ACCESS(_res_ptr);
23624         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
23625         FREE(untag_ptr(_res));
23626         C2Tuple_PublicKeyTypeZ_free(_res_conv);
23627 }
23628
23629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23630         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
23631         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23632         if (_res_constr.datalen > 0)
23633                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
23634         else
23635                 _res_constr.data = NULL;
23636         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23637         for (size_t z = 0; z < _res_constr.datalen; z++) {
23638                 int64_t _res_conv_25 = _res_vals[z];
23639                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
23640                 CHECK_ACCESS(_res_conv_25_ptr);
23641                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
23642                 FREE(untag_ptr(_res_conv_25));
23643                 _res_constr.data[z] = _res_conv_25_conv;
23644         }
23645         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23646         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
23647 }
23648
23649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23650         void* o_ptr = untag_ptr(o);
23651         CHECK_ACCESS(o_ptr);
23652         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
23653         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
23654                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23655                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
23656         }
23657         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23658         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
23659         int64_t ret_ref = tag_ptr(ret_copy, true);
23660         return ret_ref;
23661 }
23662
23663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
23664         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23665         *ret_copy = COption_CustomOnionMessageContentsZ_none();
23666         int64_t ret_ref = tag_ptr(ret_copy, true);
23667         return ret_ref;
23668 }
23669
23670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23671         if (!ptr_is_owned(_res)) return;
23672         void* _res_ptr = untag_ptr(_res);
23673         CHECK_ACCESS(_res_ptr);
23674         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
23675         FREE(untag_ptr(_res));
23676         COption_CustomOnionMessageContentsZ_free(_res_conv);
23677 }
23678
23679 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
23680         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23681         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
23682         int64_t ret_ref = tag_ptr(ret_copy, true);
23683         return ret_ref;
23684 }
23685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23686         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
23687         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
23688         return ret_conv;
23689 }
23690
23691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23692         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
23693         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23694         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
23695         int64_t ret_ref = tag_ptr(ret_copy, true);
23696         return ret_ref;
23697 }
23698
23699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23700         void* o_ptr = untag_ptr(o);
23701         CHECK_ACCESS(o_ptr);
23702         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
23703         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
23704         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23705         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
23706         return tag_ptr(ret_conv, true);
23707 }
23708
23709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23710         void* e_ptr = untag_ptr(e);
23711         CHECK_ACCESS(e_ptr);
23712         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23713         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23714         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23715         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
23716         return tag_ptr(ret_conv, true);
23717 }
23718
23719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23720         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
23721         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
23722         return ret_conv;
23723 }
23724
23725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23726         if (!ptr_is_owned(_res)) return;
23727         void* _res_ptr = untag_ptr(_res);
23728         CHECK_ACCESS(_res_ptr);
23729         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
23730         FREE(untag_ptr(_res));
23731         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
23732 }
23733
23734 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
23735         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23736         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
23737         return tag_ptr(ret_conv, true);
23738 }
23739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23740         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
23741         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
23742         return ret_conv;
23743 }
23744
23745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23746         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
23747         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23748         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
23749         return tag_ptr(ret_conv, true);
23750 }
23751
23752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23753         void* o_ptr = untag_ptr(o);
23754         CHECK_ACCESS(o_ptr);
23755         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23756         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23757         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23758         *ret_copy = COption_NetAddressZ_some(o_conv);
23759         int64_t ret_ref = tag_ptr(ret_copy, true);
23760         return ret_ref;
23761 }
23762
23763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
23764         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23765         *ret_copy = COption_NetAddressZ_none();
23766         int64_t ret_ref = tag_ptr(ret_copy, true);
23767         return ret_ref;
23768 }
23769
23770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23771         if (!ptr_is_owned(_res)) return;
23772         void* _res_ptr = untag_ptr(_res);
23773         CHECK_ACCESS(_res_ptr);
23774         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
23775         FREE(untag_ptr(_res));
23776         COption_NetAddressZ_free(_res_conv);
23777 }
23778
23779 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
23780         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23781         *ret_copy = COption_NetAddressZ_clone(arg);
23782         int64_t ret_ref = tag_ptr(ret_copy, true);
23783         return ret_ref;
23784 }
23785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23786         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
23787         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
23788         return ret_conv;
23789 }
23790
23791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23792         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
23793         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23794         *ret_copy = COption_NetAddressZ_clone(orig_conv);
23795         int64_t ret_ref = tag_ptr(ret_copy, true);
23796         return ret_ref;
23797 }
23798
23799 static inline uint64_t C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR arg) {
23800         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23801         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(arg);
23802         return tag_ptr(ret_conv, true);
23803 }
23804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23805         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(arg);
23806         int64_t ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(arg_conv);
23807         return ret_conv;
23808 }
23809
23810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23811         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(orig);
23812         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23813         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig_conv);
23814         return tag_ptr(ret_conv, true);
23815 }
23816
23817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23818         LDKPublicKey a_ref;
23819         CHECK((*env)->GetArrayLength(env, a) == 33);
23820         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23821         void* b_ptr = untag_ptr(b);
23822         CHECK_ACCESS(b_ptr);
23823         LDKCOption_NetAddressZ b_conv = *(LDKCOption_NetAddressZ*)(b_ptr);
23824         b_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(b));
23825         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23826         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_new(a_ref, b_conv);
23827         return tag_ptr(ret_conv, true);
23828 }
23829
23830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23831         if (!ptr_is_owned(_res)) return;
23832         void* _res_ptr = untag_ptr(_res);
23833         CHECK_ACCESS(_res_ptr);
23834         LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_ptr);
23835         FREE(untag_ptr(_res));
23836         C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res_conv);
23837 }
23838
23839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyCOption_1NetAddressZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23840         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res_constr;
23841         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23842         if (_res_constr.datalen > 0)
23843                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ Elements");
23844         else
23845                 _res_constr.data = NULL;
23846         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23847         for (size_t o = 0; o < _res_constr.datalen; o++) {
23848                 int64_t _res_conv_40 = _res_vals[o];
23849                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23850                 CHECK_ACCESS(_res_conv_40_ptr);
23851                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv_40_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_conv_40_ptr);
23852                 FREE(untag_ptr(_res_conv_40));
23853                 _res_constr.data[o] = _res_conv_40_conv;
23854         }
23855         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23856         CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res_constr);
23857 }
23858
23859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
23860         LDKCVec_u8Z o_ref;
23861         o_ref.datalen = (*env)->GetArrayLength(env, o);
23862         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23863         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
23864         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23865         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23866         return tag_ptr(ret_conv, true);
23867 }
23868
23869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23870         LDKPeerHandleError e_conv;
23871         e_conv.inner = untag_ptr(e);
23872         e_conv.is_owned = ptr_is_owned(e);
23873         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23874         e_conv = PeerHandleError_clone(&e_conv);
23875         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23876         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23877         return tag_ptr(ret_conv, true);
23878 }
23879
23880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23881         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23882         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23883         return ret_conv;
23884 }
23885
23886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23887         if (!ptr_is_owned(_res)) return;
23888         void* _res_ptr = untag_ptr(_res);
23889         CHECK_ACCESS(_res_ptr);
23890         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23891         FREE(untag_ptr(_res));
23892         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23893 }
23894
23895 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23896         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23897         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23898         return tag_ptr(ret_conv, true);
23899 }
23900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23901         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23902         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23903         return ret_conv;
23904 }
23905
23906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23907         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23908         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23909         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23910         return tag_ptr(ret_conv, true);
23911 }
23912
23913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23914         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23915         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23916         return tag_ptr(ret_conv, true);
23917 }
23918
23919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23920         LDKPeerHandleError e_conv;
23921         e_conv.inner = untag_ptr(e);
23922         e_conv.is_owned = ptr_is_owned(e);
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23924         e_conv = PeerHandleError_clone(&e_conv);
23925         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23926         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23927         return tag_ptr(ret_conv, true);
23928 }
23929
23930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23931         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23932         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23933         return ret_conv;
23934 }
23935
23936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23937         if (!ptr_is_owned(_res)) return;
23938         void* _res_ptr = untag_ptr(_res);
23939         CHECK_ACCESS(_res_ptr);
23940         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23941         FREE(untag_ptr(_res));
23942         CResult_NonePeerHandleErrorZ_free(_res_conv);
23943 }
23944
23945 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23946         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23947         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23948         return tag_ptr(ret_conv, true);
23949 }
23950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23951         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23952         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23953         return ret_conv;
23954 }
23955
23956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23957         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23958         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23959         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23960         return tag_ptr(ret_conv, true);
23961 }
23962
23963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23964         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23965         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23966         return tag_ptr(ret_conv, true);
23967 }
23968
23969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23970         LDKPeerHandleError e_conv;
23971         e_conv.inner = untag_ptr(e);
23972         e_conv.is_owned = ptr_is_owned(e);
23973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23974         e_conv = PeerHandleError_clone(&e_conv);
23975         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23976         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23977         return tag_ptr(ret_conv, true);
23978 }
23979
23980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23981         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23982         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23983         return ret_conv;
23984 }
23985
23986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_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_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23991         FREE(untag_ptr(_res));
23992         CResult_boolPeerHandleErrorZ_free(_res_conv);
23993 }
23994
23995 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23996         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23997         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23998         return tag_ptr(ret_conv, true);
23999 }
24000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24001         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
24002         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
24003         return ret_conv;
24004 }
24005
24006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24007         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
24008         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
24009         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
24010         return tag_ptr(ret_conv, true);
24011 }
24012
24013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24014         void* o_ptr = untag_ptr(o);
24015         CHECK_ACCESS(o_ptr);
24016         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
24017         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
24018         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24019         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
24020         return tag_ptr(ret_conv, true);
24021 }
24022
24023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24024         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_java(env, e);
24025         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24026         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
24027         return tag_ptr(ret_conv, true);
24028 }
24029
24030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24031         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
24032         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
24033         return ret_conv;
24034 }
24035
24036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24037         if (!ptr_is_owned(_res)) return;
24038         void* _res_ptr = untag_ptr(_res);
24039         CHECK_ACCESS(_res_ptr);
24040         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
24041         FREE(untag_ptr(_res));
24042         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
24043 }
24044
24045 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
24046         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24047         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
24048         return tag_ptr(ret_conv, true);
24049 }
24050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24051         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
24052         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
24053         return ret_conv;
24054 }
24055
24056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24057         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
24058         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24059         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
24060         return tag_ptr(ret_conv, true);
24061 }
24062
24063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
24064         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24065         *ret_conv = CResult_NoneSendErrorZ_ok();
24066         return tag_ptr(ret_conv, true);
24067 }
24068
24069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24070         void* e_ptr = untag_ptr(e);
24071         CHECK_ACCESS(e_ptr);
24072         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
24073         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
24074         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24075         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
24076         return tag_ptr(ret_conv, true);
24077 }
24078
24079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24080         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
24081         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
24082         return ret_conv;
24083 }
24084
24085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24086         if (!ptr_is_owned(_res)) return;
24087         void* _res_ptr = untag_ptr(_res);
24088         CHECK_ACCESS(_res_ptr);
24089         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
24090         FREE(untag_ptr(_res));
24091         CResult_NoneSendErrorZ_free(_res_conv);
24092 }
24093
24094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24095         LDKBlindedPath o_conv;
24096         o_conv.inner = untag_ptr(o);
24097         o_conv.is_owned = ptr_is_owned(o);
24098         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24099         o_conv = BlindedPath_clone(&o_conv);
24100         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24101         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
24102         return tag_ptr(ret_conv, true);
24103 }
24104
24105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
24106         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24107         *ret_conv = CResult_BlindedPathNoneZ_err();
24108         return tag_ptr(ret_conv, true);
24109 }
24110
24111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24112         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
24113         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
24114         return ret_conv;
24115 }
24116
24117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24118         if (!ptr_is_owned(_res)) return;
24119         void* _res_ptr = untag_ptr(_res);
24120         CHECK_ACCESS(_res_ptr);
24121         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
24122         FREE(untag_ptr(_res));
24123         CResult_BlindedPathNoneZ_free(_res_conv);
24124 }
24125
24126 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
24127         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24128         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
24129         return tag_ptr(ret_conv, true);
24130 }
24131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24132         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
24133         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
24134         return ret_conv;
24135 }
24136
24137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24138         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
24139         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24140         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
24141         return tag_ptr(ret_conv, true);
24142 }
24143
24144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24145         LDKBlindedPath o_conv;
24146         o_conv.inner = untag_ptr(o);
24147         o_conv.is_owned = ptr_is_owned(o);
24148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24149         o_conv = BlindedPath_clone(&o_conv);
24150         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24151         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
24152         return tag_ptr(ret_conv, true);
24153 }
24154
24155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24156         void* e_ptr = untag_ptr(e);
24157         CHECK_ACCESS(e_ptr);
24158         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24159         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24160         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24161         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
24162         return tag_ptr(ret_conv, true);
24163 }
24164
24165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24166         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
24167         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
24168         return ret_conv;
24169 }
24170
24171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24172         if (!ptr_is_owned(_res)) return;
24173         void* _res_ptr = untag_ptr(_res);
24174         CHECK_ACCESS(_res_ptr);
24175         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
24176         FREE(untag_ptr(_res));
24177         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
24178 }
24179
24180 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
24181         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24182         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
24183         return tag_ptr(ret_conv, true);
24184 }
24185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24186         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
24187         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
24188         return ret_conv;
24189 }
24190
24191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24192         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
24193         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24194         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
24195         return tag_ptr(ret_conv, true);
24196 }
24197
24198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24199         LDKBlindedHop o_conv;
24200         o_conv.inner = untag_ptr(o);
24201         o_conv.is_owned = ptr_is_owned(o);
24202         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24203         o_conv = BlindedHop_clone(&o_conv);
24204         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24205         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
24206         return tag_ptr(ret_conv, true);
24207 }
24208
24209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24210         void* e_ptr = untag_ptr(e);
24211         CHECK_ACCESS(e_ptr);
24212         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24213         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24214         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24215         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
24216         return tag_ptr(ret_conv, true);
24217 }
24218
24219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24220         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
24221         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
24222         return ret_conv;
24223 }
24224
24225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24226         if (!ptr_is_owned(_res)) return;
24227         void* _res_ptr = untag_ptr(_res);
24228         CHECK_ACCESS(_res_ptr);
24229         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
24230         FREE(untag_ptr(_res));
24231         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
24232 }
24233
24234 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
24235         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24236         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
24237         return tag_ptr(ret_conv, true);
24238 }
24239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24240         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
24241         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
24242         return ret_conv;
24243 }
24244
24245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24246         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
24247         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24248         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
24249         return tag_ptr(ret_conv, true);
24250 }
24251
24252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
24253         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
24254         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24255         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
24256         return tag_ptr(ret_conv, true);
24257 }
24258
24259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24260         void* e_ptr = untag_ptr(e);
24261         CHECK_ACCESS(e_ptr);
24262         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24263         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24264         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24265         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
24266         return tag_ptr(ret_conv, true);
24267 }
24268
24269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24270         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
24271         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
24272         return ret_conv;
24273 }
24274
24275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24276         if (!ptr_is_owned(_res)) return;
24277         void* _res_ptr = untag_ptr(_res);
24278         CHECK_ACCESS(_res_ptr);
24279         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
24280         FREE(untag_ptr(_res));
24281         CResult_SiPrefixParseErrorZ_free(_res_conv);
24282 }
24283
24284 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
24285         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24286         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
24287         return tag_ptr(ret_conv, true);
24288 }
24289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24290         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
24291         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
24292         return ret_conv;
24293 }
24294
24295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24296         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
24297         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24298         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
24299         return tag_ptr(ret_conv, true);
24300 }
24301
24302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24303         LDKInvoice o_conv;
24304         o_conv.inner = untag_ptr(o);
24305         o_conv.is_owned = ptr_is_owned(o);
24306         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24307         o_conv = Invoice_clone(&o_conv);
24308         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24309         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
24310         return tag_ptr(ret_conv, true);
24311 }
24312
24313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24314         void* e_ptr = untag_ptr(e);
24315         CHECK_ACCESS(e_ptr);
24316         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
24317         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
24318         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24319         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
24320         return tag_ptr(ret_conv, true);
24321 }
24322
24323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24324         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
24325         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
24326         return ret_conv;
24327 }
24328
24329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24330         if (!ptr_is_owned(_res)) return;
24331         void* _res_ptr = untag_ptr(_res);
24332         CHECK_ACCESS(_res_ptr);
24333         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
24334         FREE(untag_ptr(_res));
24335         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
24336 }
24337
24338 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
24339         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24340         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
24341         return tag_ptr(ret_conv, true);
24342 }
24343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24344         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
24345         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
24346         return ret_conv;
24347 }
24348
24349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24350         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
24351         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24352         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
24353         return tag_ptr(ret_conv, true);
24354 }
24355
24356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24357         LDKSignedRawInvoice o_conv;
24358         o_conv.inner = untag_ptr(o);
24359         o_conv.is_owned = ptr_is_owned(o);
24360         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24361         o_conv = SignedRawInvoice_clone(&o_conv);
24362         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24363         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
24364         return tag_ptr(ret_conv, true);
24365 }
24366
24367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24368         void* e_ptr = untag_ptr(e);
24369         CHECK_ACCESS(e_ptr);
24370         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24371         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24372         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24373         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
24374         return tag_ptr(ret_conv, true);
24375 }
24376
24377 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24378         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
24379         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
24380         return ret_conv;
24381 }
24382
24383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24384         if (!ptr_is_owned(_res)) return;
24385         void* _res_ptr = untag_ptr(_res);
24386         CHECK_ACCESS(_res_ptr);
24387         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
24388         FREE(untag_ptr(_res));
24389         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
24390 }
24391
24392 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
24393         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24394         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
24395         return tag_ptr(ret_conv, true);
24396 }
24397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24398         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
24399         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
24400         return ret_conv;
24401 }
24402
24403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24404         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
24405         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24406         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
24407         return tag_ptr(ret_conv, true);
24408 }
24409
24410 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
24411         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24412         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
24413         return tag_ptr(ret_conv, true);
24414 }
24415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24416         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
24417         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
24418         return ret_conv;
24419 }
24420
24421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24422         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
24423         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24424         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
24425         return tag_ptr(ret_conv, true);
24426 }
24427
24428 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) {
24429         LDKRawInvoice a_conv;
24430         a_conv.inner = untag_ptr(a);
24431         a_conv.is_owned = ptr_is_owned(a);
24432         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24433         a_conv = RawInvoice_clone(&a_conv);
24434         LDKThirtyTwoBytes b_ref;
24435         CHECK((*env)->GetArrayLength(env, b) == 32);
24436         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
24437         LDKInvoiceSignature c_conv;
24438         c_conv.inner = untag_ptr(c);
24439         c_conv.is_owned = ptr_is_owned(c);
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
24441         c_conv = InvoiceSignature_clone(&c_conv);
24442         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24443         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
24444         return tag_ptr(ret_conv, true);
24445 }
24446
24447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24448         if (!ptr_is_owned(_res)) return;
24449         void* _res_ptr = untag_ptr(_res);
24450         CHECK_ACCESS(_res_ptr);
24451         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
24452         FREE(untag_ptr(_res));
24453         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
24454 }
24455
24456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24457         LDKPayeePubKey o_conv;
24458         o_conv.inner = untag_ptr(o);
24459         o_conv.is_owned = ptr_is_owned(o);
24460         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24461         o_conv = PayeePubKey_clone(&o_conv);
24462         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24463         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
24464         return tag_ptr(ret_conv, true);
24465 }
24466
24467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24468         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
24469         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24470         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
24471         return tag_ptr(ret_conv, true);
24472 }
24473
24474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24475         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
24476         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
24477         return ret_conv;
24478 }
24479
24480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24481         if (!ptr_is_owned(_res)) return;
24482         void* _res_ptr = untag_ptr(_res);
24483         CHECK_ACCESS(_res_ptr);
24484         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
24485         FREE(untag_ptr(_res));
24486         CResult_PayeePubKeyErrorZ_free(_res_conv);
24487 }
24488
24489 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
24490         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24491         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
24492         return tag_ptr(ret_conv, true);
24493 }
24494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24495         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
24496         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
24497         return ret_conv;
24498 }
24499
24500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24501         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
24502         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24503         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
24504         return tag_ptr(ret_conv, true);
24505 }
24506
24507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24508         LDKCVec_PrivateRouteZ _res_constr;
24509         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24510         if (_res_constr.datalen > 0)
24511                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
24512         else
24513                 _res_constr.data = NULL;
24514         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24515         for (size_t o = 0; o < _res_constr.datalen; o++) {
24516                 int64_t _res_conv_14 = _res_vals[o];
24517                 LDKPrivateRoute _res_conv_14_conv;
24518                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
24519                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
24520                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
24521                 _res_constr.data[o] = _res_conv_14_conv;
24522         }
24523         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24524         CVec_PrivateRouteZ_free(_res_constr);
24525 }
24526
24527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24528         LDKPositiveTimestamp o_conv;
24529         o_conv.inner = untag_ptr(o);
24530         o_conv.is_owned = ptr_is_owned(o);
24531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24532         o_conv = PositiveTimestamp_clone(&o_conv);
24533         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24534         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
24535         return tag_ptr(ret_conv, true);
24536 }
24537
24538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24539         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24540         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24541         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
24542         return tag_ptr(ret_conv, true);
24543 }
24544
24545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24546         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
24547         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
24548         return ret_conv;
24549 }
24550
24551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24552         if (!ptr_is_owned(_res)) return;
24553         void* _res_ptr = untag_ptr(_res);
24554         CHECK_ACCESS(_res_ptr);
24555         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
24556         FREE(untag_ptr(_res));
24557         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
24558 }
24559
24560 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
24561         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24562         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
24563         return tag_ptr(ret_conv, true);
24564 }
24565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24566         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
24567         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
24568         return ret_conv;
24569 }
24570
24571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24572         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
24573         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24574         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
24575         return tag_ptr(ret_conv, true);
24576 }
24577
24578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
24579         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24580         *ret_conv = CResult_NoneSemanticErrorZ_ok();
24581         return tag_ptr(ret_conv, true);
24582 }
24583
24584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24585         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24586         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24587         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
24588         return tag_ptr(ret_conv, true);
24589 }
24590
24591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24592         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
24593         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
24594         return ret_conv;
24595 }
24596
24597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24598         if (!ptr_is_owned(_res)) return;
24599         void* _res_ptr = untag_ptr(_res);
24600         CHECK_ACCESS(_res_ptr);
24601         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
24602         FREE(untag_ptr(_res));
24603         CResult_NoneSemanticErrorZ_free(_res_conv);
24604 }
24605
24606 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
24607         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24608         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
24609         return tag_ptr(ret_conv, true);
24610 }
24611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24612         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
24613         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
24614         return ret_conv;
24615 }
24616
24617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24618         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
24619         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24620         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
24621         return tag_ptr(ret_conv, true);
24622 }
24623
24624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24625         LDKInvoice o_conv;
24626         o_conv.inner = untag_ptr(o);
24627         o_conv.is_owned = ptr_is_owned(o);
24628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24629         o_conv = Invoice_clone(&o_conv);
24630         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24631         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
24632         return tag_ptr(ret_conv, true);
24633 }
24634
24635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24636         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24637         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24638         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
24639         return tag_ptr(ret_conv, true);
24640 }
24641
24642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24643         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
24644         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
24645         return ret_conv;
24646 }
24647
24648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24649         if (!ptr_is_owned(_res)) return;
24650         void* _res_ptr = untag_ptr(_res);
24651         CHECK_ACCESS(_res_ptr);
24652         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
24653         FREE(untag_ptr(_res));
24654         CResult_InvoiceSemanticErrorZ_free(_res_conv);
24655 }
24656
24657 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
24658         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24659         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
24660         return tag_ptr(ret_conv, true);
24661 }
24662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24663         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
24664         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
24665         return ret_conv;
24666 }
24667
24668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24669         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
24670         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24671         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
24672         return tag_ptr(ret_conv, true);
24673 }
24674
24675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1AddressZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
24676         LDKCVec_AddressZ _res_constr;
24677         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24678         if (_res_constr.datalen > 0)
24679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_AddressZ Elements");
24680         else
24681                 _res_constr.data = NULL;
24682         for (size_t i = 0; i < _res_constr.datalen; i++) {
24683                 jstring _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
24684                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
24685                 _res_constr.data[i] = dummy;
24686         }
24687         CVec_AddressZ_free(_res_constr);
24688 }
24689
24690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24691         LDKDescription o_conv;
24692         o_conv.inner = untag_ptr(o);
24693         o_conv.is_owned = ptr_is_owned(o);
24694         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24695         o_conv = Description_clone(&o_conv);
24696         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24697         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
24698         return tag_ptr(ret_conv, true);
24699 }
24700
24701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24702         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24703         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24704         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
24705         return tag_ptr(ret_conv, true);
24706 }
24707
24708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24709         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
24710         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
24711         return ret_conv;
24712 }
24713
24714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24715         if (!ptr_is_owned(_res)) return;
24716         void* _res_ptr = untag_ptr(_res);
24717         CHECK_ACCESS(_res_ptr);
24718         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
24719         FREE(untag_ptr(_res));
24720         CResult_DescriptionCreationErrorZ_free(_res_conv);
24721 }
24722
24723 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
24724         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24725         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
24726         return tag_ptr(ret_conv, true);
24727 }
24728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24729         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
24730         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
24731         return ret_conv;
24732 }
24733
24734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24735         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
24736         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24737         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
24738         return tag_ptr(ret_conv, true);
24739 }
24740
24741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24742         LDKPrivateRoute o_conv;
24743         o_conv.inner = untag_ptr(o);
24744         o_conv.is_owned = ptr_is_owned(o);
24745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24746         o_conv = PrivateRoute_clone(&o_conv);
24747         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24748         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
24749         return tag_ptr(ret_conv, true);
24750 }
24751
24752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24753         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24754         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24755         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
24756         return tag_ptr(ret_conv, true);
24757 }
24758
24759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24760         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
24761         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
24762         return ret_conv;
24763 }
24764
24765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24766         if (!ptr_is_owned(_res)) return;
24767         void* _res_ptr = untag_ptr(_res);
24768         CHECK_ACCESS(_res_ptr);
24769         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
24770         FREE(untag_ptr(_res));
24771         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
24772 }
24773
24774 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
24775         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24776         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
24777         return tag_ptr(ret_conv, true);
24778 }
24779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24780         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
24781         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
24782         return ret_conv;
24783 }
24784
24785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24786         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
24787         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24788         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
24789         return tag_ptr(ret_conv, true);
24790 }
24791
24792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24793         void* o_ptr = untag_ptr(o);
24794         CHECK_ACCESS(o_ptr);
24795         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
24796         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
24797         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24798         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
24799         return tag_ptr(ret_conv, true);
24800 }
24801
24802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24803         void* e_ptr = untag_ptr(e);
24804         CHECK_ACCESS(e_ptr);
24805         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24806         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24807         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24808         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
24809         return tag_ptr(ret_conv, true);
24810 }
24811
24812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24813         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
24814         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
24815         return ret_conv;
24816 }
24817
24818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24819         if (!ptr_is_owned(_res)) return;
24820         void* _res_ptr = untag_ptr(_res);
24821         CHECK_ACCESS(_res_ptr);
24822         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
24823         FREE(untag_ptr(_res));
24824         CResult_NetAddressDecodeErrorZ_free(_res_conv);
24825 }
24826
24827 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
24828         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24829         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
24830         return tag_ptr(ret_conv, true);
24831 }
24832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24833         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
24834         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
24835         return ret_conv;
24836 }
24837
24838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24839         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
24840         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24841         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
24842         return tag_ptr(ret_conv, true);
24843 }
24844
24845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24846         LDKCVec_UpdateAddHTLCZ _res_constr;
24847         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24848         if (_res_constr.datalen > 0)
24849                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24850         else
24851                 _res_constr.data = NULL;
24852         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24853         for (size_t p = 0; p < _res_constr.datalen; p++) {
24854                 int64_t _res_conv_15 = _res_vals[p];
24855                 LDKUpdateAddHTLC _res_conv_15_conv;
24856                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
24857                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
24858                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
24859                 _res_constr.data[p] = _res_conv_15_conv;
24860         }
24861         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24862         CVec_UpdateAddHTLCZ_free(_res_constr);
24863 }
24864
24865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24866         LDKCVec_UpdateFulfillHTLCZ _res_constr;
24867         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24868         if (_res_constr.datalen > 0)
24869                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24870         else
24871                 _res_constr.data = NULL;
24872         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24873         for (size_t t = 0; t < _res_constr.datalen; t++) {
24874                 int64_t _res_conv_19 = _res_vals[t];
24875                 LDKUpdateFulfillHTLC _res_conv_19_conv;
24876                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24877                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24878                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24879                 _res_constr.data[t] = _res_conv_19_conv;
24880         }
24881         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24882         CVec_UpdateFulfillHTLCZ_free(_res_constr);
24883 }
24884
24885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24886         LDKCVec_UpdateFailHTLCZ _res_constr;
24887         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24888         if (_res_constr.datalen > 0)
24889                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24890         else
24891                 _res_constr.data = NULL;
24892         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24893         for (size_t q = 0; q < _res_constr.datalen; q++) {
24894                 int64_t _res_conv_16 = _res_vals[q];
24895                 LDKUpdateFailHTLC _res_conv_16_conv;
24896                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
24897                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
24898                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
24899                 _res_constr.data[q] = _res_conv_16_conv;
24900         }
24901         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24902         CVec_UpdateFailHTLCZ_free(_res_constr);
24903 }
24904
24905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24906         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
24907         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24908         if (_res_constr.datalen > 0)
24909                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24910         else
24911                 _res_constr.data = NULL;
24912         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24913         for (size_t z = 0; z < _res_constr.datalen; z++) {
24914                 int64_t _res_conv_25 = _res_vals[z];
24915                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
24916                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
24917                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
24918                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
24919                 _res_constr.data[z] = _res_conv_25_conv;
24920         }
24921         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24922         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
24923 }
24924
24925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24926         LDKAcceptChannel o_conv;
24927         o_conv.inner = untag_ptr(o);
24928         o_conv.is_owned = ptr_is_owned(o);
24929         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24930         o_conv = AcceptChannel_clone(&o_conv);
24931         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24932         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
24933         return tag_ptr(ret_conv, true);
24934 }
24935
24936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24937         void* e_ptr = untag_ptr(e);
24938         CHECK_ACCESS(e_ptr);
24939         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24940         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24941         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24942         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
24943         return tag_ptr(ret_conv, true);
24944 }
24945
24946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24947         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
24948         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
24949         return ret_conv;
24950 }
24951
24952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24953         if (!ptr_is_owned(_res)) return;
24954         void* _res_ptr = untag_ptr(_res);
24955         CHECK_ACCESS(_res_ptr);
24956         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
24957         FREE(untag_ptr(_res));
24958         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
24959 }
24960
24961 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
24962         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24963         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
24964         return tag_ptr(ret_conv, true);
24965 }
24966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24967         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
24968         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
24969         return ret_conv;
24970 }
24971
24972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24973         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
24974         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24975         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
24976         return tag_ptr(ret_conv, true);
24977 }
24978
24979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24980         LDKAnnouncementSignatures o_conv;
24981         o_conv.inner = untag_ptr(o);
24982         o_conv.is_owned = ptr_is_owned(o);
24983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24984         o_conv = AnnouncementSignatures_clone(&o_conv);
24985         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24986         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24987         return tag_ptr(ret_conv, true);
24988 }
24989
24990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24991         void* e_ptr = untag_ptr(e);
24992         CHECK_ACCESS(e_ptr);
24993         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24994         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24995         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24996         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24997         return tag_ptr(ret_conv, true);
24998 }
24999
25000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25001         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
25002         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
25003         return ret_conv;
25004 }
25005
25006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25007         if (!ptr_is_owned(_res)) return;
25008         void* _res_ptr = untag_ptr(_res);
25009         CHECK_ACCESS(_res_ptr);
25010         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
25011         FREE(untag_ptr(_res));
25012         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
25013 }
25014
25015 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
25016         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25017         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
25018         return tag_ptr(ret_conv, true);
25019 }
25020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25021         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
25022         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
25023         return ret_conv;
25024 }
25025
25026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25027         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
25028         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25029         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
25030         return tag_ptr(ret_conv, true);
25031 }
25032
25033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25034         LDKChannelReestablish o_conv;
25035         o_conv.inner = untag_ptr(o);
25036         o_conv.is_owned = ptr_is_owned(o);
25037         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25038         o_conv = ChannelReestablish_clone(&o_conv);
25039         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25040         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
25041         return tag_ptr(ret_conv, true);
25042 }
25043
25044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25045         void* e_ptr = untag_ptr(e);
25046         CHECK_ACCESS(e_ptr);
25047         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25048         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25049         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25050         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
25051         return tag_ptr(ret_conv, true);
25052 }
25053
25054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25055         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
25056         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
25057         return ret_conv;
25058 }
25059
25060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25061         if (!ptr_is_owned(_res)) return;
25062         void* _res_ptr = untag_ptr(_res);
25063         CHECK_ACCESS(_res_ptr);
25064         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
25065         FREE(untag_ptr(_res));
25066         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
25067 }
25068
25069 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
25070         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25071         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
25072         return tag_ptr(ret_conv, true);
25073 }
25074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25075         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
25076         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
25077         return ret_conv;
25078 }
25079
25080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25081         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
25082         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25083         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
25084         return tag_ptr(ret_conv, true);
25085 }
25086
25087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25088         LDKClosingSigned o_conv;
25089         o_conv.inner = untag_ptr(o);
25090         o_conv.is_owned = ptr_is_owned(o);
25091         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25092         o_conv = ClosingSigned_clone(&o_conv);
25093         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25094         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
25095         return tag_ptr(ret_conv, true);
25096 }
25097
25098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25099         void* e_ptr = untag_ptr(e);
25100         CHECK_ACCESS(e_ptr);
25101         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25102         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25103         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25104         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
25105         return tag_ptr(ret_conv, true);
25106 }
25107
25108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25109         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
25110         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
25111         return ret_conv;
25112 }
25113
25114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25115         if (!ptr_is_owned(_res)) return;
25116         void* _res_ptr = untag_ptr(_res);
25117         CHECK_ACCESS(_res_ptr);
25118         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
25119         FREE(untag_ptr(_res));
25120         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
25121 }
25122
25123 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
25124         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25125         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
25126         return tag_ptr(ret_conv, true);
25127 }
25128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25129         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
25130         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
25131         return ret_conv;
25132 }
25133
25134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25135         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
25136         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25137         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
25138         return tag_ptr(ret_conv, true);
25139 }
25140
25141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25142         LDKClosingSignedFeeRange o_conv;
25143         o_conv.inner = untag_ptr(o);
25144         o_conv.is_owned = ptr_is_owned(o);
25145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25146         o_conv = ClosingSignedFeeRange_clone(&o_conv);
25147         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25148         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
25149         return tag_ptr(ret_conv, true);
25150 }
25151
25152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25153         void* e_ptr = untag_ptr(e);
25154         CHECK_ACCESS(e_ptr);
25155         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25156         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25157         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25158         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
25159         return tag_ptr(ret_conv, true);
25160 }
25161
25162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25163         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
25164         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
25165         return ret_conv;
25166 }
25167
25168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25169         if (!ptr_is_owned(_res)) return;
25170         void* _res_ptr = untag_ptr(_res);
25171         CHECK_ACCESS(_res_ptr);
25172         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
25173         FREE(untag_ptr(_res));
25174         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
25175 }
25176
25177 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
25178         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25179         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
25180         return tag_ptr(ret_conv, true);
25181 }
25182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25183         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
25184         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
25185         return ret_conv;
25186 }
25187
25188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25189         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
25190         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25191         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
25192         return tag_ptr(ret_conv, true);
25193 }
25194
25195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25196         LDKCommitmentSigned o_conv;
25197         o_conv.inner = untag_ptr(o);
25198         o_conv.is_owned = ptr_is_owned(o);
25199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25200         o_conv = CommitmentSigned_clone(&o_conv);
25201         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25202         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
25203         return tag_ptr(ret_conv, true);
25204 }
25205
25206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25207         void* e_ptr = untag_ptr(e);
25208         CHECK_ACCESS(e_ptr);
25209         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25210         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25211         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25212         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
25213         return tag_ptr(ret_conv, true);
25214 }
25215
25216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25217         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
25218         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
25219         return ret_conv;
25220 }
25221
25222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25223         if (!ptr_is_owned(_res)) return;
25224         void* _res_ptr = untag_ptr(_res);
25225         CHECK_ACCESS(_res_ptr);
25226         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
25227         FREE(untag_ptr(_res));
25228         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
25229 }
25230
25231 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
25232         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25233         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
25234         return tag_ptr(ret_conv, true);
25235 }
25236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25237         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
25238         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
25239         return ret_conv;
25240 }
25241
25242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25243         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
25244         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25245         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
25246         return tag_ptr(ret_conv, true);
25247 }
25248
25249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25250         LDKFundingCreated o_conv;
25251         o_conv.inner = untag_ptr(o);
25252         o_conv.is_owned = ptr_is_owned(o);
25253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25254         o_conv = FundingCreated_clone(&o_conv);
25255         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25256         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
25257         return tag_ptr(ret_conv, true);
25258 }
25259
25260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25261         void* e_ptr = untag_ptr(e);
25262         CHECK_ACCESS(e_ptr);
25263         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25264         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25265         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25266         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
25267         return tag_ptr(ret_conv, true);
25268 }
25269
25270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25271         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
25272         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
25273         return ret_conv;
25274 }
25275
25276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25277         if (!ptr_is_owned(_res)) return;
25278         void* _res_ptr = untag_ptr(_res);
25279         CHECK_ACCESS(_res_ptr);
25280         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
25281         FREE(untag_ptr(_res));
25282         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
25283 }
25284
25285 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
25286         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25287         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
25288         return tag_ptr(ret_conv, true);
25289 }
25290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25291         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
25292         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
25293         return ret_conv;
25294 }
25295
25296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25297         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
25298         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25299         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
25300         return tag_ptr(ret_conv, true);
25301 }
25302
25303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25304         LDKFundingSigned o_conv;
25305         o_conv.inner = untag_ptr(o);
25306         o_conv.is_owned = ptr_is_owned(o);
25307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25308         o_conv = FundingSigned_clone(&o_conv);
25309         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25310         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
25311         return tag_ptr(ret_conv, true);
25312 }
25313
25314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25315         void* e_ptr = untag_ptr(e);
25316         CHECK_ACCESS(e_ptr);
25317         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25318         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25319         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25320         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
25321         return tag_ptr(ret_conv, true);
25322 }
25323
25324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25325         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
25326         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
25327         return ret_conv;
25328 }
25329
25330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25331         if (!ptr_is_owned(_res)) return;
25332         void* _res_ptr = untag_ptr(_res);
25333         CHECK_ACCESS(_res_ptr);
25334         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
25335         FREE(untag_ptr(_res));
25336         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
25337 }
25338
25339 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
25340         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25341         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
25342         return tag_ptr(ret_conv, true);
25343 }
25344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25345         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
25346         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
25347         return ret_conv;
25348 }
25349
25350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25351         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
25352         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25353         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
25354         return tag_ptr(ret_conv, true);
25355 }
25356
25357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25358         LDKChannelReady o_conv;
25359         o_conv.inner = untag_ptr(o);
25360         o_conv.is_owned = ptr_is_owned(o);
25361         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25362         o_conv = ChannelReady_clone(&o_conv);
25363         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25364         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
25365         return tag_ptr(ret_conv, true);
25366 }
25367
25368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25369         void* e_ptr = untag_ptr(e);
25370         CHECK_ACCESS(e_ptr);
25371         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25372         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25373         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25374         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
25375         return tag_ptr(ret_conv, true);
25376 }
25377
25378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25379         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
25380         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
25381         return ret_conv;
25382 }
25383
25384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25385         if (!ptr_is_owned(_res)) return;
25386         void* _res_ptr = untag_ptr(_res);
25387         CHECK_ACCESS(_res_ptr);
25388         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
25389         FREE(untag_ptr(_res));
25390         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
25391 }
25392
25393 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
25394         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25395         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
25396         return tag_ptr(ret_conv, true);
25397 }
25398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25399         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
25400         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
25401         return ret_conv;
25402 }
25403
25404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25405         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
25406         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25407         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
25408         return tag_ptr(ret_conv, true);
25409 }
25410
25411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25412         LDKInit o_conv;
25413         o_conv.inner = untag_ptr(o);
25414         o_conv.is_owned = ptr_is_owned(o);
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25416         o_conv = Init_clone(&o_conv);
25417         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25418         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
25419         return tag_ptr(ret_conv, true);
25420 }
25421
25422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25423         void* e_ptr = untag_ptr(e);
25424         CHECK_ACCESS(e_ptr);
25425         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25426         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25427         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25428         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
25429         return tag_ptr(ret_conv, true);
25430 }
25431
25432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25433         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
25434         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
25435         return ret_conv;
25436 }
25437
25438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25439         if (!ptr_is_owned(_res)) return;
25440         void* _res_ptr = untag_ptr(_res);
25441         CHECK_ACCESS(_res_ptr);
25442         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
25443         FREE(untag_ptr(_res));
25444         CResult_InitDecodeErrorZ_free(_res_conv);
25445 }
25446
25447 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
25448         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25449         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
25450         return tag_ptr(ret_conv, true);
25451 }
25452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25453         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
25454         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
25455         return ret_conv;
25456 }
25457
25458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25459         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
25460         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25461         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
25462         return tag_ptr(ret_conv, true);
25463 }
25464
25465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25466         LDKOpenChannel o_conv;
25467         o_conv.inner = untag_ptr(o);
25468         o_conv.is_owned = ptr_is_owned(o);
25469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25470         o_conv = OpenChannel_clone(&o_conv);
25471         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25472         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
25473         return tag_ptr(ret_conv, true);
25474 }
25475
25476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25477         void* e_ptr = untag_ptr(e);
25478         CHECK_ACCESS(e_ptr);
25479         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25480         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25481         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25482         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
25483         return tag_ptr(ret_conv, true);
25484 }
25485
25486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25487         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25488         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25489         return ret_conv;
25490 }
25491
25492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25493         if (!ptr_is_owned(_res)) return;
25494         void* _res_ptr = untag_ptr(_res);
25495         CHECK_ACCESS(_res_ptr);
25496         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25497         FREE(untag_ptr(_res));
25498         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25499 }
25500
25501 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25502         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25503         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25504         return tag_ptr(ret_conv, true);
25505 }
25506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25507         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25508         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25509         return ret_conv;
25510 }
25511
25512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25513         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25514         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25515         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25516         return tag_ptr(ret_conv, true);
25517 }
25518
25519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25520         LDKRevokeAndACK o_conv;
25521         o_conv.inner = untag_ptr(o);
25522         o_conv.is_owned = ptr_is_owned(o);
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25524         o_conv = RevokeAndACK_clone(&o_conv);
25525         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25526         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25527         return tag_ptr(ret_conv, true);
25528 }
25529
25530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25531         void* e_ptr = untag_ptr(e);
25532         CHECK_ACCESS(e_ptr);
25533         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25534         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25535         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25536         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25537         return tag_ptr(ret_conv, true);
25538 }
25539
25540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25541         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25542         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25543         return ret_conv;
25544 }
25545
25546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25547         if (!ptr_is_owned(_res)) return;
25548         void* _res_ptr = untag_ptr(_res);
25549         CHECK_ACCESS(_res_ptr);
25550         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25551         FREE(untag_ptr(_res));
25552         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25553 }
25554
25555 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25556         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25557         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25558         return tag_ptr(ret_conv, true);
25559 }
25560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25561         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25562         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25563         return ret_conv;
25564 }
25565
25566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25567         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25568         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25569         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25570         return tag_ptr(ret_conv, true);
25571 }
25572
25573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25574         LDKShutdown o_conv;
25575         o_conv.inner = untag_ptr(o);
25576         o_conv.is_owned = ptr_is_owned(o);
25577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25578         o_conv = Shutdown_clone(&o_conv);
25579         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25580         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25581         return tag_ptr(ret_conv, true);
25582 }
25583
25584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25585         void* e_ptr = untag_ptr(e);
25586         CHECK_ACCESS(e_ptr);
25587         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25588         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25589         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25590         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25591         return tag_ptr(ret_conv, true);
25592 }
25593
25594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25595         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25596         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25597         return ret_conv;
25598 }
25599
25600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25601         if (!ptr_is_owned(_res)) return;
25602         void* _res_ptr = untag_ptr(_res);
25603         CHECK_ACCESS(_res_ptr);
25604         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25605         FREE(untag_ptr(_res));
25606         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25607 }
25608
25609 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25610         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25611         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25612         return tag_ptr(ret_conv, true);
25613 }
25614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25615         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25616         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25617         return ret_conv;
25618 }
25619
25620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25621         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25622         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25623         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25624         return tag_ptr(ret_conv, true);
25625 }
25626
25627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25628         LDKUpdateFailHTLC o_conv;
25629         o_conv.inner = untag_ptr(o);
25630         o_conv.is_owned = ptr_is_owned(o);
25631         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25632         o_conv = UpdateFailHTLC_clone(&o_conv);
25633         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25634         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25635         return tag_ptr(ret_conv, true);
25636 }
25637
25638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25639         void* e_ptr = untag_ptr(e);
25640         CHECK_ACCESS(e_ptr);
25641         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25642         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25643         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25644         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25645         return tag_ptr(ret_conv, true);
25646 }
25647
25648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25649         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25650         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25651         return ret_conv;
25652 }
25653
25654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25655         if (!ptr_is_owned(_res)) return;
25656         void* _res_ptr = untag_ptr(_res);
25657         CHECK_ACCESS(_res_ptr);
25658         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25659         FREE(untag_ptr(_res));
25660         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25661 }
25662
25663 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25664         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25665         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25666         return tag_ptr(ret_conv, true);
25667 }
25668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25669         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25670         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25671         return ret_conv;
25672 }
25673
25674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25675         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25676         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25677         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25678         return tag_ptr(ret_conv, true);
25679 }
25680
25681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25682         LDKUpdateFailMalformedHTLC o_conv;
25683         o_conv.inner = untag_ptr(o);
25684         o_conv.is_owned = ptr_is_owned(o);
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25686         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25687         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25688         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25689         return tag_ptr(ret_conv, true);
25690 }
25691
25692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25693         void* e_ptr = untag_ptr(e);
25694         CHECK_ACCESS(e_ptr);
25695         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25696         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25697         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25698         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25699         return tag_ptr(ret_conv, true);
25700 }
25701
25702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25703         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25704         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25705         return ret_conv;
25706 }
25707
25708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25709         if (!ptr_is_owned(_res)) return;
25710         void* _res_ptr = untag_ptr(_res);
25711         CHECK_ACCESS(_res_ptr);
25712         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25713         FREE(untag_ptr(_res));
25714         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25715 }
25716
25717 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25718         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25719         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25720         return tag_ptr(ret_conv, true);
25721 }
25722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25723         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25724         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25725         return ret_conv;
25726 }
25727
25728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25729         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25730         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25731         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25732         return tag_ptr(ret_conv, true);
25733 }
25734
25735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25736         LDKUpdateFee o_conv;
25737         o_conv.inner = untag_ptr(o);
25738         o_conv.is_owned = ptr_is_owned(o);
25739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25740         o_conv = UpdateFee_clone(&o_conv);
25741         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25742         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25743         return tag_ptr(ret_conv, true);
25744 }
25745
25746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25747         void* e_ptr = untag_ptr(e);
25748         CHECK_ACCESS(e_ptr);
25749         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25750         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25751         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25752         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25753         return tag_ptr(ret_conv, true);
25754 }
25755
25756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25757         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25758         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25759         return ret_conv;
25760 }
25761
25762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25763         if (!ptr_is_owned(_res)) return;
25764         void* _res_ptr = untag_ptr(_res);
25765         CHECK_ACCESS(_res_ptr);
25766         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25767         FREE(untag_ptr(_res));
25768         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25769 }
25770
25771 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25772         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25773         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25774         return tag_ptr(ret_conv, true);
25775 }
25776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25777         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25778         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25779         return ret_conv;
25780 }
25781
25782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25783         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25784         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25785         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25786         return tag_ptr(ret_conv, true);
25787 }
25788
25789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25790         LDKUpdateFulfillHTLC o_conv;
25791         o_conv.inner = untag_ptr(o);
25792         o_conv.is_owned = ptr_is_owned(o);
25793         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25794         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25795         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25796         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25797         return tag_ptr(ret_conv, true);
25798 }
25799
25800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25801         void* e_ptr = untag_ptr(e);
25802         CHECK_ACCESS(e_ptr);
25803         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25804         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25805         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25806         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25807         return tag_ptr(ret_conv, true);
25808 }
25809
25810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25811         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25812         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25813         return ret_conv;
25814 }
25815
25816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25817         if (!ptr_is_owned(_res)) return;
25818         void* _res_ptr = untag_ptr(_res);
25819         CHECK_ACCESS(_res_ptr);
25820         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25821         FREE(untag_ptr(_res));
25822         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25823 }
25824
25825 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25826         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25827         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25828         return tag_ptr(ret_conv, true);
25829 }
25830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25831         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25832         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25833         return ret_conv;
25834 }
25835
25836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25837         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25838         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25839         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25840         return tag_ptr(ret_conv, true);
25841 }
25842
25843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25844         LDKUpdateAddHTLC o_conv;
25845         o_conv.inner = untag_ptr(o);
25846         o_conv.is_owned = ptr_is_owned(o);
25847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25848         o_conv = UpdateAddHTLC_clone(&o_conv);
25849         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25850         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25851         return tag_ptr(ret_conv, true);
25852 }
25853
25854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25855         void* e_ptr = untag_ptr(e);
25856         CHECK_ACCESS(e_ptr);
25857         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25858         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25859         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25860         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25861         return tag_ptr(ret_conv, true);
25862 }
25863
25864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25865         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25866         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25867         return ret_conv;
25868 }
25869
25870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25871         if (!ptr_is_owned(_res)) return;
25872         void* _res_ptr = untag_ptr(_res);
25873         CHECK_ACCESS(_res_ptr);
25874         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25875         FREE(untag_ptr(_res));
25876         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25877 }
25878
25879 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25880         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25881         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25882         return tag_ptr(ret_conv, true);
25883 }
25884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25885         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25886         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25887         return ret_conv;
25888 }
25889
25890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25891         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25892         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25893         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25894         return tag_ptr(ret_conv, true);
25895 }
25896
25897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25898         LDKOnionMessage o_conv;
25899         o_conv.inner = untag_ptr(o);
25900         o_conv.is_owned = ptr_is_owned(o);
25901         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25902         o_conv = OnionMessage_clone(&o_conv);
25903         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25904         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25905         return tag_ptr(ret_conv, true);
25906 }
25907
25908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25909         void* e_ptr = untag_ptr(e);
25910         CHECK_ACCESS(e_ptr);
25911         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25912         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25913         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25914         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25915         return tag_ptr(ret_conv, true);
25916 }
25917
25918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25919         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25920         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25921         return ret_conv;
25922 }
25923
25924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25925         if (!ptr_is_owned(_res)) return;
25926         void* _res_ptr = untag_ptr(_res);
25927         CHECK_ACCESS(_res_ptr);
25928         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25929         FREE(untag_ptr(_res));
25930         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25931 }
25932
25933 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25934         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25935         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25936         return tag_ptr(ret_conv, true);
25937 }
25938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25939         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25940         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25941         return ret_conv;
25942 }
25943
25944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25945         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25946         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25947         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25948         return tag_ptr(ret_conv, true);
25949 }
25950
25951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25952         LDKPing o_conv;
25953         o_conv.inner = untag_ptr(o);
25954         o_conv.is_owned = ptr_is_owned(o);
25955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25956         o_conv = Ping_clone(&o_conv);
25957         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25958         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25959         return tag_ptr(ret_conv, true);
25960 }
25961
25962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25963         void* e_ptr = untag_ptr(e);
25964         CHECK_ACCESS(e_ptr);
25965         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25966         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25967         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25968         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25969         return tag_ptr(ret_conv, true);
25970 }
25971
25972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25973         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25974         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25975         return ret_conv;
25976 }
25977
25978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25979         if (!ptr_is_owned(_res)) return;
25980         void* _res_ptr = untag_ptr(_res);
25981         CHECK_ACCESS(_res_ptr);
25982         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25983         FREE(untag_ptr(_res));
25984         CResult_PingDecodeErrorZ_free(_res_conv);
25985 }
25986
25987 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25988         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25989         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25990         return tag_ptr(ret_conv, true);
25991 }
25992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25993         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25994         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25995         return ret_conv;
25996 }
25997
25998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25999         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
26000         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
26001         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
26002         return tag_ptr(ret_conv, true);
26003 }
26004
26005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26006         LDKPong o_conv;
26007         o_conv.inner = untag_ptr(o);
26008         o_conv.is_owned = ptr_is_owned(o);
26009         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26010         o_conv = Pong_clone(&o_conv);
26011         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26012         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
26013         return tag_ptr(ret_conv, true);
26014 }
26015
26016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26017         void* e_ptr = untag_ptr(e);
26018         CHECK_ACCESS(e_ptr);
26019         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26020         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26021         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26022         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
26023         return tag_ptr(ret_conv, true);
26024 }
26025
26026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26027         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
26028         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
26029         return ret_conv;
26030 }
26031
26032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26033         if (!ptr_is_owned(_res)) return;
26034         void* _res_ptr = untag_ptr(_res);
26035         CHECK_ACCESS(_res_ptr);
26036         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
26037         FREE(untag_ptr(_res));
26038         CResult_PongDecodeErrorZ_free(_res_conv);
26039 }
26040
26041 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
26042         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26043         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
26044         return tag_ptr(ret_conv, true);
26045 }
26046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26047         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
26048         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
26049         return ret_conv;
26050 }
26051
26052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26053         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
26054         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26055         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
26056         return tag_ptr(ret_conv, true);
26057 }
26058
26059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26060         LDKUnsignedChannelAnnouncement o_conv;
26061         o_conv.inner = untag_ptr(o);
26062         o_conv.is_owned = ptr_is_owned(o);
26063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26064         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
26065         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26066         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
26067         return tag_ptr(ret_conv, true);
26068 }
26069
26070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26071         void* e_ptr = untag_ptr(e);
26072         CHECK_ACCESS(e_ptr);
26073         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26074         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26075         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26076         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
26077         return tag_ptr(ret_conv, true);
26078 }
26079
26080 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26081         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26082         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26083         return ret_conv;
26084 }
26085
26086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26087         if (!ptr_is_owned(_res)) return;
26088         void* _res_ptr = untag_ptr(_res);
26089         CHECK_ACCESS(_res_ptr);
26090         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26091         FREE(untag_ptr(_res));
26092         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
26093 }
26094
26095 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26096         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26097         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
26098         return tag_ptr(ret_conv, true);
26099 }
26100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26101         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26102         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26103         return ret_conv;
26104 }
26105
26106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26107         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26108         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26109         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26110         return tag_ptr(ret_conv, true);
26111 }
26112
26113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26114         LDKChannelAnnouncement o_conv;
26115         o_conv.inner = untag_ptr(o);
26116         o_conv.is_owned = ptr_is_owned(o);
26117         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26118         o_conv = ChannelAnnouncement_clone(&o_conv);
26119         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26120         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
26121         return tag_ptr(ret_conv, true);
26122 }
26123
26124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26125         void* e_ptr = untag_ptr(e);
26126         CHECK_ACCESS(e_ptr);
26127         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26128         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26129         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26130         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
26131         return tag_ptr(ret_conv, true);
26132 }
26133
26134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26135         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26136         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26137         return ret_conv;
26138 }
26139
26140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26141         if (!ptr_is_owned(_res)) return;
26142         void* _res_ptr = untag_ptr(_res);
26143         CHECK_ACCESS(_res_ptr);
26144         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26145         FREE(untag_ptr(_res));
26146         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
26147 }
26148
26149 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26150         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26151         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
26152         return tag_ptr(ret_conv, true);
26153 }
26154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26155         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26156         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26157         return ret_conv;
26158 }
26159
26160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26161         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26162         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26163         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26164         return tag_ptr(ret_conv, true);
26165 }
26166
26167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26168         LDKUnsignedChannelUpdate o_conv;
26169         o_conv.inner = untag_ptr(o);
26170         o_conv.is_owned = ptr_is_owned(o);
26171         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26172         o_conv = UnsignedChannelUpdate_clone(&o_conv);
26173         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26174         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
26175         return tag_ptr(ret_conv, true);
26176 }
26177
26178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26179         void* e_ptr = untag_ptr(e);
26180         CHECK_ACCESS(e_ptr);
26181         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26182         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26183         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26184         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
26185         return tag_ptr(ret_conv, true);
26186 }
26187
26188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26189         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
26190         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
26191         return ret_conv;
26192 }
26193
26194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26195         if (!ptr_is_owned(_res)) return;
26196         void* _res_ptr = untag_ptr(_res);
26197         CHECK_ACCESS(_res_ptr);
26198         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
26199         FREE(untag_ptr(_res));
26200         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
26201 }
26202
26203 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26204         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26205         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
26206         return tag_ptr(ret_conv, true);
26207 }
26208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26209         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26210         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26211         return ret_conv;
26212 }
26213
26214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26215         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26216         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26217         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
26218         return tag_ptr(ret_conv, true);
26219 }
26220
26221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26222         LDKChannelUpdate o_conv;
26223         o_conv.inner = untag_ptr(o);
26224         o_conv.is_owned = ptr_is_owned(o);
26225         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26226         o_conv = ChannelUpdate_clone(&o_conv);
26227         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26228         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
26229         return tag_ptr(ret_conv, true);
26230 }
26231
26232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26233         void* e_ptr = untag_ptr(e);
26234         CHECK_ACCESS(e_ptr);
26235         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26236         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26237         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26238         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
26239         return tag_ptr(ret_conv, true);
26240 }
26241
26242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26243         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
26244         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
26245         return ret_conv;
26246 }
26247
26248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26249         if (!ptr_is_owned(_res)) return;
26250         void* _res_ptr = untag_ptr(_res);
26251         CHECK_ACCESS(_res_ptr);
26252         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
26253         FREE(untag_ptr(_res));
26254         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
26255 }
26256
26257 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26258         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26259         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
26260         return tag_ptr(ret_conv, true);
26261 }
26262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26263         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26264         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26265         return ret_conv;
26266 }
26267
26268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26269         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26270         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26271         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
26272         return tag_ptr(ret_conv, true);
26273 }
26274
26275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26276         LDKErrorMessage o_conv;
26277         o_conv.inner = untag_ptr(o);
26278         o_conv.is_owned = ptr_is_owned(o);
26279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26280         o_conv = ErrorMessage_clone(&o_conv);
26281         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26282         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
26283         return tag_ptr(ret_conv, true);
26284 }
26285
26286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26287         void* e_ptr = untag_ptr(e);
26288         CHECK_ACCESS(e_ptr);
26289         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26290         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26291         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26292         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
26293         return tag_ptr(ret_conv, true);
26294 }
26295
26296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26297         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
26298         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
26299         return ret_conv;
26300 }
26301
26302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26303         if (!ptr_is_owned(_res)) return;
26304         void* _res_ptr = untag_ptr(_res);
26305         CHECK_ACCESS(_res_ptr);
26306         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
26307         FREE(untag_ptr(_res));
26308         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
26309 }
26310
26311 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
26312         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26313         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
26314         return tag_ptr(ret_conv, true);
26315 }
26316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26317         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
26318         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
26319         return ret_conv;
26320 }
26321
26322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26323         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
26324         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26325         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
26326         return tag_ptr(ret_conv, true);
26327 }
26328
26329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26330         LDKWarningMessage o_conv;
26331         o_conv.inner = untag_ptr(o);
26332         o_conv.is_owned = ptr_is_owned(o);
26333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26334         o_conv = WarningMessage_clone(&o_conv);
26335         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26336         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
26337         return tag_ptr(ret_conv, true);
26338 }
26339
26340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26341         void* e_ptr = untag_ptr(e);
26342         CHECK_ACCESS(e_ptr);
26343         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26344         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26345         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26346         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
26347         return tag_ptr(ret_conv, true);
26348 }
26349
26350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26351         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
26352         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
26353         return ret_conv;
26354 }
26355
26356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26357         if (!ptr_is_owned(_res)) return;
26358         void* _res_ptr = untag_ptr(_res);
26359         CHECK_ACCESS(_res_ptr);
26360         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
26361         FREE(untag_ptr(_res));
26362         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
26363 }
26364
26365 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
26366         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26367         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
26368         return tag_ptr(ret_conv, true);
26369 }
26370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26371         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
26372         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
26373         return ret_conv;
26374 }
26375
26376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26377         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
26378         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26379         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
26380         return tag_ptr(ret_conv, true);
26381 }
26382
26383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26384         LDKUnsignedNodeAnnouncement o_conv;
26385         o_conv.inner = untag_ptr(o);
26386         o_conv.is_owned = ptr_is_owned(o);
26387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26388         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
26389         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26390         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
26391         return tag_ptr(ret_conv, true);
26392 }
26393
26394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26395         void* e_ptr = untag_ptr(e);
26396         CHECK_ACCESS(e_ptr);
26397         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26398         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26399         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26400         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
26401         return tag_ptr(ret_conv, true);
26402 }
26403
26404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26405         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26406         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26407         return ret_conv;
26408 }
26409
26410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26411         if (!ptr_is_owned(_res)) return;
26412         void* _res_ptr = untag_ptr(_res);
26413         CHECK_ACCESS(_res_ptr);
26414         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
26415         FREE(untag_ptr(_res));
26416         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
26417 }
26418
26419 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26420         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26421         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
26422         return tag_ptr(ret_conv, true);
26423 }
26424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26425         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26426         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26427         return ret_conv;
26428 }
26429
26430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26431         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26432         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26433         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26434         return tag_ptr(ret_conv, true);
26435 }
26436
26437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26438         LDKNodeAnnouncement o_conv;
26439         o_conv.inner = untag_ptr(o);
26440         o_conv.is_owned = ptr_is_owned(o);
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26442         o_conv = NodeAnnouncement_clone(&o_conv);
26443         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26444         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26445         return tag_ptr(ret_conv, true);
26446 }
26447
26448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26449         void* e_ptr = untag_ptr(e);
26450         CHECK_ACCESS(e_ptr);
26451         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26452         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26453         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26454         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26455         return tag_ptr(ret_conv, true);
26456 }
26457
26458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26459         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26460         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26461         return ret_conv;
26462 }
26463
26464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26465         if (!ptr_is_owned(_res)) return;
26466         void* _res_ptr = untag_ptr(_res);
26467         CHECK_ACCESS(_res_ptr);
26468         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26469         FREE(untag_ptr(_res));
26470         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26471 }
26472
26473 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26474         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26475         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26476         return tag_ptr(ret_conv, true);
26477 }
26478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26479         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26480         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26481         return ret_conv;
26482 }
26483
26484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26485         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26486         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26487         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26488         return tag_ptr(ret_conv, true);
26489 }
26490
26491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26492         LDKQueryShortChannelIds o_conv;
26493         o_conv.inner = untag_ptr(o);
26494         o_conv.is_owned = ptr_is_owned(o);
26495         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26496         o_conv = QueryShortChannelIds_clone(&o_conv);
26497         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26498         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26499         return tag_ptr(ret_conv, true);
26500 }
26501
26502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26503         void* e_ptr = untag_ptr(e);
26504         CHECK_ACCESS(e_ptr);
26505         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26506         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26507         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26508         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26509         return tag_ptr(ret_conv, true);
26510 }
26511
26512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26513         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26514         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26515         return ret_conv;
26516 }
26517
26518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26519         if (!ptr_is_owned(_res)) return;
26520         void* _res_ptr = untag_ptr(_res);
26521         CHECK_ACCESS(_res_ptr);
26522         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26523         FREE(untag_ptr(_res));
26524         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26525 }
26526
26527 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26528         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26529         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26530         return tag_ptr(ret_conv, true);
26531 }
26532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26533         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26534         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26535         return ret_conv;
26536 }
26537
26538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26539         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26540         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26541         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26542         return tag_ptr(ret_conv, true);
26543 }
26544
26545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26546         LDKReplyShortChannelIdsEnd o_conv;
26547         o_conv.inner = untag_ptr(o);
26548         o_conv.is_owned = ptr_is_owned(o);
26549         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26550         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26551         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26552         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26553         return tag_ptr(ret_conv, true);
26554 }
26555
26556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26557         void* e_ptr = untag_ptr(e);
26558         CHECK_ACCESS(e_ptr);
26559         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26560         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26561         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26562         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26563         return tag_ptr(ret_conv, true);
26564 }
26565
26566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26567         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26568         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26569         return ret_conv;
26570 }
26571
26572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26573         if (!ptr_is_owned(_res)) return;
26574         void* _res_ptr = untag_ptr(_res);
26575         CHECK_ACCESS(_res_ptr);
26576         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26577         FREE(untag_ptr(_res));
26578         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26579 }
26580
26581 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26582         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26583         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26584         return tag_ptr(ret_conv, true);
26585 }
26586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26587         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26588         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26589         return ret_conv;
26590 }
26591
26592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26593         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26594         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26595         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26596         return tag_ptr(ret_conv, true);
26597 }
26598
26599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26600         LDKQueryChannelRange o_conv;
26601         o_conv.inner = untag_ptr(o);
26602         o_conv.is_owned = ptr_is_owned(o);
26603         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26604         o_conv = QueryChannelRange_clone(&o_conv);
26605         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26606         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26607         return tag_ptr(ret_conv, true);
26608 }
26609
26610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26611         void* e_ptr = untag_ptr(e);
26612         CHECK_ACCESS(e_ptr);
26613         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26614         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26615         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26616         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26617         return tag_ptr(ret_conv, true);
26618 }
26619
26620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26621         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26622         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26623         return ret_conv;
26624 }
26625
26626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26627         if (!ptr_is_owned(_res)) return;
26628         void* _res_ptr = untag_ptr(_res);
26629         CHECK_ACCESS(_res_ptr);
26630         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26631         FREE(untag_ptr(_res));
26632         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26633 }
26634
26635 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26636         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26637         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26638         return tag_ptr(ret_conv, true);
26639 }
26640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26641         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26642         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26643         return ret_conv;
26644 }
26645
26646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26647         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26648         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26649         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26650         return tag_ptr(ret_conv, true);
26651 }
26652
26653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26654         LDKReplyChannelRange o_conv;
26655         o_conv.inner = untag_ptr(o);
26656         o_conv.is_owned = ptr_is_owned(o);
26657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26658         o_conv = ReplyChannelRange_clone(&o_conv);
26659         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26660         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26661         return tag_ptr(ret_conv, true);
26662 }
26663
26664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26665         void* e_ptr = untag_ptr(e);
26666         CHECK_ACCESS(e_ptr);
26667         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26668         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26669         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26670         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26671         return tag_ptr(ret_conv, true);
26672 }
26673
26674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26675         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26676         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26677         return ret_conv;
26678 }
26679
26680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26681         if (!ptr_is_owned(_res)) return;
26682         void* _res_ptr = untag_ptr(_res);
26683         CHECK_ACCESS(_res_ptr);
26684         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26685         FREE(untag_ptr(_res));
26686         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26687 }
26688
26689 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26690         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26691         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26692         return tag_ptr(ret_conv, true);
26693 }
26694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26695         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26696         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26697         return ret_conv;
26698 }
26699
26700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26701         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26702         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26703         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26704         return tag_ptr(ret_conv, true);
26705 }
26706
26707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26708         LDKGossipTimestampFilter o_conv;
26709         o_conv.inner = untag_ptr(o);
26710         o_conv.is_owned = ptr_is_owned(o);
26711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26712         o_conv = GossipTimestampFilter_clone(&o_conv);
26713         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26714         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26715         return tag_ptr(ret_conv, true);
26716 }
26717
26718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26719         void* e_ptr = untag_ptr(e);
26720         CHECK_ACCESS(e_ptr);
26721         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26722         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26723         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26724         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26725         return tag_ptr(ret_conv, true);
26726 }
26727
26728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26729         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26730         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26731         return ret_conv;
26732 }
26733
26734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26735         if (!ptr_is_owned(_res)) return;
26736         void* _res_ptr = untag_ptr(_res);
26737         CHECK_ACCESS(_res_ptr);
26738         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26739         FREE(untag_ptr(_res));
26740         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26741 }
26742
26743 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26744         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26745         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26746         return tag_ptr(ret_conv, true);
26747 }
26748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26749         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26750         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26751         return ret_conv;
26752 }
26753
26754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26755         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26756         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26757         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26758         return tag_ptr(ret_conv, true);
26759 }
26760
26761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26762         LDKCVec_PhantomRouteHintsZ _res_constr;
26763         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26764         if (_res_constr.datalen > 0)
26765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26766         else
26767                 _res_constr.data = NULL;
26768         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26769         for (size_t t = 0; t < _res_constr.datalen; t++) {
26770                 int64_t _res_conv_19 = _res_vals[t];
26771                 LDKPhantomRouteHints _res_conv_19_conv;
26772                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26773                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26774                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26775                 _res_constr.data[t] = _res_conv_19_conv;
26776         }
26777         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26778         CVec_PhantomRouteHintsZ_free(_res_constr);
26779 }
26780
26781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26782         LDKInvoice o_conv;
26783         o_conv.inner = untag_ptr(o);
26784         o_conv.is_owned = ptr_is_owned(o);
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26786         o_conv = Invoice_clone(&o_conv);
26787         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26788         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
26789         return tag_ptr(ret_conv, true);
26790 }
26791
26792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26793         void* e_ptr = untag_ptr(e);
26794         CHECK_ACCESS(e_ptr);
26795         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26796         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26797         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26798         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
26799         return tag_ptr(ret_conv, true);
26800 }
26801
26802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26803         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26804         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26805         return ret_conv;
26806 }
26807
26808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26809         if (!ptr_is_owned(_res)) return;
26810         void* _res_ptr = untag_ptr(_res);
26811         CHECK_ACCESS(_res_ptr);
26812         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
26813         FREE(untag_ptr(_res));
26814         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
26815 }
26816
26817 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26818         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26819         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
26820         return tag_ptr(ret_conv, true);
26821 }
26822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26823         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26824         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26825         return ret_conv;
26826 }
26827
26828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26829         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26830         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26831         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
26832         return tag_ptr(ret_conv, true);
26833 }
26834
26835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1FutureZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26836         LDKCVec_FutureZ _res_constr;
26837         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26838         if (_res_constr.datalen > 0)
26839                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26840         else
26841                 _res_constr.data = NULL;
26842         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26843         for (size_t i = 0; i < _res_constr.datalen; i++) {
26844                 int64_t _res_conv_8 = _res_vals[i];
26845                 LDKFuture _res_conv_8_conv;
26846                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26847                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26849                 _res_constr.data[i] = _res_conv_8_conv;
26850         }
26851         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26852         CVec_FutureZ_free(_res_constr);
26853 }
26854
26855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
26856         void* o_ptr = untag_ptr(o);
26857         CHECK_ACCESS(o_ptr);
26858         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
26859         if (o_conv.free == LDKFilter_JCalls_free) {
26860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26861                 LDKFilter_JCalls_cloned(&o_conv);
26862         }
26863         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26864         *ret_copy = COption_FilterZ_some(o_conv);
26865         int64_t ret_ref = tag_ptr(ret_copy, true);
26866         return ret_ref;
26867 }
26868
26869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
26870         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26871         *ret_copy = COption_FilterZ_none();
26872         int64_t ret_ref = tag_ptr(ret_copy, true);
26873         return ret_ref;
26874 }
26875
26876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26877         if (!ptr_is_owned(_res)) return;
26878         void* _res_ptr = untag_ptr(_res);
26879         CHECK_ACCESS(_res_ptr);
26880         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
26881         FREE(untag_ptr(_res));
26882         COption_FilterZ_free(_res_conv);
26883 }
26884
26885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26886         LDKLockedChannelMonitor o_conv;
26887         o_conv.inner = untag_ptr(o);
26888         o_conv.is_owned = ptr_is_owned(o);
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26890         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
26891         
26892         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26893         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
26894         return tag_ptr(ret_conv, true);
26895 }
26896
26897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
26898         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26899         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
26900         return tag_ptr(ret_conv, true);
26901 }
26902
26903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26904         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
26905         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
26906         return ret_conv;
26907 }
26908
26909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26910         if (!ptr_is_owned(_res)) return;
26911         void* _res_ptr = untag_ptr(_res);
26912         CHECK_ACCESS(_res_ptr);
26913         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
26914         FREE(untag_ptr(_res));
26915         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
26916 }
26917
26918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26919         LDKCVec_OutPointZ _res_constr;
26920         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26921         if (_res_constr.datalen > 0)
26922                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
26923         else
26924                 _res_constr.data = NULL;
26925         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26926         for (size_t k = 0; k < _res_constr.datalen; k++) {
26927                 int64_t _res_conv_10 = _res_vals[k];
26928                 LDKOutPoint _res_conv_10_conv;
26929                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
26930                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
26931                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
26932                 _res_constr.data[k] = _res_conv_10_conv;
26933         }
26934         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26935         CVec_OutPointZ_free(_res_constr);
26936 }
26937
26938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26939         LDKCVec_MonitorUpdateIdZ _res_constr;
26940         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26941         if (_res_constr.datalen > 0)
26942                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26943         else
26944                 _res_constr.data = NULL;
26945         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26946         for (size_t r = 0; r < _res_constr.datalen; r++) {
26947                 int64_t _res_conv_17 = _res_vals[r];
26948                 LDKMonitorUpdateId _res_conv_17_conv;
26949                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
26950                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
26951                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
26952                 _res_constr.data[r] = _res_conv_17_conv;
26953         }
26954         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26955         CVec_MonitorUpdateIdZ_free(_res_constr);
26956 }
26957
26958 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
26959         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26960         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
26961         return tag_ptr(ret_conv, true);
26962 }
26963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26964         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
26965         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
26966         return ret_conv;
26967 }
26968
26969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26970         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
26971         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26972         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
26973         return tag_ptr(ret_conv, true);
26974 }
26975
26976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
26977         LDKOutPoint a_conv;
26978         a_conv.inner = untag_ptr(a);
26979         a_conv.is_owned = ptr_is_owned(a);
26980         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26981         a_conv = OutPoint_clone(&a_conv);
26982         LDKCVec_MonitorUpdateIdZ b_constr;
26983         b_constr.datalen = (*env)->GetArrayLength(env, b);
26984         if (b_constr.datalen > 0)
26985                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26986         else
26987                 b_constr.data = NULL;
26988         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
26989         for (size_t r = 0; r < b_constr.datalen; r++) {
26990                 int64_t b_conv_17 = b_vals[r];
26991                 LDKMonitorUpdateId b_conv_17_conv;
26992                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
26993                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
26994                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
26995                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
26996                 b_constr.data[r] = b_conv_17_conv;
26997         }
26998         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
26999         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
27000         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
27001         return tag_ptr(ret_conv, true);
27002 }
27003
27004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27005         if (!ptr_is_owned(_res)) return;
27006         void* _res_ptr = untag_ptr(_res);
27007         CHECK_ACCESS(_res_ptr);
27008         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
27009         FREE(untag_ptr(_res));
27010         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
27011 }
27012
27013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
27014         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
27015         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
27016         if (_res_constr.datalen > 0)
27017                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
27018         else
27019                 _res_constr.data = NULL;
27020         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
27021         for (size_t p = 0; p < _res_constr.datalen; p++) {
27022                 int64_t _res_conv_41 = _res_vals[p];
27023                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
27024                 CHECK_ACCESS(_res_conv_41_ptr);
27025                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
27026                 FREE(untag_ptr(_res_conv_41));
27027                 _res_constr.data[p] = _res_conv_41_conv;
27028         }
27029         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
27030         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
27031 }
27032
27033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
27034         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27035         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
27036         return tag_ptr(ret_conv, true);
27037 }
27038
27039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
27040         void* e_ptr = untag_ptr(e);
27041         CHECK_ACCESS(e_ptr);
27042         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
27043         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
27044         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27045         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
27046         return tag_ptr(ret_conv, true);
27047 }
27048
27049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
27050         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
27051         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
27052         return ret_conv;
27053 }
27054
27055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27056         if (!ptr_is_owned(_res)) return;
27057         void* _res_ptr = untag_ptr(_res);
27058         CHECK_ACCESS(_res_ptr);
27059         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
27060         FREE(untag_ptr(_res));
27061         CResult_u32GraphSyncErrorZ_free(_res_conv);
27062 }
27063
27064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27065         if (!ptr_is_owned(this_ptr)) return;
27066         void* this_ptr_ptr = untag_ptr(this_ptr);
27067         CHECK_ACCESS(this_ptr_ptr);
27068         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27069         FREE(untag_ptr(this_ptr));
27070         APIError_free(this_ptr_conv);
27071 }
27072
27073 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27074         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27075         *ret_copy = APIError_clone(arg);
27076         int64_t ret_ref = tag_ptr(ret_copy, true);
27077         return ret_ref;
27078 }
27079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27080         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27081         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27082         return ret_conv;
27083 }
27084
27085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27086         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27087         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27088         *ret_copy = APIError_clone(orig_conv);
27089         int64_t ret_ref = tag_ptr(ret_copy, true);
27090         return ret_ref;
27091 }
27092
27093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27094         LDKStr err_conv = java_to_owned_str(env, err);
27095         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27096         *ret_copy = APIError_apimisuse_error(err_conv);
27097         int64_t ret_ref = tag_ptr(ret_copy, true);
27098         return ret_ref;
27099 }
27100
27101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27102         LDKStr err_conv = java_to_owned_str(env, err);
27103         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27104         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27105         int64_t ret_ref = tag_ptr(ret_copy, true);
27106         return ret_ref;
27107 }
27108
27109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27110         LDKStr err_conv = java_to_owned_str(env, err);
27111         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27112         *ret_copy = APIError_invalid_route(err_conv);
27113         int64_t ret_ref = tag_ptr(ret_copy, true);
27114         return ret_ref;
27115 }
27116
27117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27118         LDKStr err_conv = java_to_owned_str(env, err);
27119         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27120         *ret_copy = APIError_channel_unavailable(err_conv);
27121         int64_t ret_ref = tag_ptr(ret_copy, true);
27122         return ret_ref;
27123 }
27124
27125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27126         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27127         *ret_copy = APIError_monitor_update_in_progress();
27128         int64_t ret_ref = tag_ptr(ret_copy, true);
27129         return ret_ref;
27130 }
27131
27132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27133         LDKShutdownScript script_conv;
27134         script_conv.inner = untag_ptr(script);
27135         script_conv.is_owned = ptr_is_owned(script);
27136         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27137         script_conv = ShutdownScript_clone(&script_conv);
27138         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27139         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27140         int64_t ret_ref = tag_ptr(ret_copy, true);
27141         return ret_ref;
27142 }
27143
27144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27145         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27146         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27147         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27148         return ret_conv;
27149 }
27150
27151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_APIError_1write(JNIEnv *env, jclass clz, int64_t obj) {
27152         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
27153         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
27154         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27155         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27156         CVec_u8Z_free(ret_var);
27157         return ret_arr;
27158 }
27159
27160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27161         LDKu8slice ser_ref;
27162         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27163         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27164         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
27165         *ret_conv = APIError_read(ser_ref);
27166         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27167         return tag_ptr(ret_conv, true);
27168 }
27169
27170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27171         LDKBigSize this_obj_conv;
27172         this_obj_conv.inner = untag_ptr(this_obj);
27173         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27175         BigSize_free(this_obj_conv);
27176 }
27177
27178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27179         LDKBigSize this_ptr_conv;
27180         this_ptr_conv.inner = untag_ptr(this_ptr);
27181         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27183         this_ptr_conv.is_owned = false;
27184         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27185         return ret_conv;
27186 }
27187
27188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27189         LDKBigSize this_ptr_conv;
27190         this_ptr_conv.inner = untag_ptr(this_ptr);
27191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27193         this_ptr_conv.is_owned = false;
27194         BigSize_set_a(&this_ptr_conv, val);
27195 }
27196
27197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27198         LDKBigSize ret_var = BigSize_new(a_arg);
27199         int64_t ret_ref = 0;
27200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27202         return ret_ref;
27203 }
27204
27205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27206         LDKHostname this_obj_conv;
27207         this_obj_conv.inner = untag_ptr(this_obj);
27208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27210         Hostname_free(this_obj_conv);
27211 }
27212
27213 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27214         LDKHostname ret_var = Hostname_clone(arg);
27215         int64_t ret_ref = 0;
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27217         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27218         return ret_ref;
27219 }
27220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27221         LDKHostname arg_conv;
27222         arg_conv.inner = untag_ptr(arg);
27223         arg_conv.is_owned = ptr_is_owned(arg);
27224         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27225         arg_conv.is_owned = false;
27226         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27227         return ret_conv;
27228 }
27229
27230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27231         LDKHostname orig_conv;
27232         orig_conv.inner = untag_ptr(orig);
27233         orig_conv.is_owned = ptr_is_owned(orig);
27234         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27235         orig_conv.is_owned = false;
27236         LDKHostname ret_var = Hostname_clone(&orig_conv);
27237         int64_t ret_ref = 0;
27238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27240         return ret_ref;
27241 }
27242
27243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27244         LDKHostname a_conv;
27245         a_conv.inner = untag_ptr(a);
27246         a_conv.is_owned = ptr_is_owned(a);
27247         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27248         a_conv.is_owned = false;
27249         LDKHostname b_conv;
27250         b_conv.inner = untag_ptr(b);
27251         b_conv.is_owned = ptr_is_owned(b);
27252         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27253         b_conv.is_owned = false;
27254         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27255         return ret_conv;
27256 }
27257
27258 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27259         LDKHostname this_arg_conv;
27260         this_arg_conv.inner = untag_ptr(this_arg);
27261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27263         this_arg_conv.is_owned = false;
27264         int8_t ret_conv = Hostname_len(&this_arg_conv);
27265         return ret_conv;
27266 }
27267
27268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27269         LDKu8slice msg_ref;
27270         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27271         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27272         uint8_t sk_arr[32];
27273         CHECK((*env)->GetArrayLength(env, sk) == 32);
27274         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27275         uint8_t (*sk_ref)[32] = &sk_arr;
27276         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27277         *ret_conv = sign(msg_ref, sk_ref);
27278         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27279         return tag_ptr(ret_conv, true);
27280 }
27281
27282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27283         LDKu8slice msg_ref;
27284         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27285         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27286         LDKStr sig_conv = java_to_owned_str(env, sig);
27287         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27288         *ret_conv = recover_pk(msg_ref, sig_conv);
27289         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27290         return tag_ptr(ret_conv, true);
27291 }
27292
27293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27294         LDKu8slice msg_ref;
27295         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27296         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27297         LDKStr sig_conv = java_to_owned_str(env, sig);
27298         LDKPublicKey pk_ref;
27299         CHECK((*env)->GetArrayLength(env, pk) == 33);
27300         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27301         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27302         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27303         return ret_conv;
27304 }
27305
27306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27307         LDKu8slice hrp_bytes_ref;
27308         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27309         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27310         LDKCVec_U5Z data_without_signature_constr;
27311         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27312         if (data_without_signature_constr.datalen > 0)
27313                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27314         else
27315                 data_without_signature_constr.data = NULL;
27316         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27317         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27318                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27319                 
27320                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27321         }
27322         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27323         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27326         CVec_u8Z_free(ret_var);
27327         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27328         return ret_arr;
27329 }
27330
27331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27332         if (!ptr_is_owned(this_ptr)) return;
27333         void* this_ptr_ptr = untag_ptr(this_ptr);
27334         CHECK_ACCESS(this_ptr_ptr);
27335         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27336         FREE(untag_ptr(this_ptr));
27337         Persister_free(this_ptr_conv);
27338 }
27339
27340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27341         LDKUntrustedString this_obj_conv;
27342         this_obj_conv.inner = untag_ptr(this_obj);
27343         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27345         UntrustedString_free(this_obj_conv);
27346 }
27347
27348 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_UntrustedString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27349         LDKUntrustedString this_ptr_conv;
27350         this_ptr_conv.inner = untag_ptr(this_ptr);
27351         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27353         this_ptr_conv.is_owned = false;
27354         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
27355         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27356         Str_free(ret_str);
27357         return ret_conv;
27358 }
27359
27360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27361         LDKUntrustedString this_ptr_conv;
27362         this_ptr_conv.inner = untag_ptr(this_ptr);
27363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27365         this_ptr_conv.is_owned = false;
27366         LDKStr val_conv = java_to_owned_str(env, val);
27367         UntrustedString_set_a(&this_ptr_conv, val_conv);
27368 }
27369
27370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27371         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27372         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
27373         int64_t ret_ref = 0;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27376         return ret_ref;
27377 }
27378
27379 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
27380         LDKUntrustedString ret_var = UntrustedString_clone(arg);
27381         int64_t ret_ref = 0;
27382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27384         return ret_ref;
27385 }
27386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27387         LDKUntrustedString arg_conv;
27388         arg_conv.inner = untag_ptr(arg);
27389         arg_conv.is_owned = ptr_is_owned(arg);
27390         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27391         arg_conv.is_owned = false;
27392         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
27393         return ret_conv;
27394 }
27395
27396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27397         LDKUntrustedString orig_conv;
27398         orig_conv.inner = untag_ptr(orig);
27399         orig_conv.is_owned = ptr_is_owned(orig);
27400         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27401         orig_conv.is_owned = false;
27402         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
27403         int64_t ret_ref = 0;
27404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27405         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27406         return ret_ref;
27407 }
27408
27409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UntrustedString_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27410         LDKUntrustedString a_conv;
27411         a_conv.inner = untag_ptr(a);
27412         a_conv.is_owned = ptr_is_owned(a);
27413         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27414         a_conv.is_owned = false;
27415         LDKUntrustedString b_conv;
27416         b_conv.inner = untag_ptr(b);
27417         b_conv.is_owned = ptr_is_owned(b);
27418         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27419         b_conv.is_owned = false;
27420         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
27421         return ret_conv;
27422 }
27423
27424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UntrustedString_1write(JNIEnv *env, jclass clz, int64_t obj) {
27425         LDKUntrustedString obj_conv;
27426         obj_conv.inner = untag_ptr(obj);
27427         obj_conv.is_owned = ptr_is_owned(obj);
27428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27429         obj_conv.is_owned = false;
27430         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
27431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27433         CVec_u8Z_free(ret_var);
27434         return ret_arr;
27435 }
27436
27437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27438         LDKu8slice ser_ref;
27439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27441         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
27442         *ret_conv = UntrustedString_read(ser_ref);
27443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27444         return tag_ptr(ret_conv, true);
27445 }
27446
27447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27448         LDKPrintableString this_obj_conv;
27449         this_obj_conv.inner = untag_ptr(this_obj);
27450         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27452         PrintableString_free(this_obj_conv);
27453 }
27454
27455 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27456         LDKPrintableString this_ptr_conv;
27457         this_ptr_conv.inner = untag_ptr(this_ptr);
27458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27460         this_ptr_conv.is_owned = false;
27461         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27462         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27463         Str_free(ret_str);
27464         return ret_conv;
27465 }
27466
27467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27468         LDKPrintableString this_ptr_conv;
27469         this_ptr_conv.inner = untag_ptr(this_ptr);
27470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         this_ptr_conv.is_owned = false;
27473         LDKStr val_conv = java_to_owned_str(env, val);
27474         PrintableString_set_a(&this_ptr_conv, val_conv);
27475 }
27476
27477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27478         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27479         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27480         int64_t ret_ref = 0;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27483         return ret_ref;
27484 }
27485
27486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27487         if (!ptr_is_owned(this_ptr)) return;
27488         void* this_ptr_ptr = untag_ptr(this_ptr);
27489         CHECK_ACCESS(this_ptr_ptr);
27490         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27491         FREE(untag_ptr(this_ptr));
27492         FutureCallback_free(this_ptr_conv);
27493 }
27494
27495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27496         LDKFuture this_obj_conv;
27497         this_obj_conv.inner = untag_ptr(this_obj);
27498         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27500         Future_free(this_obj_conv);
27501 }
27502
27503 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
27504         LDKFuture ret_var = Future_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_Future_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27511         LDKFuture 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 = Future_clone_ptr(&arg_conv);
27517         return ret_conv;
27518 }
27519
27520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27521         LDKFuture 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         LDKFuture ret_var = Future_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_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27534         LDKFuture this_arg_conv;
27535         this_arg_conv.inner = untag_ptr(this_arg);
27536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27538         this_arg_conv.is_owned = false;
27539         void* callback_ptr = untag_ptr(callback);
27540         CHECK_ACCESS(callback_ptr);
27541         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27542         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27543                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27544                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27545         }
27546         Future_register_callback_fn(&this_arg_conv, callback_conv);
27547 }
27548
27549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27550         LDKFuture this_arg_conv;
27551         this_arg_conv.inner = untag_ptr(this_arg);
27552         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27554         this_arg_conv = Future_clone(&this_arg_conv);
27555         Future_wait(this_arg_conv);
27556 }
27557
27558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Future_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27559         LDKFuture this_arg_conv;
27560         this_arg_conv.inner = untag_ptr(this_arg);
27561         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27563         this_arg_conv = Future_clone(&this_arg_conv);
27564         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
27565         return ret_conv;
27566 }
27567
27568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27569         LDKSleeper this_obj_conv;
27570         this_obj_conv.inner = untag_ptr(this_obj);
27571         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27573         Sleeper_free(this_obj_conv);
27574 }
27575
27576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1single_1future(JNIEnv *env, jclass clz, int64_t future) {
27577         LDKFuture future_conv;
27578         future_conv.inner = untag_ptr(future);
27579         future_conv.is_owned = ptr_is_owned(future);
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
27581         future_conv = Future_clone(&future_conv);
27582         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
27583         int64_t ret_ref = 0;
27584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27586         return ret_ref;
27587 }
27588
27589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1two_1futures(JNIEnv *env, jclass clz, int64_t fut_a, int64_t fut_b) {
27590         LDKFuture fut_a_conv;
27591         fut_a_conv.inner = untag_ptr(fut_a);
27592         fut_a_conv.is_owned = ptr_is_owned(fut_a);
27593         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
27594         fut_a_conv = Future_clone(&fut_a_conv);
27595         LDKFuture fut_b_conv;
27596         fut_b_conv.inner = untag_ptr(fut_b);
27597         fut_b_conv.is_owned = ptr_is_owned(fut_b);
27598         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
27599         fut_b_conv = Future_clone(&fut_b_conv);
27600         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
27601         int64_t ret_ref = 0;
27602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27604         return ret_ref;
27605 }
27606
27607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1new(JNIEnv *env, jclass clz, int64_tArray futures) {
27608         LDKCVec_FutureZ futures_constr;
27609         futures_constr.datalen = (*env)->GetArrayLength(env, futures);
27610         if (futures_constr.datalen > 0)
27611                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
27612         else
27613                 futures_constr.data = NULL;
27614         int64_t* futures_vals = (*env)->GetLongArrayElements (env, futures, NULL);
27615         for (size_t i = 0; i < futures_constr.datalen; i++) {
27616                 int64_t futures_conv_8 = futures_vals[i];
27617                 LDKFuture futures_conv_8_conv;
27618                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
27619                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
27620                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
27621                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
27622                 futures_constr.data[i] = futures_conv_8_conv;
27623         }
27624         (*env)->ReleaseLongArrayElements(env, futures, futures_vals, 0);
27625         LDKSleeper ret_var = Sleeper_new(futures_constr);
27626         int64_t ret_ref = 0;
27627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27629         return ret_ref;
27630 }
27631
27632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27633         LDKSleeper this_arg_conv;
27634         this_arg_conv.inner = untag_ptr(this_arg);
27635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27637         this_arg_conv.is_owned = false;
27638         Sleeper_wait(&this_arg_conv);
27639 }
27640
27641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27642         LDKSleeper this_arg_conv;
27643         this_arg_conv.inner = untag_ptr(this_arg);
27644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27646         this_arg_conv.is_owned = false;
27647         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
27648         return ret_conv;
27649 }
27650
27651 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27652         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27653         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27654         return ret_conv;
27655 }
27656
27657 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27658         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27659         return ret_conv;
27660 }
27661
27662 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27663         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27664         return ret_conv;
27665 }
27666
27667 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27668         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27669         return ret_conv;
27670 }
27671
27672 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27673         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27674         return ret_conv;
27675 }
27676
27677 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27678         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27679         return ret_conv;
27680 }
27681
27682 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27683         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27684         return ret_conv;
27685 }
27686
27687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27688         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27689         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27690         jboolean ret_conv = Level_eq(a_conv, b_conv);
27691         return ret_conv;
27692 }
27693
27694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27695         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27696         int64_t ret_conv = Level_hash(o_conv);
27697         return ret_conv;
27698 }
27699
27700 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27701         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27702         return ret_conv;
27703 }
27704
27705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27706         LDKRecord this_obj_conv;
27707         this_obj_conv.inner = untag_ptr(this_obj);
27708         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27710         Record_free(this_obj_conv);
27711 }
27712
27713 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27714         LDKRecord this_ptr_conv;
27715         this_ptr_conv.inner = untag_ptr(this_ptr);
27716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27718         this_ptr_conv.is_owned = false;
27719         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27720         return ret_conv;
27721 }
27722
27723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27724         LDKRecord this_ptr_conv;
27725         this_ptr_conv.inner = untag_ptr(this_ptr);
27726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27728         this_ptr_conv.is_owned = false;
27729         LDKLevel val_conv = LDKLevel_from_java(env, val);
27730         Record_set_level(&this_ptr_conv, val_conv);
27731 }
27732
27733 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
27734         LDKRecord this_ptr_conv;
27735         this_ptr_conv.inner = untag_ptr(this_ptr);
27736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27738         this_ptr_conv.is_owned = false;
27739         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27740         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27741         Str_free(ret_str);
27742         return ret_conv;
27743 }
27744
27745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27746         LDKRecord this_ptr_conv;
27747         this_ptr_conv.inner = untag_ptr(this_ptr);
27748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27750         this_ptr_conv.is_owned = false;
27751         LDKStr val_conv = java_to_owned_str(env, val);
27752         Record_set_args(&this_ptr_conv, val_conv);
27753 }
27754
27755 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27756         LDKRecord this_ptr_conv;
27757         this_ptr_conv.inner = untag_ptr(this_ptr);
27758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27760         this_ptr_conv.is_owned = false;
27761         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27762         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27763         Str_free(ret_str);
27764         return ret_conv;
27765 }
27766
27767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27768         LDKRecord this_ptr_conv;
27769         this_ptr_conv.inner = untag_ptr(this_ptr);
27770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27772         this_ptr_conv.is_owned = false;
27773         LDKStr val_conv = java_to_owned_str(env, val);
27774         Record_set_module_path(&this_ptr_conv, val_conv);
27775 }
27776
27777 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27778         LDKRecord this_ptr_conv;
27779         this_ptr_conv.inner = untag_ptr(this_ptr);
27780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27782         this_ptr_conv.is_owned = false;
27783         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27784         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27785         Str_free(ret_str);
27786         return ret_conv;
27787 }
27788
27789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27790         LDKRecord this_ptr_conv;
27791         this_ptr_conv.inner = untag_ptr(this_ptr);
27792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27794         this_ptr_conv.is_owned = false;
27795         LDKStr val_conv = java_to_owned_str(env, val);
27796         Record_set_file(&this_ptr_conv, val_conv);
27797 }
27798
27799 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27800         LDKRecord this_ptr_conv;
27801         this_ptr_conv.inner = untag_ptr(this_ptr);
27802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27804         this_ptr_conv.is_owned = false;
27805         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27806         return ret_conv;
27807 }
27808
27809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27810         LDKRecord this_ptr_conv;
27811         this_ptr_conv.inner = untag_ptr(this_ptr);
27812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27814         this_ptr_conv.is_owned = false;
27815         Record_set_line(&this_ptr_conv, val);
27816 }
27817
27818 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27819         LDKRecord ret_var = Record_clone(arg);
27820         int64_t ret_ref = 0;
27821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27823         return ret_ref;
27824 }
27825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27826         LDKRecord arg_conv;
27827         arg_conv.inner = untag_ptr(arg);
27828         arg_conv.is_owned = ptr_is_owned(arg);
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27830         arg_conv.is_owned = false;
27831         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27832         return ret_conv;
27833 }
27834
27835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27836         LDKRecord orig_conv;
27837         orig_conv.inner = untag_ptr(orig);
27838         orig_conv.is_owned = ptr_is_owned(orig);
27839         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27840         orig_conv.is_owned = false;
27841         LDKRecord ret_var = Record_clone(&orig_conv);
27842         int64_t ret_ref = 0;
27843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27845         return ret_ref;
27846 }
27847
27848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27849         if (!ptr_is_owned(this_ptr)) return;
27850         void* this_ptr_ptr = untag_ptr(this_ptr);
27851         CHECK_ACCESS(this_ptr_ptr);
27852         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27853         FREE(untag_ptr(this_ptr));
27854         Logger_free(this_ptr_conv);
27855 }
27856
27857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27858         LDKChannelHandshakeConfig this_obj_conv;
27859         this_obj_conv.inner = untag_ptr(this_obj);
27860         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27862         ChannelHandshakeConfig_free(this_obj_conv);
27863 }
27864
27865 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27866         LDKChannelHandshakeConfig this_ptr_conv;
27867         this_ptr_conv.inner = untag_ptr(this_ptr);
27868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27870         this_ptr_conv.is_owned = false;
27871         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27872         return ret_conv;
27873 }
27874
27875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27876         LDKChannelHandshakeConfig this_ptr_conv;
27877         this_ptr_conv.inner = untag_ptr(this_ptr);
27878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27880         this_ptr_conv.is_owned = false;
27881         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27882 }
27883
27884 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27885         LDKChannelHandshakeConfig this_ptr_conv;
27886         this_ptr_conv.inner = untag_ptr(this_ptr);
27887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27889         this_ptr_conv.is_owned = false;
27890         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27891         return ret_conv;
27892 }
27893
27894 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) {
27895         LDKChannelHandshakeConfig this_ptr_conv;
27896         this_ptr_conv.inner = untag_ptr(this_ptr);
27897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27899         this_ptr_conv.is_owned = false;
27900         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27901 }
27902
27903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27904         LDKChannelHandshakeConfig this_ptr_conv;
27905         this_ptr_conv.inner = untag_ptr(this_ptr);
27906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27908         this_ptr_conv.is_owned = false;
27909         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27910         return ret_conv;
27911 }
27912
27913 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) {
27914         LDKChannelHandshakeConfig this_ptr_conv;
27915         this_ptr_conv.inner = untag_ptr(this_ptr);
27916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27918         this_ptr_conv.is_owned = false;
27919         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27920 }
27921
27922 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) {
27923         LDKChannelHandshakeConfig this_ptr_conv;
27924         this_ptr_conv.inner = untag_ptr(this_ptr);
27925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27927         this_ptr_conv.is_owned = false;
27928         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27929         return ret_conv;
27930 }
27931
27932 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) {
27933         LDKChannelHandshakeConfig this_ptr_conv;
27934         this_ptr_conv.inner = untag_ptr(this_ptr);
27935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27937         this_ptr_conv.is_owned = false;
27938         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27939 }
27940
27941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27942         LDKChannelHandshakeConfig this_ptr_conv;
27943         this_ptr_conv.inner = untag_ptr(this_ptr);
27944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27946         this_ptr_conv.is_owned = false;
27947         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27948         return ret_conv;
27949 }
27950
27951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27952         LDKChannelHandshakeConfig this_ptr_conv;
27953         this_ptr_conv.inner = untag_ptr(this_ptr);
27954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27956         this_ptr_conv.is_owned = false;
27957         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27958 }
27959
27960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27961         LDKChannelHandshakeConfig this_ptr_conv;
27962         this_ptr_conv.inner = untag_ptr(this_ptr);
27963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27965         this_ptr_conv.is_owned = false;
27966         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27967         return ret_conv;
27968 }
27969
27970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27971         LDKChannelHandshakeConfig this_ptr_conv;
27972         this_ptr_conv.inner = untag_ptr(this_ptr);
27973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27975         this_ptr_conv.is_owned = false;
27976         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27977 }
27978
27979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27980         LDKChannelHandshakeConfig this_ptr_conv;
27981         this_ptr_conv.inner = untag_ptr(this_ptr);
27982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27984         this_ptr_conv.is_owned = false;
27985         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27986         return ret_conv;
27987 }
27988
27989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27990         LDKChannelHandshakeConfig this_ptr_conv;
27991         this_ptr_conv.inner = untag_ptr(this_ptr);
27992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27994         this_ptr_conv.is_owned = false;
27995         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27996 }
27997
27998 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27999         LDKChannelHandshakeConfig this_ptr_conv;
28000         this_ptr_conv.inner = untag_ptr(this_ptr);
28001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28003         this_ptr_conv.is_owned = false;
28004         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
28005         return ret_conv;
28006 }
28007
28008 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) {
28009         LDKChannelHandshakeConfig this_ptr_conv;
28010         this_ptr_conv.inner = untag_ptr(this_ptr);
28011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28013         this_ptr_conv.is_owned = false;
28014         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
28015 }
28016
28017 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28018         LDKChannelHandshakeConfig this_ptr_conv;
28019         this_ptr_conv.inner = untag_ptr(this_ptr);
28020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28022         this_ptr_conv.is_owned = false;
28023         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
28024         return ret_conv;
28025 }
28026
28027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28028         LDKChannelHandshakeConfig this_ptr_conv;
28029         this_ptr_conv.inner = untag_ptr(this_ptr);
28030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28032         this_ptr_conv.is_owned = false;
28033         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
28034 }
28035
28036 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, int16_t our_max_accepted_htlcs_arg) {
28037         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, our_max_accepted_htlcs_arg);
28038         int64_t ret_ref = 0;
28039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28041         return ret_ref;
28042 }
28043
28044 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
28045         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
28046         int64_t ret_ref = 0;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28049         return ret_ref;
28050 }
28051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28052         LDKChannelHandshakeConfig arg_conv;
28053         arg_conv.inner = untag_ptr(arg);
28054         arg_conv.is_owned = ptr_is_owned(arg);
28055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28056         arg_conv.is_owned = false;
28057         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
28058         return ret_conv;
28059 }
28060
28061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28062         LDKChannelHandshakeConfig orig_conv;
28063         orig_conv.inner = untag_ptr(orig);
28064         orig_conv.is_owned = ptr_is_owned(orig);
28065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28066         orig_conv.is_owned = false;
28067         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
28068         int64_t ret_ref = 0;
28069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28071         return ret_ref;
28072 }
28073
28074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
28075         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
28076         int64_t ret_ref = 0;
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28079         return ret_ref;
28080 }
28081
28082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28083         LDKChannelHandshakeLimits this_obj_conv;
28084         this_obj_conv.inner = untag_ptr(this_obj);
28085         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28087         ChannelHandshakeLimits_free(this_obj_conv);
28088 }
28089
28090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28091         LDKChannelHandshakeLimits this_ptr_conv;
28092         this_ptr_conv.inner = untag_ptr(this_ptr);
28093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28095         this_ptr_conv.is_owned = false;
28096         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
28097         return ret_conv;
28098 }
28099
28100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28101         LDKChannelHandshakeLimits this_ptr_conv;
28102         this_ptr_conv.inner = untag_ptr(this_ptr);
28103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28105         this_ptr_conv.is_owned = false;
28106         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
28107 }
28108
28109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28110         LDKChannelHandshakeLimits this_ptr_conv;
28111         this_ptr_conv.inner = untag_ptr(this_ptr);
28112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28114         this_ptr_conv.is_owned = false;
28115         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
28116         return ret_conv;
28117 }
28118
28119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28120         LDKChannelHandshakeLimits this_ptr_conv;
28121         this_ptr_conv.inner = untag_ptr(this_ptr);
28122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28124         this_ptr_conv.is_owned = false;
28125         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
28126 }
28127
28128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28129         LDKChannelHandshakeLimits this_ptr_conv;
28130         this_ptr_conv.inner = untag_ptr(this_ptr);
28131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28133         this_ptr_conv.is_owned = false;
28134         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
28135         return ret_conv;
28136 }
28137
28138 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) {
28139         LDKChannelHandshakeLimits this_ptr_conv;
28140         this_ptr_conv.inner = untag_ptr(this_ptr);
28141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28143         this_ptr_conv.is_owned = false;
28144         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
28145 }
28146
28147 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) {
28148         LDKChannelHandshakeLimits this_ptr_conv;
28149         this_ptr_conv.inner = untag_ptr(this_ptr);
28150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28152         this_ptr_conv.is_owned = false;
28153         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
28154         return ret_conv;
28155 }
28156
28157 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) {
28158         LDKChannelHandshakeLimits this_ptr_conv;
28159         this_ptr_conv.inner = untag_ptr(this_ptr);
28160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28162         this_ptr_conv.is_owned = false;
28163         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28164 }
28165
28166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28167         LDKChannelHandshakeLimits this_ptr_conv;
28168         this_ptr_conv.inner = untag_ptr(this_ptr);
28169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28171         this_ptr_conv.is_owned = false;
28172         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
28173         return ret_conv;
28174 }
28175
28176 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) {
28177         LDKChannelHandshakeLimits this_ptr_conv;
28178         this_ptr_conv.inner = untag_ptr(this_ptr);
28179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28181         this_ptr_conv.is_owned = false;
28182         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
28183 }
28184
28185 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28186         LDKChannelHandshakeLimits this_ptr_conv;
28187         this_ptr_conv.inner = untag_ptr(this_ptr);
28188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28190         this_ptr_conv.is_owned = false;
28191         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
28192         return ret_conv;
28193 }
28194
28195 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) {
28196         LDKChannelHandshakeLimits this_ptr_conv;
28197         this_ptr_conv.inner = untag_ptr(this_ptr);
28198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28200         this_ptr_conv.is_owned = false;
28201         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
28202 }
28203
28204 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28205         LDKChannelHandshakeLimits this_ptr_conv;
28206         this_ptr_conv.inner = untag_ptr(this_ptr);
28207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28209         this_ptr_conv.is_owned = false;
28210         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
28211         return ret_conv;
28212 }
28213
28214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28215         LDKChannelHandshakeLimits 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         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
28221 }
28222
28223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
28224         LDKChannelHandshakeLimits this_ptr_conv;
28225         this_ptr_conv.inner = untag_ptr(this_ptr);
28226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28228         this_ptr_conv.is_owned = false;
28229         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
28230         return ret_conv;
28231 }
28232
28233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28234         LDKChannelHandshakeLimits this_ptr_conv;
28235         this_ptr_conv.inner = untag_ptr(this_ptr);
28236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28238         this_ptr_conv.is_owned = false;
28239         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
28240 }
28241
28242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
28243         LDKChannelHandshakeLimits this_ptr_conv;
28244         this_ptr_conv.inner = untag_ptr(this_ptr);
28245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28247         this_ptr_conv.is_owned = false;
28248         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
28249         return ret_conv;
28250 }
28251
28252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28253         LDKChannelHandshakeLimits this_ptr_conv;
28254         this_ptr_conv.inner = untag_ptr(this_ptr);
28255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28257         this_ptr_conv.is_owned = false;
28258         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
28259 }
28260
28261 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28262         LDKChannelHandshakeLimits this_ptr_conv;
28263         this_ptr_conv.inner = untag_ptr(this_ptr);
28264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28266         this_ptr_conv.is_owned = false;
28267         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
28268         return ret_conv;
28269 }
28270
28271 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) {
28272         LDKChannelHandshakeLimits this_ptr_conv;
28273         this_ptr_conv.inner = untag_ptr(this_ptr);
28274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28276         this_ptr_conv.is_owned = false;
28277         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
28278 }
28279
28280 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) {
28281         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);
28282         int64_t ret_ref = 0;
28283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28285         return ret_ref;
28286 }
28287
28288 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
28289         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
28290         int64_t ret_ref = 0;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28293         return ret_ref;
28294 }
28295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28296         LDKChannelHandshakeLimits arg_conv;
28297         arg_conv.inner = untag_ptr(arg);
28298         arg_conv.is_owned = ptr_is_owned(arg);
28299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28300         arg_conv.is_owned = false;
28301         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
28302         return ret_conv;
28303 }
28304
28305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28306         LDKChannelHandshakeLimits orig_conv;
28307         orig_conv.inner = untag_ptr(orig);
28308         orig_conv.is_owned = ptr_is_owned(orig);
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28310         orig_conv.is_owned = false;
28311         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
28312         int64_t ret_ref = 0;
28313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28315         return ret_ref;
28316 }
28317
28318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
28319         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
28320         int64_t ret_ref = 0;
28321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28322         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28323         return ret_ref;
28324 }
28325
28326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28327         LDKChannelConfig this_obj_conv;
28328         this_obj_conv.inner = untag_ptr(this_obj);
28329         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28331         ChannelConfig_free(this_obj_conv);
28332 }
28333
28334 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28335         LDKChannelConfig this_ptr_conv;
28336         this_ptr_conv.inner = untag_ptr(this_ptr);
28337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28339         this_ptr_conv.is_owned = false;
28340         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28341         return ret_conv;
28342 }
28343
28344 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) {
28345         LDKChannelConfig this_ptr_conv;
28346         this_ptr_conv.inner = untag_ptr(this_ptr);
28347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28349         this_ptr_conv.is_owned = false;
28350         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28351 }
28352
28353 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28354         LDKChannelConfig this_ptr_conv;
28355         this_ptr_conv.inner = untag_ptr(this_ptr);
28356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28358         this_ptr_conv.is_owned = false;
28359         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28360         return ret_conv;
28361 }
28362
28363 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) {
28364         LDKChannelConfig this_ptr_conv;
28365         this_ptr_conv.inner = untag_ptr(this_ptr);
28366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28368         this_ptr_conv.is_owned = false;
28369         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28370 }
28371
28372 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28373         LDKChannelConfig this_ptr_conv;
28374         this_ptr_conv.inner = untag_ptr(this_ptr);
28375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28377         this_ptr_conv.is_owned = false;
28378         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28379         return ret_conv;
28380 }
28381
28382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28383         LDKChannelConfig this_ptr_conv;
28384         this_ptr_conv.inner = untag_ptr(this_ptr);
28385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28387         this_ptr_conv.is_owned = false;
28388         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28389 }
28390
28391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28392         LDKChannelConfig this_ptr_conv;
28393         this_ptr_conv.inner = untag_ptr(this_ptr);
28394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28396         this_ptr_conv.is_owned = false;
28397         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28398         return ret_conv;
28399 }
28400
28401 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) {
28402         LDKChannelConfig this_ptr_conv;
28403         this_ptr_conv.inner = untag_ptr(this_ptr);
28404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28406         this_ptr_conv.is_owned = false;
28407         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28408 }
28409
28410 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) {
28411         LDKChannelConfig this_ptr_conv;
28412         this_ptr_conv.inner = untag_ptr(this_ptr);
28413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28415         this_ptr_conv.is_owned = false;
28416         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28417         return ret_conv;
28418 }
28419
28420 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) {
28421         LDKChannelConfig this_ptr_conv;
28422         this_ptr_conv.inner = untag_ptr(this_ptr);
28423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28425         this_ptr_conv.is_owned = false;
28426         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28427 }
28428
28429 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) {
28430         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);
28431         int64_t ret_ref = 0;
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28434         return ret_ref;
28435 }
28436
28437 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28438         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28439         int64_t ret_ref = 0;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28442         return ret_ref;
28443 }
28444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28445         LDKChannelConfig arg_conv;
28446         arg_conv.inner = untag_ptr(arg);
28447         arg_conv.is_owned = ptr_is_owned(arg);
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28449         arg_conv.is_owned = false;
28450         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28451         return ret_conv;
28452 }
28453
28454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28455         LDKChannelConfig orig_conv;
28456         orig_conv.inner = untag_ptr(orig);
28457         orig_conv.is_owned = ptr_is_owned(orig);
28458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28459         orig_conv.is_owned = false;
28460         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_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 jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28468         LDKChannelConfig a_conv;
28469         a_conv.inner = untag_ptr(a);
28470         a_conv.is_owned = ptr_is_owned(a);
28471         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28472         a_conv.is_owned = false;
28473         LDKChannelConfig b_conv;
28474         b_conv.inner = untag_ptr(b);
28475         b_conv.is_owned = ptr_is_owned(b);
28476         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28477         b_conv.is_owned = false;
28478         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28479         return ret_conv;
28480 }
28481
28482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28483         LDKChannelConfig ret_var = ChannelConfig_default();
28484         int64_t ret_ref = 0;
28485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28487         return ret_ref;
28488 }
28489
28490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28491         LDKChannelConfig obj_conv;
28492         obj_conv.inner = untag_ptr(obj);
28493         obj_conv.is_owned = ptr_is_owned(obj);
28494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28495         obj_conv.is_owned = false;
28496         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28499         CVec_u8Z_free(ret_var);
28500         return ret_arr;
28501 }
28502
28503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28504         LDKu8slice ser_ref;
28505         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28506         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28507         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28508         *ret_conv = ChannelConfig_read(ser_ref);
28509         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28510         return tag_ptr(ret_conv, true);
28511 }
28512
28513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28514         LDKUserConfig this_obj_conv;
28515         this_obj_conv.inner = untag_ptr(this_obj);
28516         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28518         UserConfig_free(this_obj_conv);
28519 }
28520
28521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28522         LDKUserConfig this_ptr_conv;
28523         this_ptr_conv.inner = untag_ptr(this_ptr);
28524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28526         this_ptr_conv.is_owned = false;
28527         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28528         int64_t ret_ref = 0;
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28531         return ret_ref;
28532 }
28533
28534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28535         LDKUserConfig this_ptr_conv;
28536         this_ptr_conv.inner = untag_ptr(this_ptr);
28537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28539         this_ptr_conv.is_owned = false;
28540         LDKChannelHandshakeConfig val_conv;
28541         val_conv.inner = untag_ptr(val);
28542         val_conv.is_owned = ptr_is_owned(val);
28543         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28544         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28545         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28546 }
28547
28548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28549         LDKUserConfig this_ptr_conv;
28550         this_ptr_conv.inner = untag_ptr(this_ptr);
28551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28553         this_ptr_conv.is_owned = false;
28554         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28555         int64_t ret_ref = 0;
28556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28557         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28558         return ret_ref;
28559 }
28560
28561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28562         LDKUserConfig this_ptr_conv;
28563         this_ptr_conv.inner = untag_ptr(this_ptr);
28564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28566         this_ptr_conv.is_owned = false;
28567         LDKChannelHandshakeLimits val_conv;
28568         val_conv.inner = untag_ptr(val);
28569         val_conv.is_owned = ptr_is_owned(val);
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28571         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28572         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28573 }
28574
28575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28576         LDKUserConfig this_ptr_conv;
28577         this_ptr_conv.inner = untag_ptr(this_ptr);
28578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28580         this_ptr_conv.is_owned = false;
28581         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28582         int64_t ret_ref = 0;
28583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28584         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28585         return ret_ref;
28586 }
28587
28588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28589         LDKUserConfig this_ptr_conv;
28590         this_ptr_conv.inner = untag_ptr(this_ptr);
28591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28593         this_ptr_conv.is_owned = false;
28594         LDKChannelConfig val_conv;
28595         val_conv.inner = untag_ptr(val);
28596         val_conv.is_owned = ptr_is_owned(val);
28597         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28598         val_conv = ChannelConfig_clone(&val_conv);
28599         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28600 }
28601
28602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28603         LDKUserConfig this_ptr_conv;
28604         this_ptr_conv.inner = untag_ptr(this_ptr);
28605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28607         this_ptr_conv.is_owned = false;
28608         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28609         return ret_conv;
28610 }
28611
28612 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) {
28613         LDKUserConfig this_ptr_conv;
28614         this_ptr_conv.inner = untag_ptr(this_ptr);
28615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28617         this_ptr_conv.is_owned = false;
28618         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28619 }
28620
28621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28622         LDKUserConfig this_ptr_conv;
28623         this_ptr_conv.inner = untag_ptr(this_ptr);
28624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28626         this_ptr_conv.is_owned = false;
28627         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28628         return ret_conv;
28629 }
28630
28631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28632         LDKUserConfig this_ptr_conv;
28633         this_ptr_conv.inner = untag_ptr(this_ptr);
28634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28636         this_ptr_conv.is_owned = false;
28637         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28638 }
28639
28640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28641         LDKUserConfig this_ptr_conv;
28642         this_ptr_conv.inner = untag_ptr(this_ptr);
28643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28645         this_ptr_conv.is_owned = false;
28646         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28647         return ret_conv;
28648 }
28649
28650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28651         LDKUserConfig this_ptr_conv;
28652         this_ptr_conv.inner = untag_ptr(this_ptr);
28653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28655         this_ptr_conv.is_owned = false;
28656         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28657 }
28658
28659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28660         LDKUserConfig this_ptr_conv;
28661         this_ptr_conv.inner = untag_ptr(this_ptr);
28662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28664         this_ptr_conv.is_owned = false;
28665         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28666         return ret_conv;
28667 }
28668
28669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28670         LDKUserConfig this_ptr_conv;
28671         this_ptr_conv.inner = untag_ptr(this_ptr);
28672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28674         this_ptr_conv.is_owned = false;
28675         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28676 }
28677
28678 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) {
28679         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28680         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28681         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28682         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28683         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28684         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28685         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28686         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28687         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28688         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28689         LDKChannelConfig channel_config_arg_conv;
28690         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28691         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28692         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28693         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28694         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);
28695         int64_t ret_ref = 0;
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28698         return ret_ref;
28699 }
28700
28701 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28702         LDKUserConfig ret_var = UserConfig_clone(arg);
28703         int64_t ret_ref = 0;
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28706         return ret_ref;
28707 }
28708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28709         LDKUserConfig arg_conv;
28710         arg_conv.inner = untag_ptr(arg);
28711         arg_conv.is_owned = ptr_is_owned(arg);
28712         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28713         arg_conv.is_owned = false;
28714         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28715         return ret_conv;
28716 }
28717
28718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28719         LDKUserConfig orig_conv;
28720         orig_conv.inner = untag_ptr(orig);
28721         orig_conv.is_owned = ptr_is_owned(orig);
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28723         orig_conv.is_owned = false;
28724         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28725         int64_t ret_ref = 0;
28726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28728         return ret_ref;
28729 }
28730
28731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28732         LDKUserConfig ret_var = UserConfig_default();
28733         int64_t ret_ref = 0;
28734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28736         return ret_ref;
28737 }
28738
28739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28740         LDKBestBlock this_obj_conv;
28741         this_obj_conv.inner = untag_ptr(this_obj);
28742         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28744         BestBlock_free(this_obj_conv);
28745 }
28746
28747 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28748         LDKBestBlock ret_var = BestBlock_clone(arg);
28749         int64_t ret_ref = 0;
28750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28752         return ret_ref;
28753 }
28754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28755         LDKBestBlock arg_conv;
28756         arg_conv.inner = untag_ptr(arg);
28757         arg_conv.is_owned = ptr_is_owned(arg);
28758         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28759         arg_conv.is_owned = false;
28760         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28761         return ret_conv;
28762 }
28763
28764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28765         LDKBestBlock orig_conv;
28766         orig_conv.inner = untag_ptr(orig);
28767         orig_conv.is_owned = ptr_is_owned(orig);
28768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28769         orig_conv.is_owned = false;
28770         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28771         int64_t ret_ref = 0;
28772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28774         return ret_ref;
28775 }
28776
28777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28778         LDKBestBlock a_conv;
28779         a_conv.inner = untag_ptr(a);
28780         a_conv.is_owned = ptr_is_owned(a);
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28782         a_conv.is_owned = false;
28783         LDKBestBlock b_conv;
28784         b_conv.inner = untag_ptr(b);
28785         b_conv.is_owned = ptr_is_owned(b);
28786         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28787         b_conv.is_owned = false;
28788         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28789         return ret_conv;
28790 }
28791
28792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1network(JNIEnv *env, jclass clz, jclass network) {
28793         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28794         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
28795         int64_t ret_ref = 0;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28798         return ret_ref;
28799 }
28800
28801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28802         LDKThirtyTwoBytes block_hash_ref;
28803         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28804         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28805         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28806         int64_t ret_ref = 0;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28809         return ret_ref;
28810 }
28811
28812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28813         LDKBestBlock this_arg_conv;
28814         this_arg_conv.inner = untag_ptr(this_arg);
28815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28817         this_arg_conv.is_owned = false;
28818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28820         return ret_arr;
28821 }
28822
28823 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28824         LDKBestBlock this_arg_conv;
28825         this_arg_conv.inner = untag_ptr(this_arg);
28826         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28828         this_arg_conv.is_owned = false;
28829         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28830         return ret_conv;
28831 }
28832
28833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28834         if (!ptr_is_owned(this_ptr)) return;
28835         void* this_ptr_ptr = untag_ptr(this_ptr);
28836         CHECK_ACCESS(this_ptr_ptr);
28837         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28838         FREE(untag_ptr(this_ptr));
28839         Listen_free(this_ptr_conv);
28840 }
28841
28842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28843         if (!ptr_is_owned(this_ptr)) return;
28844         void* this_ptr_ptr = untag_ptr(this_ptr);
28845         CHECK_ACCESS(this_ptr_ptr);
28846         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28847         FREE(untag_ptr(this_ptr));
28848         Confirm_free(this_ptr_conv);
28849 }
28850
28851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28852         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28853         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28854         return ret_conv;
28855 }
28856
28857 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28858         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28859         return ret_conv;
28860 }
28861
28862 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28863         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28864         return ret_conv;
28865 }
28866
28867 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28868         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28869         return ret_conv;
28870 }
28871
28872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28873         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28874         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28875         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28876         return ret_conv;
28877 }
28878
28879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28880         if (!ptr_is_owned(this_ptr)) return;
28881         void* this_ptr_ptr = untag_ptr(this_ptr);
28882         CHECK_ACCESS(this_ptr_ptr);
28883         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28884         FREE(untag_ptr(this_ptr));
28885         Watch_free(this_ptr_conv);
28886 }
28887
28888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28889         if (!ptr_is_owned(this_ptr)) return;
28890         void* this_ptr_ptr = untag_ptr(this_ptr);
28891         CHECK_ACCESS(this_ptr_ptr);
28892         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28893         FREE(untag_ptr(this_ptr));
28894         Filter_free(this_ptr_conv);
28895 }
28896
28897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28898         LDKWatchedOutput this_obj_conv;
28899         this_obj_conv.inner = untag_ptr(this_obj);
28900         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28902         WatchedOutput_free(this_obj_conv);
28903 }
28904
28905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28906         LDKWatchedOutput this_ptr_conv;
28907         this_ptr_conv.inner = untag_ptr(this_ptr);
28908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28910         this_ptr_conv.is_owned = false;
28911         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28913         return ret_arr;
28914 }
28915
28916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28917         LDKWatchedOutput this_ptr_conv;
28918         this_ptr_conv.inner = untag_ptr(this_ptr);
28919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28921         this_ptr_conv.is_owned = false;
28922         LDKThirtyTwoBytes val_ref;
28923         CHECK((*env)->GetArrayLength(env, val) == 32);
28924         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28925         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28926 }
28927
28928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28929         LDKWatchedOutput this_ptr_conv;
28930         this_ptr_conv.inner = untag_ptr(this_ptr);
28931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28933         this_ptr_conv.is_owned = false;
28934         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28935         int64_t ret_ref = 0;
28936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28938         return ret_ref;
28939 }
28940
28941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28942         LDKWatchedOutput this_ptr_conv;
28943         this_ptr_conv.inner = untag_ptr(this_ptr);
28944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28946         this_ptr_conv.is_owned = false;
28947         LDKOutPoint val_conv;
28948         val_conv.inner = untag_ptr(val);
28949         val_conv.is_owned = ptr_is_owned(val);
28950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28951         val_conv = OutPoint_clone(&val_conv);
28952         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28953 }
28954
28955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28956         LDKWatchedOutput this_ptr_conv;
28957         this_ptr_conv.inner = untag_ptr(this_ptr);
28958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28960         this_ptr_conv.is_owned = false;
28961         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28964         return ret_arr;
28965 }
28966
28967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28968         LDKWatchedOutput this_ptr_conv;
28969         this_ptr_conv.inner = untag_ptr(this_ptr);
28970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28972         this_ptr_conv.is_owned = false;
28973         LDKCVec_u8Z val_ref;
28974         val_ref.datalen = (*env)->GetArrayLength(env, val);
28975         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28976         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28977         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28978 }
28979
28980 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) {
28981         LDKThirtyTwoBytes block_hash_arg_ref;
28982         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28983         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28984         LDKOutPoint outpoint_arg_conv;
28985         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28986         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28987         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28988         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28989         LDKCVec_u8Z script_pubkey_arg_ref;
28990         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28991         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28992         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28993         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28994         int64_t ret_ref = 0;
28995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28997         return ret_ref;
28998 }
28999
29000 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
29001         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
29002         int64_t ret_ref = 0;
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29005         return ret_ref;
29006 }
29007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29008         LDKWatchedOutput arg_conv;
29009         arg_conv.inner = untag_ptr(arg);
29010         arg_conv.is_owned = ptr_is_owned(arg);
29011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29012         arg_conv.is_owned = false;
29013         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
29014         return ret_conv;
29015 }
29016
29017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29018         LDKWatchedOutput orig_conv;
29019         orig_conv.inner = untag_ptr(orig);
29020         orig_conv.is_owned = ptr_is_owned(orig);
29021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29022         orig_conv.is_owned = false;
29023         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
29024         int64_t ret_ref = 0;
29025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29027         return ret_ref;
29028 }
29029
29030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29031         LDKWatchedOutput a_conv;
29032         a_conv.inner = untag_ptr(a);
29033         a_conv.is_owned = ptr_is_owned(a);
29034         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29035         a_conv.is_owned = false;
29036         LDKWatchedOutput b_conv;
29037         b_conv.inner = untag_ptr(b);
29038         b_conv.is_owned = ptr_is_owned(b);
29039         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29040         b_conv.is_owned = false;
29041         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
29042         return ret_conv;
29043 }
29044
29045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
29046         LDKWatchedOutput o_conv;
29047         o_conv.inner = untag_ptr(o);
29048         o_conv.is_owned = ptr_is_owned(o);
29049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29050         o_conv.is_owned = false;
29051         int64_t ret_conv = WatchedOutput_hash(&o_conv);
29052         return ret_conv;
29053 }
29054
29055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29056         if (!ptr_is_owned(this_ptr)) return;
29057         void* this_ptr_ptr = untag_ptr(this_ptr);
29058         CHECK_ACCESS(this_ptr_ptr);
29059         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
29060         FREE(untag_ptr(this_ptr));
29061         BroadcasterInterface_free(this_ptr_conv);
29062 }
29063
29064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29065         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
29066         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
29067         return ret_conv;
29068 }
29069
29070 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
29071         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
29072         return ret_conv;
29073 }
29074
29075 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
29076         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
29077         return ret_conv;
29078 }
29079
29080 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
29081         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
29082         return ret_conv;
29083 }
29084
29085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
29086         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
29087         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
29088         return ret_conv;
29089 }
29090
29091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29092         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
29093         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
29094         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
29095         return ret_conv;
29096 }
29097
29098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29099         if (!ptr_is_owned(this_ptr)) return;
29100         void* this_ptr_ptr = untag_ptr(this_ptr);
29101         CHECK_ACCESS(this_ptr_ptr);
29102         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
29103         FREE(untag_ptr(this_ptr));
29104         FeeEstimator_free(this_ptr_conv);
29105 }
29106
29107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29108         LDKMonitorUpdateId this_obj_conv;
29109         this_obj_conv.inner = untag_ptr(this_obj);
29110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29112         MonitorUpdateId_free(this_obj_conv);
29113 }
29114
29115 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
29116         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
29117         int64_t ret_ref = 0;
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29120         return ret_ref;
29121 }
29122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29123         LDKMonitorUpdateId arg_conv;
29124         arg_conv.inner = untag_ptr(arg);
29125         arg_conv.is_owned = ptr_is_owned(arg);
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29127         arg_conv.is_owned = false;
29128         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
29129         return ret_conv;
29130 }
29131
29132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29133         LDKMonitorUpdateId orig_conv;
29134         orig_conv.inner = untag_ptr(orig);
29135         orig_conv.is_owned = ptr_is_owned(orig);
29136         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29137         orig_conv.is_owned = false;
29138         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
29139         int64_t ret_ref = 0;
29140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29142         return ret_ref;
29143 }
29144
29145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29146         LDKMonitorUpdateId o_conv;
29147         o_conv.inner = untag_ptr(o);
29148         o_conv.is_owned = ptr_is_owned(o);
29149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29150         o_conv.is_owned = false;
29151         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
29152         return ret_conv;
29153 }
29154
29155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29156         LDKMonitorUpdateId a_conv;
29157         a_conv.inner = untag_ptr(a);
29158         a_conv.is_owned = ptr_is_owned(a);
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29160         a_conv.is_owned = false;
29161         LDKMonitorUpdateId b_conv;
29162         b_conv.inner = untag_ptr(b);
29163         b_conv.is_owned = ptr_is_owned(b);
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29165         b_conv.is_owned = false;
29166         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
29167         return ret_conv;
29168 }
29169
29170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29171         if (!ptr_is_owned(this_ptr)) return;
29172         void* this_ptr_ptr = untag_ptr(this_ptr);
29173         CHECK_ACCESS(this_ptr_ptr);
29174         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
29175         FREE(untag_ptr(this_ptr));
29176         Persist_free(this_ptr_conv);
29177 }
29178
29179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29180         LDKLockedChannelMonitor this_obj_conv;
29181         this_obj_conv.inner = untag_ptr(this_obj);
29182         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29184         LockedChannelMonitor_free(this_obj_conv);
29185 }
29186
29187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29188         LDKChainMonitor this_obj_conv;
29189         this_obj_conv.inner = untag_ptr(this_obj);
29190         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29192         ChainMonitor_free(this_obj_conv);
29193 }
29194
29195 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) {
29196         void* chain_source_ptr = untag_ptr(chain_source);
29197         CHECK_ACCESS(chain_source_ptr);
29198         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
29199         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
29200         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
29201                 // Manually implement clone for Java trait instances
29202                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
29203                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29204                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
29205                 }
29206         }
29207         void* broadcaster_ptr = untag_ptr(broadcaster);
29208         CHECK_ACCESS(broadcaster_ptr);
29209         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29210         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29212                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29213         }
29214         void* logger_ptr = untag_ptr(logger);
29215         CHECK_ACCESS(logger_ptr);
29216         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29217         if (logger_conv.free == LDKLogger_JCalls_free) {
29218                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29219                 LDKLogger_JCalls_cloned(&logger_conv);
29220         }
29221         void* feeest_ptr = untag_ptr(feeest);
29222         CHECK_ACCESS(feeest_ptr);
29223         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
29224         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
29225                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29226                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
29227         }
29228         void* persister_ptr = untag_ptr(persister);
29229         CHECK_ACCESS(persister_ptr);
29230         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
29231         if (persister_conv.free == LDKPersist_JCalls_free) {
29232                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29233                 LDKPersist_JCalls_cloned(&persister_conv);
29234         }
29235         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
29236         int64_t ret_ref = 0;
29237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29239         return ret_ref;
29240 }
29241
29242 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) {
29243         LDKChainMonitor this_arg_conv;
29244         this_arg_conv.inner = untag_ptr(this_arg);
29245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29247         this_arg_conv.is_owned = false;
29248         LDKCVec_ChannelDetailsZ ignored_channels_constr;
29249         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
29250         if (ignored_channels_constr.datalen > 0)
29251                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29252         else
29253                 ignored_channels_constr.data = NULL;
29254         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
29255         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
29256                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
29257                 LDKChannelDetails ignored_channels_conv_16_conv;
29258                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
29259                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
29260                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
29261                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
29262                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
29263         }
29264         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
29265         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
29266         int64_tArray ret_arr = NULL;
29267         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29268         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29269         for (size_t j = 0; j < ret_var.datalen; j++) {
29270                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29271                 *ret_conv_9_copy = ret_var.data[j];
29272                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29273                 ret_arr_ptr[j] = ret_conv_9_ref;
29274         }
29275         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29276         FREE(ret_var.data);
29277         return ret_arr;
29278 }
29279
29280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
29281         LDKChainMonitor this_arg_conv;
29282         this_arg_conv.inner = untag_ptr(this_arg);
29283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29285         this_arg_conv.is_owned = false;
29286         LDKOutPoint funding_txo_conv;
29287         funding_txo_conv.inner = untag_ptr(funding_txo);
29288         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29289         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29290         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29291         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29292         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
29293         return tag_ptr(ret_conv, true);
29294 }
29295
29296 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
29297         LDKChainMonitor this_arg_conv;
29298         this_arg_conv.inner = untag_ptr(this_arg);
29299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29301         this_arg_conv.is_owned = false;
29302         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
29303         int64_tArray ret_arr = NULL;
29304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29306         for (size_t k = 0; k < ret_var.datalen; k++) {
29307                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29308                 int64_t ret_conv_10_ref = 0;
29309                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29310                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29311                 ret_arr_ptr[k] = ret_conv_10_ref;
29312         }
29313         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29314         FREE(ret_var.data);
29315         return ret_arr;
29316 }
29317
29318 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29319         LDKChainMonitor this_arg_conv;
29320         this_arg_conv.inner = untag_ptr(this_arg);
29321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29323         this_arg_conv.is_owned = false;
29324         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29325         int64_tArray ret_arr = NULL;
29326         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29327         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29328         for (size_t p = 0; p < ret_var.datalen; p++) {
29329                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29330                 *ret_conv_41_conv = ret_var.data[p];
29331                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
29332         }
29333         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29334         FREE(ret_var.data);
29335         return ret_arr;
29336 }
29337
29338 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) {
29339         LDKChainMonitor this_arg_conv;
29340         this_arg_conv.inner = untag_ptr(this_arg);
29341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29343         this_arg_conv.is_owned = false;
29344         LDKOutPoint funding_txo_conv;
29345         funding_txo_conv.inner = untag_ptr(funding_txo);
29346         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29347         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29348         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29349         LDKMonitorUpdateId completed_update_id_conv;
29350         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29351         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29352         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29353         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29354         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29355         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29356         return tag_ptr(ret_conv, true);
29357 }
29358
29359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
29360         LDKChainMonitor this_arg_conv;
29361         this_arg_conv.inner = untag_ptr(this_arg);
29362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29364         this_arg_conv.is_owned = false;
29365         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
29366         int64_t ret_ref = 0;
29367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29369         return ret_ref;
29370 }
29371
29372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg) {
29373         LDKChainMonitor this_arg_conv;
29374         this_arg_conv.inner = untag_ptr(this_arg);
29375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29377         this_arg_conv.is_owned = false;
29378         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
29379 }
29380
29381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29382         LDKChainMonitor this_arg_conv;
29383         this_arg_conv.inner = untag_ptr(this_arg);
29384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29386         this_arg_conv.is_owned = false;
29387         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29388         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29389         return tag_ptr(ret_ret, true);
29390 }
29391
29392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29393         LDKChainMonitor this_arg_conv;
29394         this_arg_conv.inner = untag_ptr(this_arg);
29395         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29397         this_arg_conv.is_owned = false;
29398         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29399         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29400         return tag_ptr(ret_ret, true);
29401 }
29402
29403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29404         LDKChainMonitor this_arg_conv;
29405         this_arg_conv.inner = untag_ptr(this_arg);
29406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29408         this_arg_conv.is_owned = false;
29409         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29410         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29411         return tag_ptr(ret_ret, true);
29412 }
29413
29414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29415         LDKChainMonitor this_arg_conv;
29416         this_arg_conv.inner = untag_ptr(this_arg);
29417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29419         this_arg_conv.is_owned = false;
29420         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29421         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29422         return tag_ptr(ret_ret, true);
29423 }
29424
29425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29426         LDKChannelMonitorUpdate this_obj_conv;
29427         this_obj_conv.inner = untag_ptr(this_obj);
29428         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29430         ChannelMonitorUpdate_free(this_obj_conv);
29431 }
29432
29433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29434         LDKChannelMonitorUpdate this_ptr_conv;
29435         this_ptr_conv.inner = untag_ptr(this_ptr);
29436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29438         this_ptr_conv.is_owned = false;
29439         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29440         return ret_conv;
29441 }
29442
29443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29444         LDKChannelMonitorUpdate this_ptr_conv;
29445         this_ptr_conv.inner = untag_ptr(this_ptr);
29446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29448         this_ptr_conv.is_owned = false;
29449         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29450 }
29451
29452 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29453         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29454         int64_t ret_ref = 0;
29455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29456         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29457         return ret_ref;
29458 }
29459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29460         LDKChannelMonitorUpdate arg_conv;
29461         arg_conv.inner = untag_ptr(arg);
29462         arg_conv.is_owned = ptr_is_owned(arg);
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29464         arg_conv.is_owned = false;
29465         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29466         return ret_conv;
29467 }
29468
29469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29470         LDKChannelMonitorUpdate orig_conv;
29471         orig_conv.inner = untag_ptr(orig);
29472         orig_conv.is_owned = ptr_is_owned(orig);
29473         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29474         orig_conv.is_owned = false;
29475         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29476         int64_t ret_ref = 0;
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29479         return ret_ref;
29480 }
29481
29482 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29483         LDKChannelMonitorUpdate a_conv;
29484         a_conv.inner = untag_ptr(a);
29485         a_conv.is_owned = ptr_is_owned(a);
29486         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29487         a_conv.is_owned = false;
29488         LDKChannelMonitorUpdate b_conv;
29489         b_conv.inner = untag_ptr(b);
29490         b_conv.is_owned = ptr_is_owned(b);
29491         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29492         b_conv.is_owned = false;
29493         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
29494         return ret_conv;
29495 }
29496
29497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29498         LDKChannelMonitorUpdate obj_conv;
29499         obj_conv.inner = untag_ptr(obj);
29500         obj_conv.is_owned = ptr_is_owned(obj);
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29502         obj_conv.is_owned = false;
29503         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29506         CVec_u8Z_free(ret_var);
29507         return ret_arr;
29508 }
29509
29510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29511         LDKu8slice ser_ref;
29512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29514         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29515         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29517         return tag_ptr(ret_conv, true);
29518 }
29519
29520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29521         if (!ptr_is_owned(this_ptr)) return;
29522         void* this_ptr_ptr = untag_ptr(this_ptr);
29523         CHECK_ACCESS(this_ptr_ptr);
29524         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29525         FREE(untag_ptr(this_ptr));
29526         MonitorEvent_free(this_ptr_conv);
29527 }
29528
29529 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29530         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29531         *ret_copy = MonitorEvent_clone(arg);
29532         int64_t ret_ref = tag_ptr(ret_copy, true);
29533         return ret_ref;
29534 }
29535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29536         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29537         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29538         return ret_conv;
29539 }
29540
29541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29542         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29543         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29544         *ret_copy = MonitorEvent_clone(orig_conv);
29545         int64_t ret_ref = tag_ptr(ret_copy, true);
29546         return ret_ref;
29547 }
29548
29549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29550         LDKHTLCUpdate a_conv;
29551         a_conv.inner = untag_ptr(a);
29552         a_conv.is_owned = ptr_is_owned(a);
29553         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29554         a_conv = HTLCUpdate_clone(&a_conv);
29555         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29556         *ret_copy = MonitorEvent_htlcevent(a_conv);
29557         int64_t ret_ref = tag_ptr(ret_copy, true);
29558         return ret_ref;
29559 }
29560
29561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29562         LDKOutPoint a_conv;
29563         a_conv.inner = untag_ptr(a);
29564         a_conv.is_owned = ptr_is_owned(a);
29565         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29566         a_conv = OutPoint_clone(&a_conv);
29567         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29568         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29569         int64_t ret_ref = tag_ptr(ret_copy, true);
29570         return ret_ref;
29571 }
29572
29573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29574         LDKOutPoint funding_txo_conv;
29575         funding_txo_conv.inner = untag_ptr(funding_txo);
29576         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29577         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29578         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29579         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29580         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29581         int64_t ret_ref = tag_ptr(ret_copy, true);
29582         return ret_ref;
29583 }
29584
29585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29586         LDKOutPoint a_conv;
29587         a_conv.inner = untag_ptr(a);
29588         a_conv.is_owned = ptr_is_owned(a);
29589         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29590         a_conv = OutPoint_clone(&a_conv);
29591         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29592         *ret_copy = MonitorEvent_update_failed(a_conv);
29593         int64_t ret_ref = tag_ptr(ret_copy, true);
29594         return ret_ref;
29595 }
29596
29597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29598         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29599         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29600         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29601         return ret_conv;
29602 }
29603
29604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29605         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29606         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29607         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29608         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29609         CVec_u8Z_free(ret_var);
29610         return ret_arr;
29611 }
29612
29613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29614         LDKu8slice ser_ref;
29615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29617         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29618         *ret_conv = MonitorEvent_read(ser_ref);
29619         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29620         return tag_ptr(ret_conv, true);
29621 }
29622
29623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29624         LDKHTLCUpdate this_obj_conv;
29625         this_obj_conv.inner = untag_ptr(this_obj);
29626         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29628         HTLCUpdate_free(this_obj_conv);
29629 }
29630
29631 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29632         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29633         int64_t ret_ref = 0;
29634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29636         return ret_ref;
29637 }
29638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29639         LDKHTLCUpdate arg_conv;
29640         arg_conv.inner = untag_ptr(arg);
29641         arg_conv.is_owned = ptr_is_owned(arg);
29642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29643         arg_conv.is_owned = false;
29644         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29645         return ret_conv;
29646 }
29647
29648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29649         LDKHTLCUpdate orig_conv;
29650         orig_conv.inner = untag_ptr(orig);
29651         orig_conv.is_owned = ptr_is_owned(orig);
29652         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29653         orig_conv.is_owned = false;
29654         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29655         int64_t ret_ref = 0;
29656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29657         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29658         return ret_ref;
29659 }
29660
29661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29662         LDKHTLCUpdate a_conv;
29663         a_conv.inner = untag_ptr(a);
29664         a_conv.is_owned = ptr_is_owned(a);
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29666         a_conv.is_owned = false;
29667         LDKHTLCUpdate b_conv;
29668         b_conv.inner = untag_ptr(b);
29669         b_conv.is_owned = ptr_is_owned(b);
29670         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29671         b_conv.is_owned = false;
29672         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29673         return ret_conv;
29674 }
29675
29676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29677         LDKHTLCUpdate obj_conv;
29678         obj_conv.inner = untag_ptr(obj);
29679         obj_conv.is_owned = ptr_is_owned(obj);
29680         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29681         obj_conv.is_owned = false;
29682         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29685         CVec_u8Z_free(ret_var);
29686         return ret_arr;
29687 }
29688
29689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29690         LDKu8slice ser_ref;
29691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29693         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29694         *ret_conv = HTLCUpdate_read(ser_ref);
29695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29696         return tag_ptr(ret_conv, true);
29697 }
29698
29699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29700         if (!ptr_is_owned(this_ptr)) return;
29701         void* this_ptr_ptr = untag_ptr(this_ptr);
29702         CHECK_ACCESS(this_ptr_ptr);
29703         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29704         FREE(untag_ptr(this_ptr));
29705         Balance_free(this_ptr_conv);
29706 }
29707
29708 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29709         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29710         *ret_copy = Balance_clone(arg);
29711         int64_t ret_ref = tag_ptr(ret_copy, true);
29712         return ret_ref;
29713 }
29714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29715         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29716         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29717         return ret_conv;
29718 }
29719
29720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29721         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29722         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29723         *ret_copy = Balance_clone(orig_conv);
29724         int64_t ret_ref = tag_ptr(ret_copy, true);
29725         return ret_ref;
29726 }
29727
29728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29729         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29730         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29731         int64_t ret_ref = tag_ptr(ret_copy, true);
29732         return ret_ref;
29733 }
29734
29735 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) {
29736         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29737         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29738         int64_t ret_ref = tag_ptr(ret_copy, true);
29739         return ret_ref;
29740 }
29741
29742 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) {
29743         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29744         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29745         int64_t ret_ref = tag_ptr(ret_copy, true);
29746         return ret_ref;
29747 }
29748
29749 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) {
29750         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29751         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29752         int64_t ret_ref = tag_ptr(ret_copy, true);
29753         return ret_ref;
29754 }
29755
29756 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) {
29757         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29758         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29759         int64_t ret_ref = tag_ptr(ret_copy, true);
29760         return ret_ref;
29761 }
29762
29763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29764         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29765         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29766         int64_t ret_ref = tag_ptr(ret_copy, true);
29767         return ret_ref;
29768 }
29769
29770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29771         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29772         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29773         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29774         return ret_conv;
29775 }
29776
29777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29778         LDKChannelMonitor this_obj_conv;
29779         this_obj_conv.inner = untag_ptr(this_obj);
29780         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29782         ChannelMonitor_free(this_obj_conv);
29783 }
29784
29785 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29786         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29787         int64_t ret_ref = 0;
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29790         return ret_ref;
29791 }
29792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29793         LDKChannelMonitor arg_conv;
29794         arg_conv.inner = untag_ptr(arg);
29795         arg_conv.is_owned = ptr_is_owned(arg);
29796         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29797         arg_conv.is_owned = false;
29798         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29799         return ret_conv;
29800 }
29801
29802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29803         LDKChannelMonitor orig_conv;
29804         orig_conv.inner = untag_ptr(orig);
29805         orig_conv.is_owned = ptr_is_owned(orig);
29806         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29807         orig_conv.is_owned = false;
29808         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29809         int64_t ret_ref = 0;
29810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29812         return ret_ref;
29813 }
29814
29815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29816         LDKChannelMonitor obj_conv;
29817         obj_conv.inner = untag_ptr(obj);
29818         obj_conv.is_owned = ptr_is_owned(obj);
29819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29820         obj_conv.is_owned = false;
29821         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29824         CVec_u8Z_free(ret_var);
29825         return ret_arr;
29826 }
29827
29828 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) {
29829         LDKChannelMonitor this_arg_conv;
29830         this_arg_conv.inner = untag_ptr(this_arg);
29831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29833         this_arg_conv.is_owned = false;
29834         LDKChannelMonitorUpdate updates_conv;
29835         updates_conv.inner = untag_ptr(updates);
29836         updates_conv.is_owned = ptr_is_owned(updates);
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29838         updates_conv.is_owned = false;
29839         void* broadcaster_ptr = untag_ptr(broadcaster);
29840         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29841         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29842         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29843         CHECK_ACCESS(fee_estimator_ptr);
29844         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29845         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29847                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29848         }
29849         void* logger_ptr = untag_ptr(logger);
29850         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29851         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29852         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29853         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29854         return tag_ptr(ret_conv, true);
29855 }
29856
29857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29858         LDKChannelMonitor this_arg_conv;
29859         this_arg_conv.inner = untag_ptr(this_arg);
29860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29862         this_arg_conv.is_owned = false;
29863         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29864         return ret_conv;
29865 }
29866
29867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29868         LDKChannelMonitor this_arg_conv;
29869         this_arg_conv.inner = untag_ptr(this_arg);
29870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29872         this_arg_conv.is_owned = false;
29873         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29874         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29875         return tag_ptr(ret_conv, true);
29876 }
29877
29878 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29879         LDKChannelMonitor this_arg_conv;
29880         this_arg_conv.inner = untag_ptr(this_arg);
29881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29883         this_arg_conv.is_owned = false;
29884         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29885         int64_tArray ret_arr = NULL;
29886         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29887         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29888         for (size_t o = 0; o < ret_var.datalen; o++) {
29889                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29890                 *ret_conv_40_conv = ret_var.data[o];
29891                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29892         }
29893         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29894         FREE(ret_var.data);
29895         return ret_arr;
29896 }
29897
29898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
29899         LDKChannelMonitor this_arg_conv;
29900         this_arg_conv.inner = untag_ptr(this_arg);
29901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29903         this_arg_conv.is_owned = false;
29904         void* filter_ptr = untag_ptr(filter);
29905         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29906         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29907         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29908 }
29909
29910 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(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_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&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 o = 0; o < ret_var.datalen; o++) {
29921                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29922                 *ret_conv_14_copy = ret_var.data[o];
29923                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29924                 ret_arr_ptr[o] = ret_conv_14_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_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29932         LDKChannelMonitor this_arg_conv;
29933         this_arg_conv.inner = untag_ptr(this_arg);
29934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29936         this_arg_conv.is_owned = false;
29937         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29938         int64_tArray ret_arr = NULL;
29939         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29940         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29941         for (size_t h = 0; h < ret_var.datalen; h++) {
29942                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29943                 *ret_conv_7_copy = ret_var.data[h];
29944                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29945                 ret_arr_ptr[h] = ret_conv_7_ref;
29946         }
29947         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29948         FREE(ret_var.data);
29949         return ret_arr;
29950 }
29951
29952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29953         LDKChannelMonitor this_arg_conv;
29954         this_arg_conv.inner = untag_ptr(this_arg);
29955         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29957         this_arg_conv.is_owned = false;
29958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29960         return ret_arr;
29961 }
29962
29963 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) {
29964         LDKChannelMonitor this_arg_conv;
29965         this_arg_conv.inner = untag_ptr(this_arg);
29966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29968         this_arg_conv.is_owned = false;
29969         void* logger_ptr = untag_ptr(logger);
29970         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29971         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29972         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29973         jobjectArray ret_arr = NULL;
29974         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29975         ;
29976         for (size_t i = 0; i < ret_var.datalen; i++) {
29977                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29978                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29979                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29980                 Transaction_free(ret_conv_8_var);
29981                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29982         }
29983         
29984         FREE(ret_var.data);
29985         return ret_arr;
29986 }
29987
29988 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) {
29989         LDKChannelMonitor this_arg_conv;
29990         this_arg_conv.inner = untag_ptr(this_arg);
29991         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29993         this_arg_conv.is_owned = false;
29994         uint8_t header_arr[80];
29995         CHECK((*env)->GetArrayLength(env, header) == 80);
29996         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29997         uint8_t (*header_ref)[80] = &header_arr;
29998         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29999         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30000         if (txdata_constr.datalen > 0)
30001                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30002         else
30003                 txdata_constr.data = NULL;
30004         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30005         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30006                 int64_t txdata_conv_28 = txdata_vals[c];
30007                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30008                 CHECK_ACCESS(txdata_conv_28_ptr);
30009                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30010                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30011                 txdata_constr.data[c] = txdata_conv_28_conv;
30012         }
30013         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30014         void* broadcaster_ptr = untag_ptr(broadcaster);
30015         CHECK_ACCESS(broadcaster_ptr);
30016         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30017         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30019                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30020         }
30021         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30022         CHECK_ACCESS(fee_estimator_ptr);
30023         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30024         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30025                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30026                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30027         }
30028         void* logger_ptr = untag_ptr(logger);
30029         CHECK_ACCESS(logger_ptr);
30030         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30031         if (logger_conv.free == LDKLogger_JCalls_free) {
30032                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30033                 LDKLogger_JCalls_cloned(&logger_conv);
30034         }
30035         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);
30036         int64_tArray ret_arr = NULL;
30037         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30038         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30039         for (size_t n = 0; n < ret_var.datalen; n++) {
30040                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30041                 *ret_conv_39_conv = ret_var.data[n];
30042                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30043         }
30044         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30045         FREE(ret_var.data);
30046         return ret_arr;
30047 }
30048
30049 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) {
30050         LDKChannelMonitor this_arg_conv;
30051         this_arg_conv.inner = untag_ptr(this_arg);
30052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30054         this_arg_conv.is_owned = false;
30055         uint8_t header_arr[80];
30056         CHECK((*env)->GetArrayLength(env, header) == 80);
30057         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30058         uint8_t (*header_ref)[80] = &header_arr;
30059         void* broadcaster_ptr = untag_ptr(broadcaster);
30060         CHECK_ACCESS(broadcaster_ptr);
30061         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30062         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30063                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30064                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30065         }
30066         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30067         CHECK_ACCESS(fee_estimator_ptr);
30068         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30069         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30071                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30072         }
30073         void* logger_ptr = untag_ptr(logger);
30074         CHECK_ACCESS(logger_ptr);
30075         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30076         if (logger_conv.free == LDKLogger_JCalls_free) {
30077                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30078                 LDKLogger_JCalls_cloned(&logger_conv);
30079         }
30080         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30081 }
30082
30083 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) {
30084         LDKChannelMonitor this_arg_conv;
30085         this_arg_conv.inner = untag_ptr(this_arg);
30086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30088         this_arg_conv.is_owned = false;
30089         uint8_t header_arr[80];
30090         CHECK((*env)->GetArrayLength(env, header) == 80);
30091         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30092         uint8_t (*header_ref)[80] = &header_arr;
30093         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30094         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30095         if (txdata_constr.datalen > 0)
30096                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30097         else
30098                 txdata_constr.data = NULL;
30099         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30100         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30101                 int64_t txdata_conv_28 = txdata_vals[c];
30102                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30103                 CHECK_ACCESS(txdata_conv_28_ptr);
30104                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30105                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30106                 txdata_constr.data[c] = txdata_conv_28_conv;
30107         }
30108         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30109         void* broadcaster_ptr = untag_ptr(broadcaster);
30110         CHECK_ACCESS(broadcaster_ptr);
30111         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30112         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30113                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30114                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30115         }
30116         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30117         CHECK_ACCESS(fee_estimator_ptr);
30118         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30119         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30121                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30122         }
30123         void* logger_ptr = untag_ptr(logger);
30124         CHECK_ACCESS(logger_ptr);
30125         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30126         if (logger_conv.free == LDKLogger_JCalls_free) {
30127                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30128                 LDKLogger_JCalls_cloned(&logger_conv);
30129         }
30130         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);
30131         int64_tArray ret_arr = NULL;
30132         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30133         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30134         for (size_t n = 0; n < ret_var.datalen; n++) {
30135                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30136                 *ret_conv_39_conv = ret_var.data[n];
30137                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30138         }
30139         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30140         FREE(ret_var.data);
30141         return ret_arr;
30142 }
30143
30144 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) {
30145         LDKChannelMonitor this_arg_conv;
30146         this_arg_conv.inner = untag_ptr(this_arg);
30147         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30149         this_arg_conv.is_owned = false;
30150         uint8_t txid_arr[32];
30151         CHECK((*env)->GetArrayLength(env, txid) == 32);
30152         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
30153         uint8_t (*txid_ref)[32] = &txid_arr;
30154         void* broadcaster_ptr = untag_ptr(broadcaster);
30155         CHECK_ACCESS(broadcaster_ptr);
30156         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30157         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30159                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30160         }
30161         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30162         CHECK_ACCESS(fee_estimator_ptr);
30163         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30164         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30166                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30167         }
30168         void* logger_ptr = untag_ptr(logger);
30169         CHECK_ACCESS(logger_ptr);
30170         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30171         if (logger_conv.free == LDKLogger_JCalls_free) {
30172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30173                 LDKLogger_JCalls_cloned(&logger_conv);
30174         }
30175         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
30176 }
30177
30178 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) {
30179         LDKChannelMonitor this_arg_conv;
30180         this_arg_conv.inner = untag_ptr(this_arg);
30181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30183         this_arg_conv.is_owned = false;
30184         uint8_t header_arr[80];
30185         CHECK((*env)->GetArrayLength(env, header) == 80);
30186         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30187         uint8_t (*header_ref)[80] = &header_arr;
30188         void* broadcaster_ptr = untag_ptr(broadcaster);
30189         CHECK_ACCESS(broadcaster_ptr);
30190         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30191         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30193                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30194         }
30195         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30196         CHECK_ACCESS(fee_estimator_ptr);
30197         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30198         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30200                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30201         }
30202         void* logger_ptr = untag_ptr(logger);
30203         CHECK_ACCESS(logger_ptr);
30204         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30205         if (logger_conv.free == LDKLogger_JCalls_free) {
30206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30207                 LDKLogger_JCalls_cloned(&logger_conv);
30208         }
30209         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30210         int64_tArray ret_arr = NULL;
30211         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30212         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30213         for (size_t n = 0; n < ret_var.datalen; n++) {
30214                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30215                 *ret_conv_39_conv = ret_var.data[n];
30216                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30217         }
30218         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30219         FREE(ret_var.data);
30220         return ret_arr;
30221 }
30222
30223 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
30224         LDKChannelMonitor this_arg_conv;
30225         this_arg_conv.inner = untag_ptr(this_arg);
30226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30228         this_arg_conv.is_owned = false;
30229         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
30230         int64_tArray ret_arr = NULL;
30231         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30232         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30233         for (size_t z = 0; z < ret_var.datalen; z++) {
30234                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
30235                 *ret_conv_25_conv = ret_var.data[z];
30236                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
30237         }
30238         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30239         FREE(ret_var.data);
30240         return ret_arr;
30241 }
30242
30243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30244         LDKChannelMonitor this_arg_conv;
30245         this_arg_conv.inner = untag_ptr(this_arg);
30246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30248         this_arg_conv.is_owned = false;
30249         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
30250         int64_t ret_ref = 0;
30251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30253         return ret_ref;
30254 }
30255
30256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
30257         LDKChannelMonitor this_arg_conv;
30258         this_arg_conv.inner = untag_ptr(this_arg);
30259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30261         this_arg_conv.is_owned = false;
30262         void* broadcaster_ptr = untag_ptr(broadcaster);
30263         CHECK_ACCESS(broadcaster_ptr);
30264         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30265         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30266                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30267                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30268         }
30269         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30270         CHECK_ACCESS(fee_estimator_ptr);
30271         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30272         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30273                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30274                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30275         }
30276         void* logger_ptr = untag_ptr(logger);
30277         CHECK_ACCESS(logger_ptr);
30278         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30279         if (logger_conv.free == LDKLogger_JCalls_free) {
30280                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30281                 LDKLogger_JCalls_cloned(&logger_conv);
30282         }
30283         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
30284 }
30285
30286 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
30287         LDKChannelMonitor this_arg_conv;
30288         this_arg_conv.inner = untag_ptr(this_arg);
30289         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30291         this_arg_conv.is_owned = false;
30292         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
30293         int64_tArray ret_arr = NULL;
30294         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30295         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30296         for (size_t j = 0; j < ret_var.datalen; j++) {
30297                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
30298                 *ret_conv_9_copy = ret_var.data[j];
30299                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
30300                 ret_arr_ptr[j] = ret_conv_9_ref;
30301         }
30302         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30303         FREE(ret_var.data);
30304         return ret_arr;
30305 }
30306
30307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b) {
30308         LDKu8slice ser_ref;
30309         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30310         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30311         void* arg_a_ptr = untag_ptr(arg_a);
30312         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
30313         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
30314         void* arg_b_ptr = untag_ptr(arg_b);
30315         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
30316         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
30317         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
30318         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
30319         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30320         return tag_ptr(ret_conv, true);
30321 }
30322
30323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30324         LDKOutPoint this_obj_conv;
30325         this_obj_conv.inner = untag_ptr(this_obj);
30326         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30328         OutPoint_free(this_obj_conv);
30329 }
30330
30331 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30332         LDKOutPoint this_ptr_conv;
30333         this_ptr_conv.inner = untag_ptr(this_ptr);
30334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30336         this_ptr_conv.is_owned = false;
30337         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30338         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
30339         return ret_arr;
30340 }
30341
30342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30343         LDKOutPoint this_ptr_conv;
30344         this_ptr_conv.inner = untag_ptr(this_ptr);
30345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30347         this_ptr_conv.is_owned = false;
30348         LDKThirtyTwoBytes val_ref;
30349         CHECK((*env)->GetArrayLength(env, val) == 32);
30350         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30351         OutPoint_set_txid(&this_ptr_conv, val_ref);
30352 }
30353
30354 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30355         LDKOutPoint this_ptr_conv;
30356         this_ptr_conv.inner = untag_ptr(this_ptr);
30357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30359         this_ptr_conv.is_owned = false;
30360         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
30361         return ret_conv;
30362 }
30363
30364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30365         LDKOutPoint this_ptr_conv;
30366         this_ptr_conv.inner = untag_ptr(this_ptr);
30367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30369         this_ptr_conv.is_owned = false;
30370         OutPoint_set_index(&this_ptr_conv, val);
30371 }
30372
30373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
30374         LDKThirtyTwoBytes txid_arg_ref;
30375         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
30376         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30377         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30378         int64_t ret_ref = 0;
30379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30380         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30381         return ret_ref;
30382 }
30383
30384 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30385         LDKOutPoint ret_var = OutPoint_clone(arg);
30386         int64_t ret_ref = 0;
30387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30389         return ret_ref;
30390 }
30391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30392         LDKOutPoint arg_conv;
30393         arg_conv.inner = untag_ptr(arg);
30394         arg_conv.is_owned = ptr_is_owned(arg);
30395         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30396         arg_conv.is_owned = false;
30397         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30398         return ret_conv;
30399 }
30400
30401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30402         LDKOutPoint orig_conv;
30403         orig_conv.inner = untag_ptr(orig);
30404         orig_conv.is_owned = ptr_is_owned(orig);
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30406         orig_conv.is_owned = false;
30407         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30408         int64_t ret_ref = 0;
30409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30410         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30411         return ret_ref;
30412 }
30413
30414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30415         LDKOutPoint a_conv;
30416         a_conv.inner = untag_ptr(a);
30417         a_conv.is_owned = ptr_is_owned(a);
30418         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30419         a_conv.is_owned = false;
30420         LDKOutPoint b_conv;
30421         b_conv.inner = untag_ptr(b);
30422         b_conv.is_owned = ptr_is_owned(b);
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30424         b_conv.is_owned = false;
30425         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30426         return ret_conv;
30427 }
30428
30429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30430         LDKOutPoint o_conv;
30431         o_conv.inner = untag_ptr(o);
30432         o_conv.is_owned = ptr_is_owned(o);
30433         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30434         o_conv.is_owned = false;
30435         int64_t ret_conv = OutPoint_hash(&o_conv);
30436         return ret_conv;
30437 }
30438
30439 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30440         LDKOutPoint this_arg_conv;
30441         this_arg_conv.inner = untag_ptr(this_arg);
30442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30444         this_arg_conv.is_owned = false;
30445         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30447         return ret_arr;
30448 }
30449
30450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30451         LDKOutPoint obj_conv;
30452         obj_conv.inner = untag_ptr(obj);
30453         obj_conv.is_owned = ptr_is_owned(obj);
30454         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30455         obj_conv.is_owned = false;
30456         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30459         CVec_u8Z_free(ret_var);
30460         return ret_arr;
30461 }
30462
30463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30464         LDKu8slice ser_ref;
30465         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30466         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30467         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30468         *ret_conv = OutPoint_read(ser_ref);
30469         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30470         return tag_ptr(ret_conv, true);
30471 }
30472
30473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30474         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30475         this_obj_conv.inner = untag_ptr(this_obj);
30476         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30478         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30479 }
30480
30481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30482         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30483         this_ptr_conv.inner = untag_ptr(this_ptr);
30484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30486         this_ptr_conv.is_owned = false;
30487         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30488         int64_t ret_ref = 0;
30489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30491         return ret_ref;
30492 }
30493
30494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30495         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30496         this_ptr_conv.inner = untag_ptr(this_ptr);
30497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30499         this_ptr_conv.is_owned = false;
30500         LDKOutPoint val_conv;
30501         val_conv.inner = untag_ptr(val);
30502         val_conv.is_owned = ptr_is_owned(val);
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30504         val_conv = OutPoint_clone(&val_conv);
30505         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30506 }
30507
30508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30509         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30510         this_ptr_conv.inner = untag_ptr(this_ptr);
30511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30513         this_ptr_conv.is_owned = false;
30514         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30515         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30516         return ret_arr;
30517 }
30518
30519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30520         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30521         this_ptr_conv.inner = untag_ptr(this_ptr);
30522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30524         this_ptr_conv.is_owned = false;
30525         LDKPublicKey val_ref;
30526         CHECK((*env)->GetArrayLength(env, val) == 33);
30527         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30528         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30529 }
30530
30531 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30532         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30533         this_ptr_conv.inner = untag_ptr(this_ptr);
30534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30536         this_ptr_conv.is_owned = false;
30537         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30538         return ret_conv;
30539 }
30540
30541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30542         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30543         this_ptr_conv.inner = untag_ptr(this_ptr);
30544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30546         this_ptr_conv.is_owned = false;
30547         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30548 }
30549
30550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30551         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30552         this_ptr_conv.inner = untag_ptr(this_ptr);
30553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30555         this_ptr_conv.is_owned = false;
30556         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30557         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30558         return tag_ptr(ret_ref, true);
30559 }
30560
30561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30562         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30563         this_ptr_conv.inner = untag_ptr(this_ptr);
30564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30566         this_ptr_conv.is_owned = false;
30567         void* val_ptr = untag_ptr(val);
30568         CHECK_ACCESS(val_ptr);
30569         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30570         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30571         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30572 }
30573
30574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30575         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30576         this_ptr_conv.inner = untag_ptr(this_ptr);
30577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         this_ptr_conv.is_owned = false;
30580         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30582         return ret_arr;
30583 }
30584
30585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30586         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30587         this_ptr_conv.inner = untag_ptr(this_ptr);
30588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30590         this_ptr_conv.is_owned = false;
30591         LDKPublicKey val_ref;
30592         CHECK((*env)->GetArrayLength(env, val) == 33);
30593         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30594         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30595 }
30596
30597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30598         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30599         this_ptr_conv.inner = untag_ptr(this_ptr);
30600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30602         this_ptr_conv.is_owned = false;
30603         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30604         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30605         return ret_arr;
30606 }
30607
30608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30609         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30610         this_ptr_conv.inner = untag_ptr(this_ptr);
30611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30613         this_ptr_conv.is_owned = false;
30614         LDKThirtyTwoBytes val_ref;
30615         CHECK((*env)->GetArrayLength(env, val) == 32);
30616         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30617         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30618 }
30619
30620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30621         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30622         this_ptr_conv.inner = untag_ptr(this_ptr);
30623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30625         this_ptr_conv.is_owned = false;
30626         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30627         return ret_conv;
30628 }
30629
30630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30631         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30632         this_ptr_conv.inner = untag_ptr(this_ptr);
30633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30635         this_ptr_conv.is_owned = false;
30636         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30637 }
30638
30639 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) {
30640         LDKOutPoint outpoint_arg_conv;
30641         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30642         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30643         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30644         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30645         LDKPublicKey per_commitment_point_arg_ref;
30646         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30647         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30648         void* output_arg_ptr = untag_ptr(output_arg);
30649         CHECK_ACCESS(output_arg_ptr);
30650         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30651         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30652         LDKPublicKey revocation_pubkey_arg_ref;
30653         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30654         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30655         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30656         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30657         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30658         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);
30659         int64_t ret_ref = 0;
30660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30662         return ret_ref;
30663 }
30664
30665 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30666         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30667         int64_t ret_ref = 0;
30668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30670         return ret_ref;
30671 }
30672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30673         LDKDelayedPaymentOutputDescriptor arg_conv;
30674         arg_conv.inner = untag_ptr(arg);
30675         arg_conv.is_owned = ptr_is_owned(arg);
30676         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30677         arg_conv.is_owned = false;
30678         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30679         return ret_conv;
30680 }
30681
30682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30683         LDKDelayedPaymentOutputDescriptor orig_conv;
30684         orig_conv.inner = untag_ptr(orig);
30685         orig_conv.is_owned = ptr_is_owned(orig);
30686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30687         orig_conv.is_owned = false;
30688         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30689         int64_t ret_ref = 0;
30690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30692         return ret_ref;
30693 }
30694
30695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30696         LDKDelayedPaymentOutputDescriptor a_conv;
30697         a_conv.inner = untag_ptr(a);
30698         a_conv.is_owned = ptr_is_owned(a);
30699         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30700         a_conv.is_owned = false;
30701         LDKDelayedPaymentOutputDescriptor b_conv;
30702         b_conv.inner = untag_ptr(b);
30703         b_conv.is_owned = ptr_is_owned(b);
30704         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30705         b_conv.is_owned = false;
30706         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30707         return ret_conv;
30708 }
30709
30710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30711         LDKDelayedPaymentOutputDescriptor obj_conv;
30712         obj_conv.inner = untag_ptr(obj);
30713         obj_conv.is_owned = ptr_is_owned(obj);
30714         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30715         obj_conv.is_owned = false;
30716         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30717         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30718         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30719         CVec_u8Z_free(ret_var);
30720         return ret_arr;
30721 }
30722
30723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30724         LDKu8slice ser_ref;
30725         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30726         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30727         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30728         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30729         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30730         return tag_ptr(ret_conv, true);
30731 }
30732
30733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30734         LDKStaticPaymentOutputDescriptor this_obj_conv;
30735         this_obj_conv.inner = untag_ptr(this_obj);
30736         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30738         StaticPaymentOutputDescriptor_free(this_obj_conv);
30739 }
30740
30741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30742         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30743         this_ptr_conv.inner = untag_ptr(this_ptr);
30744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30746         this_ptr_conv.is_owned = false;
30747         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30748         int64_t ret_ref = 0;
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30751         return ret_ref;
30752 }
30753
30754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30755         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30756         this_ptr_conv.inner = untag_ptr(this_ptr);
30757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30759         this_ptr_conv.is_owned = false;
30760         LDKOutPoint val_conv;
30761         val_conv.inner = untag_ptr(val);
30762         val_conv.is_owned = ptr_is_owned(val);
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30764         val_conv = OutPoint_clone(&val_conv);
30765         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30766 }
30767
30768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30769         LDKStaticPaymentOutputDescriptor 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         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30775         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30776         return tag_ptr(ret_ref, true);
30777 }
30778
30779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30780         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30781         this_ptr_conv.inner = untag_ptr(this_ptr);
30782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30784         this_ptr_conv.is_owned = false;
30785         void* val_ptr = untag_ptr(val);
30786         CHECK_ACCESS(val_ptr);
30787         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30788         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30789         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30790 }
30791
30792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30793         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30794         this_ptr_conv.inner = untag_ptr(this_ptr);
30795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30797         this_ptr_conv.is_owned = false;
30798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30800         return ret_arr;
30801 }
30802
30803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30804         LDKStaticPaymentOutputDescriptor 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         LDKThirtyTwoBytes val_ref;
30810         CHECK((*env)->GetArrayLength(env, val) == 32);
30811         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30812         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30813 }
30814
30815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30816         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30817         this_ptr_conv.inner = untag_ptr(this_ptr);
30818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30820         this_ptr_conv.is_owned = false;
30821         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30822         return ret_conv;
30823 }
30824
30825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30826         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30827         this_ptr_conv.inner = untag_ptr(this_ptr);
30828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30830         this_ptr_conv.is_owned = false;
30831         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30832 }
30833
30834 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) {
30835         LDKOutPoint outpoint_arg_conv;
30836         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30837         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30838         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30839         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30840         void* output_arg_ptr = untag_ptr(output_arg);
30841         CHECK_ACCESS(output_arg_ptr);
30842         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30843         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30844         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30845         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30846         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30847         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30848         int64_t ret_ref = 0;
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30850         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30851         return ret_ref;
30852 }
30853
30854 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30855         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30856         int64_t ret_ref = 0;
30857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30859         return ret_ref;
30860 }
30861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30862         LDKStaticPaymentOutputDescriptor arg_conv;
30863         arg_conv.inner = untag_ptr(arg);
30864         arg_conv.is_owned = ptr_is_owned(arg);
30865         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30866         arg_conv.is_owned = false;
30867         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30868         return ret_conv;
30869 }
30870
30871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30872         LDKStaticPaymentOutputDescriptor orig_conv;
30873         orig_conv.inner = untag_ptr(orig);
30874         orig_conv.is_owned = ptr_is_owned(orig);
30875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30876         orig_conv.is_owned = false;
30877         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30878         int64_t ret_ref = 0;
30879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30880         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30881         return ret_ref;
30882 }
30883
30884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30885         LDKStaticPaymentOutputDescriptor a_conv;
30886         a_conv.inner = untag_ptr(a);
30887         a_conv.is_owned = ptr_is_owned(a);
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30889         a_conv.is_owned = false;
30890         LDKStaticPaymentOutputDescriptor b_conv;
30891         b_conv.inner = untag_ptr(b);
30892         b_conv.is_owned = ptr_is_owned(b);
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30894         b_conv.is_owned = false;
30895         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30896         return ret_conv;
30897 }
30898
30899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30900         LDKStaticPaymentOutputDescriptor obj_conv;
30901         obj_conv.inner = untag_ptr(obj);
30902         obj_conv.is_owned = ptr_is_owned(obj);
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30904         obj_conv.is_owned = false;
30905         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30906         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30907         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30908         CVec_u8Z_free(ret_var);
30909         return ret_arr;
30910 }
30911
30912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30913         LDKu8slice ser_ref;
30914         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30915         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30916         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30917         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30918         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30919         return tag_ptr(ret_conv, true);
30920 }
30921
30922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30923         if (!ptr_is_owned(this_ptr)) return;
30924         void* this_ptr_ptr = untag_ptr(this_ptr);
30925         CHECK_ACCESS(this_ptr_ptr);
30926         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30927         FREE(untag_ptr(this_ptr));
30928         SpendableOutputDescriptor_free(this_ptr_conv);
30929 }
30930
30931 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30932         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30933         *ret_copy = SpendableOutputDescriptor_clone(arg);
30934         int64_t ret_ref = tag_ptr(ret_copy, true);
30935         return ret_ref;
30936 }
30937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30938         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30939         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30940         return ret_conv;
30941 }
30942
30943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30944         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30945         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30946         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30947         int64_t ret_ref = tag_ptr(ret_copy, true);
30948         return ret_ref;
30949 }
30950
30951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30952         LDKOutPoint outpoint_conv;
30953         outpoint_conv.inner = untag_ptr(outpoint);
30954         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30955         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30956         outpoint_conv = OutPoint_clone(&outpoint_conv);
30957         void* output_ptr = untag_ptr(output);
30958         CHECK_ACCESS(output_ptr);
30959         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30960         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30961         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30962         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30963         int64_t ret_ref = tag_ptr(ret_copy, true);
30964         return ret_ref;
30965 }
30966
30967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30968         LDKDelayedPaymentOutputDescriptor a_conv;
30969         a_conv.inner = untag_ptr(a);
30970         a_conv.is_owned = ptr_is_owned(a);
30971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30972         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30973         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30974         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30975         int64_t ret_ref = tag_ptr(ret_copy, true);
30976         return ret_ref;
30977 }
30978
30979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30980         LDKStaticPaymentOutputDescriptor a_conv;
30981         a_conv.inner = untag_ptr(a);
30982         a_conv.is_owned = ptr_is_owned(a);
30983         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30984         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30985         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30986         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30987         int64_t ret_ref = tag_ptr(ret_copy, true);
30988         return ret_ref;
30989 }
30990
30991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30992         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30993         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30994         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30995         return ret_conv;
30996 }
30997
30998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30999         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
31000         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
31001         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31002         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31003         CVec_u8Z_free(ret_var);
31004         return ret_arr;
31005 }
31006
31007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31008         LDKu8slice ser_ref;
31009         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31010         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31011         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
31012         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
31013         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31014         return tag_ptr(ret_conv, true);
31015 }
31016
31017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31018         if (!ptr_is_owned(this_ptr)) return;
31019         void* this_ptr_ptr = untag_ptr(this_ptr);
31020         CHECK_ACCESS(this_ptr_ptr);
31021         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
31022         FREE(untag_ptr(this_ptr));
31023         ChannelSigner_free(this_ptr_conv);
31024 }
31025
31026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31027         if (!ptr_is_owned(this_ptr)) return;
31028         void* this_ptr_ptr = untag_ptr(this_ptr);
31029         CHECK_ACCESS(this_ptr_ptr);
31030         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
31031         FREE(untag_ptr(this_ptr));
31032         EcdsaChannelSigner_free(this_ptr_conv);
31033 }
31034
31035 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
31036         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31037         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
31038         return tag_ptr(ret_ret, true);
31039 }
31040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31041         void* arg_ptr = untag_ptr(arg);
31042         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
31043         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
31044         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
31045         return ret_conv;
31046 }
31047
31048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31049         void* orig_ptr = untag_ptr(orig);
31050         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
31051         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
31052         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31053         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
31054         return tag_ptr(ret_ret, true);
31055 }
31056
31057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31058         if (!ptr_is_owned(this_ptr)) return;
31059         void* this_ptr_ptr = untag_ptr(this_ptr);
31060         CHECK_ACCESS(this_ptr_ptr);
31061         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
31062         FREE(untag_ptr(this_ptr));
31063         WriteableEcdsaChannelSigner_free(this_ptr_conv);
31064 }
31065
31066 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31067         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
31068         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
31069         return ret_conv;
31070 }
31071
31072 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
31073         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
31074         return ret_conv;
31075 }
31076
31077 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
31078         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
31079         return ret_conv;
31080 }
31081
31082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EntropySource_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31083         if (!ptr_is_owned(this_ptr)) return;
31084         void* this_ptr_ptr = untag_ptr(this_ptr);
31085         CHECK_ACCESS(this_ptr_ptr);
31086         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
31087         FREE(untag_ptr(this_ptr));
31088         EntropySource_free(this_ptr_conv);
31089 }
31090
31091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31092         if (!ptr_is_owned(this_ptr)) return;
31093         void* this_ptr_ptr = untag_ptr(this_ptr);
31094         CHECK_ACCESS(this_ptr_ptr);
31095         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
31096         FREE(untag_ptr(this_ptr));
31097         NodeSigner_free(this_ptr_conv);
31098 }
31099
31100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignerProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31101         if (!ptr_is_owned(this_ptr)) return;
31102         void* this_ptr_ptr = untag_ptr(this_ptr);
31103         CHECK_ACCESS(this_ptr_ptr);
31104         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
31105         FREE(untag_ptr(this_ptr));
31106         SignerProvider_free(this_ptr_conv);
31107 }
31108
31109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31110         LDKInMemorySigner this_obj_conv;
31111         this_obj_conv.inner = untag_ptr(this_obj);
31112         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31114         InMemorySigner_free(this_obj_conv);
31115 }
31116
31117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31118         LDKInMemorySigner this_ptr_conv;
31119         this_ptr_conv.inner = untag_ptr(this_ptr);
31120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31122         this_ptr_conv.is_owned = false;
31123         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
31125         return ret_arr;
31126 }
31127
31128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31129         LDKInMemorySigner this_ptr_conv;
31130         this_ptr_conv.inner = untag_ptr(this_ptr);
31131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31133         this_ptr_conv.is_owned = false;
31134         LDKSecretKey val_ref;
31135         CHECK((*env)->GetArrayLength(env, val) == 32);
31136         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31137         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
31138 }
31139
31140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31141         LDKInMemorySigner this_ptr_conv;
31142         this_ptr_conv.inner = untag_ptr(this_ptr);
31143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31145         this_ptr_conv.is_owned = false;
31146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
31148         return ret_arr;
31149 }
31150
31151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31152         LDKInMemorySigner this_ptr_conv;
31153         this_ptr_conv.inner = untag_ptr(this_ptr);
31154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31156         this_ptr_conv.is_owned = false;
31157         LDKSecretKey val_ref;
31158         CHECK((*env)->GetArrayLength(env, val) == 32);
31159         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31160         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
31161 }
31162
31163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31164         LDKInMemorySigner this_ptr_conv;
31165         this_ptr_conv.inner = untag_ptr(this_ptr);
31166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31168         this_ptr_conv.is_owned = false;
31169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
31171         return ret_arr;
31172 }
31173
31174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31175         LDKInMemorySigner this_ptr_conv;
31176         this_ptr_conv.inner = untag_ptr(this_ptr);
31177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31179         this_ptr_conv.is_owned = false;
31180         LDKSecretKey val_ref;
31181         CHECK((*env)->GetArrayLength(env, val) == 32);
31182         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31183         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
31184 }
31185
31186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31187         LDKInMemorySigner this_ptr_conv;
31188         this_ptr_conv.inner = untag_ptr(this_ptr);
31189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31191         this_ptr_conv.is_owned = false;
31192         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
31194         return ret_arr;
31195 }
31196
31197 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) {
31198         LDKInMemorySigner this_ptr_conv;
31199         this_ptr_conv.inner = untag_ptr(this_ptr);
31200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31202         this_ptr_conv.is_owned = false;
31203         LDKSecretKey val_ref;
31204         CHECK((*env)->GetArrayLength(env, val) == 32);
31205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31206         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
31207 }
31208
31209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31210         LDKInMemorySigner this_ptr_conv;
31211         this_ptr_conv.inner = untag_ptr(this_ptr);
31212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31214         this_ptr_conv.is_owned = false;
31215         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
31217         return ret_arr;
31218 }
31219
31220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31221         LDKInMemorySigner this_ptr_conv;
31222         this_ptr_conv.inner = untag_ptr(this_ptr);
31223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31225         this_ptr_conv.is_owned = false;
31226         LDKSecretKey val_ref;
31227         CHECK((*env)->GetArrayLength(env, val) == 32);
31228         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31229         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
31230 }
31231
31232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31233         LDKInMemorySigner this_ptr_conv;
31234         this_ptr_conv.inner = untag_ptr(this_ptr);
31235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31237         this_ptr_conv.is_owned = false;
31238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
31240         return ret_arr;
31241 }
31242
31243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31244         LDKInMemorySigner this_ptr_conv;
31245         this_ptr_conv.inner = untag_ptr(this_ptr);
31246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31248         this_ptr_conv.is_owned = false;
31249         LDKThirtyTwoBytes val_ref;
31250         CHECK((*env)->GetArrayLength(env, val) == 32);
31251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31252         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
31253 }
31254
31255 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
31256         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
31257         int64_t ret_ref = 0;
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31260         return ret_ref;
31261 }
31262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31263         LDKInMemorySigner arg_conv;
31264         arg_conv.inner = untag_ptr(arg);
31265         arg_conv.is_owned = ptr_is_owned(arg);
31266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31267         arg_conv.is_owned = false;
31268         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
31269         return ret_conv;
31270 }
31271
31272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31273         LDKInMemorySigner orig_conv;
31274         orig_conv.inner = untag_ptr(orig);
31275         orig_conv.is_owned = ptr_is_owned(orig);
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31277         orig_conv.is_owned = false;
31278         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
31279         int64_t ret_ref = 0;
31280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31282         return ret_ref;
31283 }
31284
31285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, 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, int8_tArray rand_bytes_unique_start) {
31286         LDKSecretKey funding_key_ref;
31287         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
31288         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
31289         LDKSecretKey revocation_base_key_ref;
31290         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
31291         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
31292         LDKSecretKey payment_key_ref;
31293         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
31294         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
31295         LDKSecretKey delayed_payment_base_key_ref;
31296         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
31297         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
31298         LDKSecretKey htlc_base_key_ref;
31299         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
31300         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
31301         LDKThirtyTwoBytes commitment_seed_ref;
31302         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31303         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
31304         LDKThirtyTwoBytes channel_keys_id_ref;
31305         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
31306         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
31307         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
31308         CHECK((*env)->GetArrayLength(env, rand_bytes_unique_start) == 32);
31309         (*env)->GetByteArrayRegion(env, rand_bytes_unique_start, 0, 32, rand_bytes_unique_start_ref.data);
31310         LDKInMemorySigner ret_var = InMemorySigner_new(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, rand_bytes_unique_start_ref);
31311         int64_t ret_ref = 0;
31312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31314         return ret_ref;
31315 }
31316
31317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
31318         LDKInMemorySigner this_arg_conv;
31319         this_arg_conv.inner = untag_ptr(this_arg);
31320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31322         this_arg_conv.is_owned = false;
31323         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
31324         int64_t ret_ref = 0;
31325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31327         return ret_ref;
31328 }
31329
31330 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31331         LDKInMemorySigner this_arg_conv;
31332         this_arg_conv.inner = untag_ptr(this_arg);
31333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31335         this_arg_conv.is_owned = false;
31336         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
31337         return ret_conv;
31338 }
31339
31340 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31341         LDKInMemorySigner this_arg_conv;
31342         this_arg_conv.inner = untag_ptr(this_arg);
31343         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31345         this_arg_conv.is_owned = false;
31346         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
31347         return ret_conv;
31348 }
31349
31350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
31351         LDKInMemorySigner this_arg_conv;
31352         this_arg_conv.inner = untag_ptr(this_arg);
31353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31355         this_arg_conv.is_owned = false;
31356         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
31357         return ret_conv;
31358 }
31359
31360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
31361         LDKInMemorySigner this_arg_conv;
31362         this_arg_conv.inner = untag_ptr(this_arg);
31363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31365         this_arg_conv.is_owned = false;
31366         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
31367         int64_t ret_ref = 0;
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31370         return ret_ref;
31371 }
31372
31373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
31374         LDKInMemorySigner this_arg_conv;
31375         this_arg_conv.inner = untag_ptr(this_arg);
31376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31378         this_arg_conv.is_owned = false;
31379         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
31380         int64_t ret_ref = 0;
31381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31382         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31383         return ret_ref;
31384 }
31385
31386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
31387         LDKInMemorySigner this_arg_conv;
31388         this_arg_conv.inner = untag_ptr(this_arg);
31389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31391         this_arg_conv.is_owned = false;
31392         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
31393         return ret_conv;
31394 }
31395
31396 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) {
31397         LDKInMemorySigner this_arg_conv;
31398         this_arg_conv.inner = untag_ptr(this_arg);
31399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31401         this_arg_conv.is_owned = false;
31402         LDKTransaction spend_tx_ref;
31403         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31404         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31405         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31406         spend_tx_ref.data_is_owned = true;
31407         LDKStaticPaymentOutputDescriptor descriptor_conv;
31408         descriptor_conv.inner = untag_ptr(descriptor);
31409         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31410         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31411         descriptor_conv.is_owned = false;
31412         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31413         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31414         return tag_ptr(ret_conv, true);
31415 }
31416
31417 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) {
31418         LDKInMemorySigner this_arg_conv;
31419         this_arg_conv.inner = untag_ptr(this_arg);
31420         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31422         this_arg_conv.is_owned = false;
31423         LDKTransaction spend_tx_ref;
31424         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31425         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31426         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31427         spend_tx_ref.data_is_owned = true;
31428         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31429         descriptor_conv.inner = untag_ptr(descriptor);
31430         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31432         descriptor_conv.is_owned = false;
31433         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31434         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31435         return tag_ptr(ret_conv, true);
31436 }
31437
31438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31439         LDKInMemorySigner this_arg_conv;
31440         this_arg_conv.inner = untag_ptr(this_arg);
31441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31443         this_arg_conv.is_owned = false;
31444         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31445         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
31446         return tag_ptr(ret_ret, true);
31447 }
31448
31449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1ChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31450         LDKInMemorySigner this_arg_conv;
31451         this_arg_conv.inner = untag_ptr(this_arg);
31452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31454         this_arg_conv.is_owned = false;
31455         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
31456         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
31457         return tag_ptr(ret_ret, true);
31458 }
31459
31460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31461         LDKInMemorySigner this_arg_conv;
31462         this_arg_conv.inner = untag_ptr(this_arg);
31463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31465         this_arg_conv.is_owned = false;
31466         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
31467         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
31468         return tag_ptr(ret_ret, true);
31469 }
31470
31471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1WriteableEcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31472         LDKInMemorySigner this_arg_conv;
31473         this_arg_conv.inner = untag_ptr(this_arg);
31474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31476         this_arg_conv.is_owned = false;
31477         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31478         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
31479         return tag_ptr(ret_ret, true);
31480 }
31481
31482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31483         LDKInMemorySigner obj_conv;
31484         obj_conv.inner = untag_ptr(obj);
31485         obj_conv.is_owned = ptr_is_owned(obj);
31486         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31487         obj_conv.is_owned = false;
31488         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31491         CVec_u8Z_free(ret_var);
31492         return ret_arr;
31493 }
31494
31495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31496         LDKu8slice ser_ref;
31497         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31498         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31499         void* arg_ptr = untag_ptr(arg);
31500         CHECK_ACCESS(arg_ptr);
31501         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
31502         if (arg_conv.free == LDKEntropySource_JCalls_free) {
31503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31504                 LDKEntropySource_JCalls_cloned(&arg_conv);
31505         }
31506         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31507         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
31508         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31509         return tag_ptr(ret_conv, true);
31510 }
31511
31512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31513         LDKKeysManager this_obj_conv;
31514         this_obj_conv.inner = untag_ptr(this_obj);
31515         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31517         KeysManager_free(this_obj_conv);
31518 }
31519
31520 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) {
31521         uint8_t seed_arr[32];
31522         CHECK((*env)->GetArrayLength(env, seed) == 32);
31523         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31524         uint8_t (*seed_ref)[32] = &seed_arr;
31525         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31526         int64_t ret_ref = 0;
31527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31529         return ret_ref;
31530 }
31531
31532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31533         LDKKeysManager this_arg_conv;
31534         this_arg_conv.inner = untag_ptr(this_arg);
31535         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31537         this_arg_conv.is_owned = false;
31538         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, KeysManager_get_node_secret_key(&this_arg_conv).bytes);
31540         return ret_arr;
31541 }
31542
31543 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) {
31544         LDKKeysManager this_arg_conv;
31545         this_arg_conv.inner = untag_ptr(this_arg);
31546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31548         this_arg_conv.is_owned = false;
31549         uint8_t params_arr[32];
31550         CHECK((*env)->GetArrayLength(env, params) == 32);
31551         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31552         uint8_t (*params_ref)[32] = &params_arr;
31553         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31554         int64_t ret_ref = 0;
31555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31557         return ret_ref;
31558 }
31559
31560 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) {
31561         LDKKeysManager this_arg_conv;
31562         this_arg_conv.inner = untag_ptr(this_arg);
31563         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31565         this_arg_conv.is_owned = false;
31566         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31567         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31568         if (descriptors_constr.datalen > 0)
31569                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31570         else
31571                 descriptors_constr.data = NULL;
31572         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31573         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31574                 int64_t descriptors_conv_27 = descriptors_vals[b];
31575                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31576                 CHECK_ACCESS(descriptors_conv_27_ptr);
31577                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31578                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31579                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31580         }
31581         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31582         LDKCVec_TxOutZ outputs_constr;
31583         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31584         if (outputs_constr.datalen > 0)
31585                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31586         else
31587                 outputs_constr.data = NULL;
31588         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31589         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31590                 int64_t outputs_conv_7 = outputs_vals[h];
31591                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31592                 CHECK_ACCESS(outputs_conv_7_ptr);
31593                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31594                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31595                 outputs_constr.data[h] = outputs_conv_7_conv;
31596         }
31597         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31598         LDKCVec_u8Z change_destination_script_ref;
31599         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31600         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31601         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31602         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31603         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31604         return tag_ptr(ret_conv, true);
31605 }
31606
31607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31608         LDKKeysManager this_arg_conv;
31609         this_arg_conv.inner = untag_ptr(this_arg);
31610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31612         this_arg_conv.is_owned = false;
31613         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31614         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
31615         return tag_ptr(ret_ret, true);
31616 }
31617
31618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31619         LDKKeysManager this_arg_conv;
31620         this_arg_conv.inner = untag_ptr(this_arg);
31621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31623         this_arg_conv.is_owned = false;
31624         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31625         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
31626         return tag_ptr(ret_ret, true);
31627 }
31628
31629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31630         LDKKeysManager this_arg_conv;
31631         this_arg_conv.inner = untag_ptr(this_arg);
31632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31634         this_arg_conv.is_owned = false;
31635         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31636         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
31637         return tag_ptr(ret_ret, true);
31638 }
31639
31640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31641         LDKPhantomKeysManager this_obj_conv;
31642         this_obj_conv.inner = untag_ptr(this_obj);
31643         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31645         PhantomKeysManager_free(this_obj_conv);
31646 }
31647
31648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31649         LDKPhantomKeysManager this_arg_conv;
31650         this_arg_conv.inner = untag_ptr(this_arg);
31651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31653         this_arg_conv.is_owned = false;
31654         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31655         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
31656         return tag_ptr(ret_ret, true);
31657 }
31658
31659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31660         LDKPhantomKeysManager this_arg_conv;
31661         this_arg_conv.inner = untag_ptr(this_arg);
31662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31664         this_arg_conv.is_owned = false;
31665         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31666         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
31667         return tag_ptr(ret_ret, true);
31668 }
31669
31670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31671         LDKPhantomKeysManager this_arg_conv;
31672         this_arg_conv.inner = untag_ptr(this_arg);
31673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31675         this_arg_conv.is_owned = false;
31676         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31677         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
31678         return tag_ptr(ret_ret, true);
31679 }
31680
31681 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) {
31682         uint8_t seed_arr[32];
31683         CHECK((*env)->GetArrayLength(env, seed) == 32);
31684         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31685         uint8_t (*seed_ref)[32] = &seed_arr;
31686         uint8_t cross_node_seed_arr[32];
31687         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31688         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31689         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31690         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
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 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) {
31698         LDKPhantomKeysManager this_arg_conv;
31699         this_arg_conv.inner = untag_ptr(this_arg);
31700         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31702         this_arg_conv.is_owned = false;
31703         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31704         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31705         if (descriptors_constr.datalen > 0)
31706                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31707         else
31708                 descriptors_constr.data = NULL;
31709         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31710         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31711                 int64_t descriptors_conv_27 = descriptors_vals[b];
31712                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31713                 CHECK_ACCESS(descriptors_conv_27_ptr);
31714                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31715                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31716                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31717         }
31718         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31719         LDKCVec_TxOutZ outputs_constr;
31720         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31721         if (outputs_constr.datalen > 0)
31722                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31723         else
31724                 outputs_constr.data = NULL;
31725         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31726         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31727                 int64_t outputs_conv_7 = outputs_vals[h];
31728                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31729                 CHECK_ACCESS(outputs_conv_7_ptr);
31730                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31731                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31732                 outputs_constr.data[h] = outputs_conv_7_conv;
31733         }
31734         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31735         LDKCVec_u8Z change_destination_script_ref;
31736         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31737         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31738         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31739         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31740         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31741         return tag_ptr(ret_conv, true);
31742 }
31743
31744 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) {
31745         LDKPhantomKeysManager this_arg_conv;
31746         this_arg_conv.inner = untag_ptr(this_arg);
31747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31749         this_arg_conv.is_owned = false;
31750         uint8_t params_arr[32];
31751         CHECK((*env)->GetArrayLength(env, params) == 32);
31752         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31753         uint8_t (*params_ref)[32] = &params_arr;
31754         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31755         int64_t ret_ref = 0;
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31758         return ret_ref;
31759 }
31760
31761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31762         LDKPhantomKeysManager this_arg_conv;
31763         this_arg_conv.inner = untag_ptr(this_arg);
31764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31766         this_arg_conv.is_owned = false;
31767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes);
31769         return ret_arr;
31770 }
31771
31772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1phantom_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31773         LDKPhantomKeysManager this_arg_conv;
31774         this_arg_conv.inner = untag_ptr(this_arg);
31775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31777         this_arg_conv.is_owned = false;
31778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes);
31780         return ret_arr;
31781 }
31782
31783 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31784         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
31785         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_clone(orig_conv));
31786         return ret_conv;
31787 }
31788
31789 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1temporary_1node_1failure(JNIEnv *env, jclass clz) {
31790         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_temporary_node_failure());
31791         return ret_conv;
31792 }
31793
31794 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1required_1node_1feature_1missing(JNIEnv *env, jclass clz) {
31795         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_required_node_feature_missing());
31796         return ret_conv;
31797 }
31798
31799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1incorrect_1or_1unknown_1payment_1details(JNIEnv *env, jclass clz) {
31800         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_incorrect_or_unknown_payment_details());
31801         return ret_conv;
31802 }
31803
31804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31805         LDKChannelManager this_obj_conv;
31806         this_obj_conv.inner = untag_ptr(this_obj);
31807         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31809         ChannelManager_free(this_obj_conv);
31810 }
31811
31812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31813         LDKChainParameters this_obj_conv;
31814         this_obj_conv.inner = untag_ptr(this_obj);
31815         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31817         ChainParameters_free(this_obj_conv);
31818 }
31819
31820 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31821         LDKChainParameters this_ptr_conv;
31822         this_ptr_conv.inner = untag_ptr(this_ptr);
31823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31825         this_ptr_conv.is_owned = false;
31826         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31827         return ret_conv;
31828 }
31829
31830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31831         LDKChainParameters this_ptr_conv;
31832         this_ptr_conv.inner = untag_ptr(this_ptr);
31833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31835         this_ptr_conv.is_owned = false;
31836         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31837         ChainParameters_set_network(&this_ptr_conv, val_conv);
31838 }
31839
31840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
31841         LDKChainParameters this_ptr_conv;
31842         this_ptr_conv.inner = untag_ptr(this_ptr);
31843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31845         this_ptr_conv.is_owned = false;
31846         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31847         int64_t ret_ref = 0;
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31850         return ret_ref;
31851 }
31852
31853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31854         LDKChainParameters this_ptr_conv;
31855         this_ptr_conv.inner = untag_ptr(this_ptr);
31856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31858         this_ptr_conv.is_owned = false;
31859         LDKBestBlock val_conv;
31860         val_conv.inner = untag_ptr(val);
31861         val_conv.is_owned = ptr_is_owned(val);
31862         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31863         val_conv = BestBlock_clone(&val_conv);
31864         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31865 }
31866
31867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31868         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31869         LDKBestBlock best_block_arg_conv;
31870         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31871         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31873         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31874         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31875         int64_t ret_ref = 0;
31876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31878         return ret_ref;
31879 }
31880
31881 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31882         LDKChainParameters ret_var = ChainParameters_clone(arg);
31883         int64_t ret_ref = 0;
31884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31886         return ret_ref;
31887 }
31888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31889         LDKChainParameters arg_conv;
31890         arg_conv.inner = untag_ptr(arg);
31891         arg_conv.is_owned = ptr_is_owned(arg);
31892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31893         arg_conv.is_owned = false;
31894         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31895         return ret_conv;
31896 }
31897
31898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31899         LDKChainParameters orig_conv;
31900         orig_conv.inner = untag_ptr(orig);
31901         orig_conv.is_owned = ptr_is_owned(orig);
31902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31903         orig_conv.is_owned = false;
31904         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31905         int64_t ret_ref = 0;
31906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31908         return ret_ref;
31909 }
31910
31911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31912         LDKCounterpartyForwardingInfo this_obj_conv;
31913         this_obj_conv.inner = untag_ptr(this_obj);
31914         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31916         CounterpartyForwardingInfo_free(this_obj_conv);
31917 }
31918
31919 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31920         LDKCounterpartyForwardingInfo this_ptr_conv;
31921         this_ptr_conv.inner = untag_ptr(this_ptr);
31922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31924         this_ptr_conv.is_owned = false;
31925         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31926         return ret_conv;
31927 }
31928
31929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31930         LDKCounterpartyForwardingInfo this_ptr_conv;
31931         this_ptr_conv.inner = untag_ptr(this_ptr);
31932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31934         this_ptr_conv.is_owned = false;
31935         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31936 }
31937
31938 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31939         LDKCounterpartyForwardingInfo this_ptr_conv;
31940         this_ptr_conv.inner = untag_ptr(this_ptr);
31941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31943         this_ptr_conv.is_owned = false;
31944         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31945         return ret_conv;
31946 }
31947
31948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31949         LDKCounterpartyForwardingInfo this_ptr_conv;
31950         this_ptr_conv.inner = untag_ptr(this_ptr);
31951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31953         this_ptr_conv.is_owned = false;
31954         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31955 }
31956
31957 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31958         LDKCounterpartyForwardingInfo this_ptr_conv;
31959         this_ptr_conv.inner = untag_ptr(this_ptr);
31960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31962         this_ptr_conv.is_owned = false;
31963         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31964         return ret_conv;
31965 }
31966
31967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31968         LDKCounterpartyForwardingInfo this_ptr_conv;
31969         this_ptr_conv.inner = untag_ptr(this_ptr);
31970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31972         this_ptr_conv.is_owned = false;
31973         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31974 }
31975
31976 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) {
31977         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31978         int64_t ret_ref = 0;
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31981         return ret_ref;
31982 }
31983
31984 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31985         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31986         int64_t ret_ref = 0;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31989         return ret_ref;
31990 }
31991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31992         LDKCounterpartyForwardingInfo arg_conv;
31993         arg_conv.inner = untag_ptr(arg);
31994         arg_conv.is_owned = ptr_is_owned(arg);
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31996         arg_conv.is_owned = false;
31997         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31998         return ret_conv;
31999 }
32000
32001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32002         LDKCounterpartyForwardingInfo orig_conv;
32003         orig_conv.inner = untag_ptr(orig);
32004         orig_conv.is_owned = ptr_is_owned(orig);
32005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32006         orig_conv.is_owned = false;
32007         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
32008         int64_t ret_ref = 0;
32009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32011         return ret_ref;
32012 }
32013
32014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32015         LDKChannelCounterparty this_obj_conv;
32016         this_obj_conv.inner = untag_ptr(this_obj);
32017         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32019         ChannelCounterparty_free(this_obj_conv);
32020 }
32021
32022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32023         LDKChannelCounterparty this_ptr_conv;
32024         this_ptr_conv.inner = untag_ptr(this_ptr);
32025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32027         this_ptr_conv.is_owned = false;
32028         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32029         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
32030         return ret_arr;
32031 }
32032
32033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32034         LDKChannelCounterparty this_ptr_conv;
32035         this_ptr_conv.inner = untag_ptr(this_ptr);
32036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32038         this_ptr_conv.is_owned = false;
32039         LDKPublicKey val_ref;
32040         CHECK((*env)->GetArrayLength(env, val) == 33);
32041         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32042         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
32043 }
32044
32045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32046         LDKChannelCounterparty this_ptr_conv;
32047         this_ptr_conv.inner = untag_ptr(this_ptr);
32048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32050         this_ptr_conv.is_owned = false;
32051         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
32052         int64_t ret_ref = 0;
32053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32055         return ret_ref;
32056 }
32057
32058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32059         LDKChannelCounterparty this_ptr_conv;
32060         this_ptr_conv.inner = untag_ptr(this_ptr);
32061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32063         this_ptr_conv.is_owned = false;
32064         LDKInitFeatures val_conv;
32065         val_conv.inner = untag_ptr(val);
32066         val_conv.is_owned = ptr_is_owned(val);
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32068         val_conv = InitFeatures_clone(&val_conv);
32069         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
32070 }
32071
32072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32073         LDKChannelCounterparty this_ptr_conv;
32074         this_ptr_conv.inner = untag_ptr(this_ptr);
32075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32077         this_ptr_conv.is_owned = false;
32078         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
32079         return ret_conv;
32080 }
32081
32082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32083         LDKChannelCounterparty this_ptr_conv;
32084         this_ptr_conv.inner = untag_ptr(this_ptr);
32085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         this_ptr_conv.is_owned = false;
32088         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
32089 }
32090
32091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
32092         LDKChannelCounterparty this_ptr_conv;
32093         this_ptr_conv.inner = untag_ptr(this_ptr);
32094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32096         this_ptr_conv.is_owned = false;
32097         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
32098         int64_t ret_ref = 0;
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32101         return ret_ref;
32102 }
32103
32104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32105         LDKChannelCounterparty this_ptr_conv;
32106         this_ptr_conv.inner = untag_ptr(this_ptr);
32107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32109         this_ptr_conv.is_owned = false;
32110         LDKCounterpartyForwardingInfo val_conv;
32111         val_conv.inner = untag_ptr(val);
32112         val_conv.is_owned = ptr_is_owned(val);
32113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32114         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
32115         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
32116 }
32117
32118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32119         LDKChannelCounterparty this_ptr_conv;
32120         this_ptr_conv.inner = untag_ptr(this_ptr);
32121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32123         this_ptr_conv.is_owned = false;
32124         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32125         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
32126         int64_t ret_ref = tag_ptr(ret_copy, true);
32127         return ret_ref;
32128 }
32129
32130 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) {
32131         LDKChannelCounterparty this_ptr_conv;
32132         this_ptr_conv.inner = untag_ptr(this_ptr);
32133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32135         this_ptr_conv.is_owned = false;
32136         void* val_ptr = untag_ptr(val);
32137         CHECK_ACCESS(val_ptr);
32138         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32139         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32140         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32141 }
32142
32143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32144         LDKChannelCounterparty this_ptr_conv;
32145         this_ptr_conv.inner = untag_ptr(this_ptr);
32146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32148         this_ptr_conv.is_owned = false;
32149         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32150         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
32151         int64_t ret_ref = tag_ptr(ret_copy, true);
32152         return ret_ref;
32153 }
32154
32155 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) {
32156         LDKChannelCounterparty this_ptr_conv;
32157         this_ptr_conv.inner = untag_ptr(this_ptr);
32158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32160         this_ptr_conv.is_owned = false;
32161         void* val_ptr = untag_ptr(val);
32162         CHECK_ACCESS(val_ptr);
32163         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32164         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32165         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32166 }
32167
32168 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) {
32169         LDKPublicKey node_id_arg_ref;
32170         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
32171         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
32172         LDKInitFeatures features_arg_conv;
32173         features_arg_conv.inner = untag_ptr(features_arg);
32174         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32175         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32176         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32177         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
32178         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
32179         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
32181         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
32182         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
32183         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
32184         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
32185         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
32186         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
32187         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
32188         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
32189         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
32190         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);
32191         int64_t ret_ref = 0;
32192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32194         return ret_ref;
32195 }
32196
32197 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
32198         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
32199         int64_t ret_ref = 0;
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32202         return ret_ref;
32203 }
32204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32205         LDKChannelCounterparty arg_conv;
32206         arg_conv.inner = untag_ptr(arg);
32207         arg_conv.is_owned = ptr_is_owned(arg);
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32209         arg_conv.is_owned = false;
32210         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
32211         return ret_conv;
32212 }
32213
32214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32215         LDKChannelCounterparty orig_conv;
32216         orig_conv.inner = untag_ptr(orig);
32217         orig_conv.is_owned = ptr_is_owned(orig);
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32219         orig_conv.is_owned = false;
32220         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
32221         int64_t ret_ref = 0;
32222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32224         return ret_ref;
32225 }
32226
32227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32228         LDKChannelDetails this_obj_conv;
32229         this_obj_conv.inner = untag_ptr(this_obj);
32230         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32232         ChannelDetails_free(this_obj_conv);
32233 }
32234
32235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32236         LDKChannelDetails this_ptr_conv;
32237         this_ptr_conv.inner = untag_ptr(this_ptr);
32238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32240         this_ptr_conv.is_owned = false;
32241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
32243         return ret_arr;
32244 }
32245
32246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32247         LDKChannelDetails this_ptr_conv;
32248         this_ptr_conv.inner = untag_ptr(this_ptr);
32249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32251         this_ptr_conv.is_owned = false;
32252         LDKThirtyTwoBytes val_ref;
32253         CHECK((*env)->GetArrayLength(env, val) == 32);
32254         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32255         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
32256 }
32257
32258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
32259         LDKChannelDetails this_ptr_conv;
32260         this_ptr_conv.inner = untag_ptr(this_ptr);
32261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32263         this_ptr_conv.is_owned = false;
32264         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
32265         int64_t ret_ref = 0;
32266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32268         return ret_ref;
32269 }
32270
32271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32272         LDKChannelDetails this_ptr_conv;
32273         this_ptr_conv.inner = untag_ptr(this_ptr);
32274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32276         this_ptr_conv.is_owned = false;
32277         LDKChannelCounterparty val_conv;
32278         val_conv.inner = untag_ptr(val);
32279         val_conv.is_owned = ptr_is_owned(val);
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32281         val_conv = ChannelCounterparty_clone(&val_conv);
32282         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
32283 }
32284
32285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
32286         LDKChannelDetails this_ptr_conv;
32287         this_ptr_conv.inner = untag_ptr(this_ptr);
32288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32290         this_ptr_conv.is_owned = false;
32291         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
32292         int64_t ret_ref = 0;
32293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32295         return ret_ref;
32296 }
32297
32298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32299         LDKChannelDetails this_ptr_conv;
32300         this_ptr_conv.inner = untag_ptr(this_ptr);
32301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32303         this_ptr_conv.is_owned = false;
32304         LDKOutPoint val_conv;
32305         val_conv.inner = untag_ptr(val);
32306         val_conv.is_owned = ptr_is_owned(val);
32307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32308         val_conv = OutPoint_clone(&val_conv);
32309         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
32310 }
32311
32312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32313         LDKChannelDetails this_ptr_conv;
32314         this_ptr_conv.inner = untag_ptr(this_ptr);
32315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32317         this_ptr_conv.is_owned = false;
32318         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
32319         int64_t ret_ref = 0;
32320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32322         return ret_ref;
32323 }
32324
32325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32326         LDKChannelDetails this_ptr_conv;
32327         this_ptr_conv.inner = untag_ptr(this_ptr);
32328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32330         this_ptr_conv.is_owned = false;
32331         LDKChannelTypeFeatures val_conv;
32332         val_conv.inner = untag_ptr(val);
32333         val_conv.is_owned = ptr_is_owned(val);
32334         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32335         val_conv = ChannelTypeFeatures_clone(&val_conv);
32336         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
32337 }
32338
32339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32340         LDKChannelDetails this_ptr_conv;
32341         this_ptr_conv.inner = untag_ptr(this_ptr);
32342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32344         this_ptr_conv.is_owned = false;
32345         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32346         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
32347         int64_t ret_ref = tag_ptr(ret_copy, true);
32348         return ret_ref;
32349 }
32350
32351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32352         LDKChannelDetails this_ptr_conv;
32353         this_ptr_conv.inner = untag_ptr(this_ptr);
32354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32356         this_ptr_conv.is_owned = false;
32357         void* val_ptr = untag_ptr(val);
32358         CHECK_ACCESS(val_ptr);
32359         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32360         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32361         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
32362 }
32363
32364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32365         LDKChannelDetails this_ptr_conv;
32366         this_ptr_conv.inner = untag_ptr(this_ptr);
32367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32369         this_ptr_conv.is_owned = false;
32370         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32371         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
32372         int64_t ret_ref = tag_ptr(ret_copy, true);
32373         return ret_ref;
32374 }
32375
32376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32377         LDKChannelDetails this_ptr_conv;
32378         this_ptr_conv.inner = untag_ptr(this_ptr);
32379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32381         this_ptr_conv.is_owned = false;
32382         void* val_ptr = untag_ptr(val);
32383         CHECK_ACCESS(val_ptr);
32384         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32385         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32386         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
32387 }
32388
32389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32390         LDKChannelDetails this_ptr_conv;
32391         this_ptr_conv.inner = untag_ptr(this_ptr);
32392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32394         this_ptr_conv.is_owned = false;
32395         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32396         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
32397         int64_t ret_ref = tag_ptr(ret_copy, true);
32398         return ret_ref;
32399 }
32400
32401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32402         LDKChannelDetails this_ptr_conv;
32403         this_ptr_conv.inner = untag_ptr(this_ptr);
32404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32406         this_ptr_conv.is_owned = false;
32407         void* val_ptr = untag_ptr(val);
32408         CHECK_ACCESS(val_ptr);
32409         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32410         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32411         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
32412 }
32413
32414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32415         LDKChannelDetails this_ptr_conv;
32416         this_ptr_conv.inner = untag_ptr(this_ptr);
32417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32419         this_ptr_conv.is_owned = false;
32420         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
32421         return ret_conv;
32422 }
32423
32424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32425         LDKChannelDetails this_ptr_conv;
32426         this_ptr_conv.inner = untag_ptr(this_ptr);
32427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32429         this_ptr_conv.is_owned = false;
32430         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
32431 }
32432
32433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32434         LDKChannelDetails this_ptr_conv;
32435         this_ptr_conv.inner = untag_ptr(this_ptr);
32436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32438         this_ptr_conv.is_owned = false;
32439         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32440         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
32441         int64_t ret_ref = tag_ptr(ret_copy, true);
32442         return ret_ref;
32443 }
32444
32445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32446         LDKChannelDetails this_ptr_conv;
32447         this_ptr_conv.inner = untag_ptr(this_ptr);
32448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32450         this_ptr_conv.is_owned = false;
32451         void* val_ptr = untag_ptr(val);
32452         CHECK_ACCESS(val_ptr);
32453         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32454         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32455         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
32456 }
32457
32458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32459         LDKChannelDetails this_ptr_conv;
32460         this_ptr_conv.inner = untag_ptr(this_ptr);
32461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32463         this_ptr_conv.is_owned = false;
32464         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
32465         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
32466         return ret_arr;
32467 }
32468
32469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32470         LDKChannelDetails this_ptr_conv;
32471         this_ptr_conv.inner = untag_ptr(this_ptr);
32472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32474         this_ptr_conv.is_owned = false;
32475         LDKU128 val_ref;
32476         CHECK((*env)->GetArrayLength(env, val) == 16);
32477         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
32478         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
32479 }
32480
32481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr) {
32482         LDKChannelDetails this_ptr_conv;
32483         this_ptr_conv.inner = untag_ptr(this_ptr);
32484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32486         this_ptr_conv.is_owned = false;
32487         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32488         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
32489         int64_t ret_ref = tag_ptr(ret_copy, true);
32490         return ret_ref;
32491 }
32492
32493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32494         LDKChannelDetails this_ptr_conv;
32495         this_ptr_conv.inner = untag_ptr(this_ptr);
32496         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32498         this_ptr_conv.is_owned = false;
32499         void* val_ptr = untag_ptr(val);
32500         CHECK_ACCESS(val_ptr);
32501         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32502         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32503         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
32504 }
32505
32506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32507         LDKChannelDetails this_ptr_conv;
32508         this_ptr_conv.inner = untag_ptr(this_ptr);
32509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32511         this_ptr_conv.is_owned = false;
32512         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
32513         return ret_conv;
32514 }
32515
32516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32517         LDKChannelDetails this_ptr_conv;
32518         this_ptr_conv.inner = untag_ptr(this_ptr);
32519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32521         this_ptr_conv.is_owned = false;
32522         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
32523 }
32524
32525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32526         LDKChannelDetails this_ptr_conv;
32527         this_ptr_conv.inner = untag_ptr(this_ptr);
32528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32530         this_ptr_conv.is_owned = false;
32531         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
32532         return ret_conv;
32533 }
32534
32535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32536         LDKChannelDetails this_ptr_conv;
32537         this_ptr_conv.inner = untag_ptr(this_ptr);
32538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32540         this_ptr_conv.is_owned = false;
32541         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
32542 }
32543
32544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32545         LDKChannelDetails this_ptr_conv;
32546         this_ptr_conv.inner = untag_ptr(this_ptr);
32547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32549         this_ptr_conv.is_owned = false;
32550         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
32551         return ret_conv;
32552 }
32553
32554 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) {
32555         LDKChannelDetails this_ptr_conv;
32556         this_ptr_conv.inner = untag_ptr(this_ptr);
32557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32559         this_ptr_conv.is_owned = false;
32560         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32561 }
32562
32563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32564         LDKChannelDetails this_ptr_conv;
32565         this_ptr_conv.inner = untag_ptr(this_ptr);
32566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         this_ptr_conv.is_owned = false;
32569         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32570         return ret_conv;
32571 }
32572
32573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32574         LDKChannelDetails this_ptr_conv;
32575         this_ptr_conv.inner = untag_ptr(this_ptr);
32576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32578         this_ptr_conv.is_owned = false;
32579         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32580 }
32581
32582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32583         LDKChannelDetails this_ptr_conv;
32584         this_ptr_conv.inner = untag_ptr(this_ptr);
32585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32587         this_ptr_conv.is_owned = false;
32588         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32589         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32590         int64_t ret_ref = tag_ptr(ret_copy, true);
32591         return ret_ref;
32592 }
32593
32594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32595         LDKChannelDetails this_ptr_conv;
32596         this_ptr_conv.inner = untag_ptr(this_ptr);
32597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32599         this_ptr_conv.is_owned = false;
32600         void* val_ptr = untag_ptr(val);
32601         CHECK_ACCESS(val_ptr);
32602         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32603         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32604         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32605 }
32606
32607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32608         LDKChannelDetails this_ptr_conv;
32609         this_ptr_conv.inner = untag_ptr(this_ptr);
32610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32612         this_ptr_conv.is_owned = false;
32613         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32614         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32615         int64_t ret_ref = tag_ptr(ret_copy, true);
32616         return ret_ref;
32617 }
32618
32619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32620         LDKChannelDetails this_ptr_conv;
32621         this_ptr_conv.inner = untag_ptr(this_ptr);
32622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32624         this_ptr_conv.is_owned = false;
32625         void* val_ptr = untag_ptr(val);
32626         CHECK_ACCESS(val_ptr);
32627         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32628         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32629         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32630 }
32631
32632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32633         LDKChannelDetails this_ptr_conv;
32634         this_ptr_conv.inner = untag_ptr(this_ptr);
32635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32637         this_ptr_conv.is_owned = false;
32638         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32639         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32640         int64_t ret_ref = tag_ptr(ret_copy, true);
32641         return ret_ref;
32642 }
32643
32644 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) {
32645         LDKChannelDetails this_ptr_conv;
32646         this_ptr_conv.inner = untag_ptr(this_ptr);
32647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32649         this_ptr_conv.is_owned = false;
32650         void* val_ptr = untag_ptr(val);
32651         CHECK_ACCESS(val_ptr);
32652         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32653         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32654         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32655 }
32656
32657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32658         LDKChannelDetails this_ptr_conv;
32659         this_ptr_conv.inner = untag_ptr(this_ptr);
32660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32662         this_ptr_conv.is_owned = false;
32663         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32664         return ret_conv;
32665 }
32666
32667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32668         LDKChannelDetails this_ptr_conv;
32669         this_ptr_conv.inner = untag_ptr(this_ptr);
32670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32672         this_ptr_conv.is_owned = false;
32673         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32674 }
32675
32676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32677         LDKChannelDetails this_ptr_conv;
32678         this_ptr_conv.inner = untag_ptr(this_ptr);
32679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32681         this_ptr_conv.is_owned = false;
32682         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32683         return ret_conv;
32684 }
32685
32686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32687         LDKChannelDetails this_ptr_conv;
32688         this_ptr_conv.inner = untag_ptr(this_ptr);
32689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32691         this_ptr_conv.is_owned = false;
32692         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32693 }
32694
32695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32696         LDKChannelDetails this_ptr_conv;
32697         this_ptr_conv.inner = untag_ptr(this_ptr);
32698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32700         this_ptr_conv.is_owned = false;
32701         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32702         return ret_conv;
32703 }
32704
32705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32706         LDKChannelDetails this_ptr_conv;
32707         this_ptr_conv.inner = untag_ptr(this_ptr);
32708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32710         this_ptr_conv.is_owned = false;
32711         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32712 }
32713
32714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32715         LDKChannelDetails this_ptr_conv;
32716         this_ptr_conv.inner = untag_ptr(this_ptr);
32717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32719         this_ptr_conv.is_owned = false;
32720         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32721         return ret_conv;
32722 }
32723
32724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32725         LDKChannelDetails this_ptr_conv;
32726         this_ptr_conv.inner = untag_ptr(this_ptr);
32727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32729         this_ptr_conv.is_owned = false;
32730         ChannelDetails_set_is_public(&this_ptr_conv, val);
32731 }
32732
32733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32734         LDKChannelDetails this_ptr_conv;
32735         this_ptr_conv.inner = untag_ptr(this_ptr);
32736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32738         this_ptr_conv.is_owned = false;
32739         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32740         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32741         int64_t ret_ref = tag_ptr(ret_copy, true);
32742         return ret_ref;
32743 }
32744
32745 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) {
32746         LDKChannelDetails this_ptr_conv;
32747         this_ptr_conv.inner = untag_ptr(this_ptr);
32748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32750         this_ptr_conv.is_owned = false;
32751         void* val_ptr = untag_ptr(val);
32752         CHECK_ACCESS(val_ptr);
32753         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32754         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32755         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32756 }
32757
32758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32759         LDKChannelDetails this_ptr_conv;
32760         this_ptr_conv.inner = untag_ptr(this_ptr);
32761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32763         this_ptr_conv.is_owned = false;
32764         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32765         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32766         int64_t ret_ref = tag_ptr(ret_copy, true);
32767         return ret_ref;
32768 }
32769
32770 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) {
32771         LDKChannelDetails this_ptr_conv;
32772         this_ptr_conv.inner = untag_ptr(this_ptr);
32773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32775         this_ptr_conv.is_owned = false;
32776         void* val_ptr = untag_ptr(val);
32777         CHECK_ACCESS(val_ptr);
32778         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32779         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32780         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32781 }
32782
32783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32784         LDKChannelDetails this_ptr_conv;
32785         this_ptr_conv.inner = untag_ptr(this_ptr);
32786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32788         this_ptr_conv.is_owned = false;
32789         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32790         int64_t ret_ref = 0;
32791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32793         return ret_ref;
32794 }
32795
32796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32797         LDKChannelDetails this_ptr_conv;
32798         this_ptr_conv.inner = untag_ptr(this_ptr);
32799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32801         this_ptr_conv.is_owned = false;
32802         LDKChannelConfig val_conv;
32803         val_conv.inner = untag_ptr(val);
32804         val_conv.is_owned = ptr_is_owned(val);
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32806         val_conv = ChannelConfig_clone(&val_conv);
32807         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32808 }
32809
32810 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 feerate_sat_per_1000_weight_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) {
32811         LDKThirtyTwoBytes channel_id_arg_ref;
32812         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32813         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32814         LDKChannelCounterparty counterparty_arg_conv;
32815         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32816         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32817         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32818         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32819         LDKOutPoint funding_txo_arg_conv;
32820         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32821         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32822         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32823         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32824         LDKChannelTypeFeatures channel_type_arg_conv;
32825         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32826         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32827         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32828         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32829         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32830         CHECK_ACCESS(short_channel_id_arg_ptr);
32831         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32832         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32833         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32834         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32835         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32836         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32837         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32838         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32839         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32840         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32841         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32842         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32843         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32844         LDKU128 user_channel_id_arg_ref;
32845         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32846         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32847         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
32848         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
32849         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
32850         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
32851         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32852         CHECK_ACCESS(confirmations_required_arg_ptr);
32853         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32854         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32855         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32856         CHECK_ACCESS(confirmations_arg_ptr);
32857         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32858         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32859         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32860         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32861         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32862         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32863         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32864         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32865         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32866         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32867         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32868         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32869         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32870         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32871         LDKChannelConfig config_arg_conv;
32872         config_arg_conv.inner = untag_ptr(config_arg);
32873         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32875         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32876         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, feerate_sat_per_1000_weight_arg_conv, 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);
32877         int64_t ret_ref = 0;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32880         return ret_ref;
32881 }
32882
32883 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32884         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32885         int64_t ret_ref = 0;
32886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32888         return ret_ref;
32889 }
32890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32891         LDKChannelDetails arg_conv;
32892         arg_conv.inner = untag_ptr(arg);
32893         arg_conv.is_owned = ptr_is_owned(arg);
32894         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32895         arg_conv.is_owned = false;
32896         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32897         return ret_conv;
32898 }
32899
32900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32901         LDKChannelDetails orig_conv;
32902         orig_conv.inner = untag_ptr(orig);
32903         orig_conv.is_owned = ptr_is_owned(orig);
32904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32905         orig_conv.is_owned = false;
32906         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32907         int64_t ret_ref = 0;
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32910         return ret_ref;
32911 }
32912
32913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32914         LDKChannelDetails this_arg_conv;
32915         this_arg_conv.inner = untag_ptr(this_arg);
32916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32918         this_arg_conv.is_owned = false;
32919         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32920         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32921         int64_t ret_ref = tag_ptr(ret_copy, true);
32922         return ret_ref;
32923 }
32924
32925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32926         LDKChannelDetails this_arg_conv;
32927         this_arg_conv.inner = untag_ptr(this_arg);
32928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32930         this_arg_conv.is_owned = false;
32931         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32932         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32933         int64_t ret_ref = tag_ptr(ret_copy, true);
32934         return ret_ref;
32935 }
32936
32937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32938         if (!ptr_is_owned(this_ptr)) return;
32939         void* this_ptr_ptr = untag_ptr(this_ptr);
32940         CHECK_ACCESS(this_ptr_ptr);
32941         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
32942         FREE(untag_ptr(this_ptr));
32943         RecentPaymentDetails_free(this_ptr_conv);
32944 }
32945
32946 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
32947         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32948         *ret_copy = RecentPaymentDetails_clone(arg);
32949         int64_t ret_ref = tag_ptr(ret_copy, true);
32950         return ret_ref;
32951 }
32952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32953         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
32954         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
32955         return ret_conv;
32956 }
32957
32958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32959         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
32960         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32961         *ret_copy = RecentPaymentDetails_clone(orig_conv);
32962         int64_t ret_ref = tag_ptr(ret_copy, true);
32963         return ret_ref;
32964 }
32965
32966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1pending(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t total_msat) {
32967         LDKThirtyTwoBytes payment_hash_ref;
32968         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32969         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32970         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32971         *ret_copy = RecentPaymentDetails_pending(payment_hash_ref, total_msat);
32972         int64_t ret_ref = tag_ptr(ret_copy, true);
32973         return ret_ref;
32974 }
32975
32976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1fulfilled(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32977         LDKThirtyTwoBytes payment_hash_ref;
32978         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32979         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32980         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32981         *ret_copy = RecentPaymentDetails_fulfilled(payment_hash_ref);
32982         int64_t ret_ref = tag_ptr(ret_copy, true);
32983         return ret_ref;
32984 }
32985
32986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1abandoned(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32987         LDKThirtyTwoBytes payment_hash_ref;
32988         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32989         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32990         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32991         *ret_copy = RecentPaymentDetails_abandoned(payment_hash_ref);
32992         int64_t ret_ref = tag_ptr(ret_copy, true);
32993         return ret_ref;
32994 }
32995
32996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32997         LDKPhantomRouteHints this_obj_conv;
32998         this_obj_conv.inner = untag_ptr(this_obj);
32999         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33001         PhantomRouteHints_free(this_obj_conv);
33002 }
33003
33004 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
33005         LDKPhantomRouteHints this_ptr_conv;
33006         this_ptr_conv.inner = untag_ptr(this_ptr);
33007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33009         this_ptr_conv.is_owned = false;
33010         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
33011         int64_tArray ret_arr = NULL;
33012         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33013         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33014         for (size_t q = 0; q < ret_var.datalen; q++) {
33015                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33016                 int64_t ret_conv_16_ref = 0;
33017                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33018                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33019                 ret_arr_ptr[q] = ret_conv_16_ref;
33020         }
33021         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33022         FREE(ret_var.data);
33023         return ret_arr;
33024 }
33025
33026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33027         LDKPhantomRouteHints this_ptr_conv;
33028         this_ptr_conv.inner = untag_ptr(this_ptr);
33029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33031         this_ptr_conv.is_owned = false;
33032         LDKCVec_ChannelDetailsZ val_constr;
33033         val_constr.datalen = (*env)->GetArrayLength(env, val);
33034         if (val_constr.datalen > 0)
33035                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33036         else
33037                 val_constr.data = NULL;
33038         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33039         for (size_t q = 0; q < val_constr.datalen; q++) {
33040                 int64_t val_conv_16 = val_vals[q];
33041                 LDKChannelDetails val_conv_16_conv;
33042                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
33043                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
33044                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33045                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
33046                 val_constr.data[q] = val_conv_16_conv;
33047         }
33048         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33049         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
33050 }
33051
33052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33053         LDKPhantomRouteHints this_ptr_conv;
33054         this_ptr_conv.inner = untag_ptr(this_ptr);
33055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33057         this_ptr_conv.is_owned = false;
33058         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
33059         return ret_conv;
33060 }
33061
33062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33063         LDKPhantomRouteHints this_ptr_conv;
33064         this_ptr_conv.inner = untag_ptr(this_ptr);
33065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33067         this_ptr_conv.is_owned = false;
33068         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
33069 }
33070
33071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33072         LDKPhantomRouteHints this_ptr_conv;
33073         this_ptr_conv.inner = untag_ptr(this_ptr);
33074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33076         this_ptr_conv.is_owned = false;
33077         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
33079         return ret_arr;
33080 }
33081
33082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33083         LDKPhantomRouteHints this_ptr_conv;
33084         this_ptr_conv.inner = untag_ptr(this_ptr);
33085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33087         this_ptr_conv.is_owned = false;
33088         LDKPublicKey val_ref;
33089         CHECK((*env)->GetArrayLength(env, val) == 33);
33090         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33091         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
33092 }
33093
33094 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) {
33095         LDKCVec_ChannelDetailsZ channels_arg_constr;
33096         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
33097         if (channels_arg_constr.datalen > 0)
33098                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33099         else
33100                 channels_arg_constr.data = NULL;
33101         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
33102         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
33103                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
33104                 LDKChannelDetails channels_arg_conv_16_conv;
33105                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
33106                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
33107                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
33108                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
33109                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
33110         }
33111         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
33112         LDKPublicKey real_node_pubkey_arg_ref;
33113         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
33114         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
33115         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
33116         int64_t ret_ref = 0;
33117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33119         return ret_ref;
33120 }
33121
33122 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
33123         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
33124         int64_t ret_ref = 0;
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33127         return ret_ref;
33128 }
33129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33130         LDKPhantomRouteHints arg_conv;
33131         arg_conv.inner = untag_ptr(arg);
33132         arg_conv.is_owned = ptr_is_owned(arg);
33133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33134         arg_conv.is_owned = false;
33135         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
33136         return ret_conv;
33137 }
33138
33139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33140         LDKPhantomRouteHints orig_conv;
33141         orig_conv.inner = untag_ptr(orig);
33142         orig_conv.is_owned = ptr_is_owned(orig);
33143         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33144         orig_conv.is_owned = false;
33145         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
33146         int64_t ret_ref = 0;
33147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33149         return ret_ref;
33150 }
33151
33152 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 router, int64_t logger, int64_t entropy_source, int64_t node_signer, int64_t signer_provider, int64_t config, int64_t params) {
33153         void* fee_est_ptr = untag_ptr(fee_est);
33154         CHECK_ACCESS(fee_est_ptr);
33155         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
33156         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
33157                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33158                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
33159         }
33160         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33161         CHECK_ACCESS(chain_monitor_ptr);
33162         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33163         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33164                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33165                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33166         }
33167         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33168         CHECK_ACCESS(tx_broadcaster_ptr);
33169         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33170         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33171                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33172                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33173         }
33174         void* router_ptr = untag_ptr(router);
33175         CHECK_ACCESS(router_ptr);
33176         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33177         if (router_conv.free == LDKRouter_JCalls_free) {
33178                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33179                 LDKRouter_JCalls_cloned(&router_conv);
33180         }
33181         void* logger_ptr = untag_ptr(logger);
33182         CHECK_ACCESS(logger_ptr);
33183         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33184         if (logger_conv.free == LDKLogger_JCalls_free) {
33185                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33186                 LDKLogger_JCalls_cloned(&logger_conv);
33187         }
33188         void* entropy_source_ptr = untag_ptr(entropy_source);
33189         CHECK_ACCESS(entropy_source_ptr);
33190         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
33191         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
33192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33193                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
33194         }
33195         void* node_signer_ptr = untag_ptr(node_signer);
33196         CHECK_ACCESS(node_signer_ptr);
33197         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
33198         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
33199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33200                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
33201         }
33202         void* signer_provider_ptr = untag_ptr(signer_provider);
33203         CHECK_ACCESS(signer_provider_ptr);
33204         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
33205         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
33206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33207                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
33208         }
33209         LDKUserConfig config_conv;
33210         config_conv.inner = untag_ptr(config);
33211         config_conv.is_owned = ptr_is_owned(config);
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33213         config_conv = UserConfig_clone(&config_conv);
33214         LDKChainParameters params_conv;
33215         params_conv.inner = untag_ptr(params);
33216         params_conv.is_owned = ptr_is_owned(params);
33217         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
33218         params_conv = ChainParameters_clone(&params_conv);
33219         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, router_conv, logger_conv, entropy_source_conv, node_signer_conv, signer_provider_conv, config_conv, params_conv);
33220         int64_t ret_ref = 0;
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33223         return ret_ref;
33224 }
33225
33226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
33227         LDKChannelManager this_arg_conv;
33228         this_arg_conv.inner = untag_ptr(this_arg);
33229         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33231         this_arg_conv.is_owned = false;
33232         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
33233         int64_t ret_ref = 0;
33234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33236         return ret_ref;
33237 }
33238
33239 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) {
33240         LDKChannelManager this_arg_conv;
33241         this_arg_conv.inner = untag_ptr(this_arg);
33242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33244         this_arg_conv.is_owned = false;
33245         LDKPublicKey their_network_key_ref;
33246         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
33247         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
33248         LDKU128 user_channel_id_ref;
33249         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33250         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33251         LDKUserConfig override_config_conv;
33252         override_config_conv.inner = untag_ptr(override_config);
33253         override_config_conv.is_owned = ptr_is_owned(override_config);
33254         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
33255         override_config_conv = UserConfig_clone(&override_config_conv);
33256         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
33257         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
33258         return tag_ptr(ret_conv, true);
33259 }
33260
33261 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33262         LDKChannelManager this_arg_conv;
33263         this_arg_conv.inner = untag_ptr(this_arg);
33264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33266         this_arg_conv.is_owned = false;
33267         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
33268         int64_tArray ret_arr = NULL;
33269         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33270         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33271         for (size_t q = 0; q < ret_var.datalen; q++) {
33272                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33273                 int64_t ret_conv_16_ref = 0;
33274                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33275                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33276                 ret_arr_ptr[q] = ret_conv_16_ref;
33277         }
33278         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33279         FREE(ret_var.data);
33280         return ret_arr;
33281 }
33282
33283 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33284         LDKChannelManager this_arg_conv;
33285         this_arg_conv.inner = untag_ptr(this_arg);
33286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33288         this_arg_conv.is_owned = false;
33289         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
33290         int64_tArray ret_arr = NULL;
33291         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33292         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33293         for (size_t q = 0; q < ret_var.datalen; q++) {
33294                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33295                 int64_t ret_conv_16_ref = 0;
33296                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33297                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33298                 ret_arr_ptr[q] = ret_conv_16_ref;
33299         }
33300         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33301         FREE(ret_var.data);
33302         return ret_arr;
33303 }
33304
33305 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels_1with_1counterparty(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id) {
33306         LDKChannelManager this_arg_conv;
33307         this_arg_conv.inner = untag_ptr(this_arg);
33308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33310         this_arg_conv.is_owned = false;
33311         LDKPublicKey counterparty_node_id_ref;
33312         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33313         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33314         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
33315         int64_tArray ret_arr = NULL;
33316         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33317         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33318         for (size_t q = 0; q < ret_var.datalen; q++) {
33319                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33320                 int64_t ret_conv_16_ref = 0;
33321                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33322                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33323                 ret_arr_ptr[q] = ret_conv_16_ref;
33324         }
33325         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33326         FREE(ret_var.data);
33327         return ret_arr;
33328 }
33329
33330 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1recent_1payments(JNIEnv *env, jclass clz, int64_t this_arg) {
33331         LDKChannelManager this_arg_conv;
33332         this_arg_conv.inner = untag_ptr(this_arg);
33333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33335         this_arg_conv.is_owned = false;
33336         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
33337         int64_tArray ret_arr = NULL;
33338         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33339         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33340         for (size_t w = 0; w < ret_var.datalen; w++) {
33341                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
33342                 *ret_conv_22_copy = ret_var.data[w];
33343                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
33344                 ret_arr_ptr[w] = ret_conv_22_ref;
33345         }
33346         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33347         FREE(ret_var.data);
33348         return ret_arr;
33349 }
33350
33351 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) {
33352         LDKChannelManager this_arg_conv;
33353         this_arg_conv.inner = untag_ptr(this_arg);
33354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33356         this_arg_conv.is_owned = false;
33357         uint8_t channel_id_arr[32];
33358         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33359         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33360         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33361         LDKPublicKey counterparty_node_id_ref;
33362         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33363         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33364         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33365         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33366         return tag_ptr(ret_conv, true);
33367 }
33368
33369 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) {
33370         LDKChannelManager this_arg_conv;
33371         this_arg_conv.inner = untag_ptr(this_arg);
33372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33374         this_arg_conv.is_owned = false;
33375         uint8_t channel_id_arr[32];
33376         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33377         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33378         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33379         LDKPublicKey counterparty_node_id_ref;
33380         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33381         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33382         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33383         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
33384         return tag_ptr(ret_conv, true);
33385 }
33386
33387 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) {
33388         LDKChannelManager this_arg_conv;
33389         this_arg_conv.inner = untag_ptr(this_arg);
33390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33392         this_arg_conv.is_owned = false;
33393         uint8_t channel_id_arr[32];
33394         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33395         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33396         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33397         LDKPublicKey counterparty_node_id_ref;
33398         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33399         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33400         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33401         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33402         return tag_ptr(ret_conv, true);
33403 }
33404
33405 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) {
33406         LDKChannelManager this_arg_conv;
33407         this_arg_conv.inner = untag_ptr(this_arg);
33408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33410         this_arg_conv.is_owned = false;
33411         uint8_t channel_id_arr[32];
33412         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33413         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33414         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33415         LDKPublicKey counterparty_node_id_ref;
33416         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33417         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33418         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33419         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33420         return tag_ptr(ret_conv, true);
33421 }
33422
33423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33424         LDKChannelManager this_arg_conv;
33425         this_arg_conv.inner = untag_ptr(this_arg);
33426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33428         this_arg_conv.is_owned = false;
33429         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
33430 }
33431
33432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33433         LDKChannelManager this_arg_conv;
33434         this_arg_conv.inner = untag_ptr(this_arg);
33435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33437         this_arg_conv.is_owned = false;
33438         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
33439 }
33440
33441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1route(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) {
33442         LDKChannelManager this_arg_conv;
33443         this_arg_conv.inner = untag_ptr(this_arg);
33444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33446         this_arg_conv.is_owned = false;
33447         LDKRoute route_conv;
33448         route_conv.inner = untag_ptr(route);
33449         route_conv.is_owned = ptr_is_owned(route);
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33451         route_conv.is_owned = false;
33452         LDKThirtyTwoBytes payment_hash_ref;
33453         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33454         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33455         LDKRecipientOnionFields recipient_onion_conv;
33456         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33457         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33459         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33460         LDKThirtyTwoBytes payment_id_ref;
33461         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33462         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33463         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
33464         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
33465         return tag_ptr(ret_conv, true);
33466 }
33467
33468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33469         LDKChannelManager this_arg_conv;
33470         this_arg_conv.inner = untag_ptr(this_arg);
33471         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33473         this_arg_conv.is_owned = false;
33474         LDKThirtyTwoBytes payment_hash_ref;
33475         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33476         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33477         LDKRecipientOnionFields recipient_onion_conv;
33478         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33479         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33481         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33482         LDKThirtyTwoBytes payment_id_ref;
33483         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33484         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33485         LDKRouteParameters route_params_conv;
33486         route_params_conv.inner = untag_ptr(route_params);
33487         route_params_conv.is_owned = ptr_is_owned(route_params);
33488         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33489         route_params_conv = RouteParameters_clone(&route_params_conv);
33490         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33491         CHECK_ACCESS(retry_strategy_ptr);
33492         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33493         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33494         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
33495         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33496         return tag_ptr(ret_conv, true);
33497 }
33498
33499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
33500         LDKChannelManager this_arg_conv;
33501         this_arg_conv.inner = untag_ptr(this_arg);
33502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33504         this_arg_conv.is_owned = false;
33505         LDKThirtyTwoBytes payment_id_ref;
33506         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33507         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33508         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
33509 }
33510
33511 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, int64_t recipient_onion, int8_tArray payment_id) {
33512         LDKChannelManager this_arg_conv;
33513         this_arg_conv.inner = untag_ptr(this_arg);
33514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33516         this_arg_conv.is_owned = false;
33517         LDKRoute route_conv;
33518         route_conv.inner = untag_ptr(route);
33519         route_conv.is_owned = ptr_is_owned(route);
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33521         route_conv.is_owned = false;
33522         LDKThirtyTwoBytes payment_preimage_ref;
33523         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33524         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33525         LDKRecipientOnionFields recipient_onion_conv;
33526         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33527         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33528         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33529         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33530         LDKThirtyTwoBytes payment_id_ref;
33531         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33532         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33533         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
33534         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref);
33535         return tag_ptr(ret_conv, true);
33536 }
33537
33538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment_1with_1retry(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33539         LDKChannelManager this_arg_conv;
33540         this_arg_conv.inner = untag_ptr(this_arg);
33541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33543         this_arg_conv.is_owned = false;
33544         LDKThirtyTwoBytes payment_preimage_ref;
33545         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33546         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33547         LDKRecipientOnionFields recipient_onion_conv;
33548         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33549         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33550         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33551         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33552         LDKThirtyTwoBytes payment_id_ref;
33553         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33554         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33555         LDKRouteParameters route_params_conv;
33556         route_params_conv.inner = untag_ptr(route_params);
33557         route_params_conv.is_owned = ptr_is_owned(route_params);
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33559         route_params_conv = RouteParameters_clone(&route_params_conv);
33560         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33561         CHECK_ACCESS(retry_strategy_ptr);
33562         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33563         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33564         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
33565         *ret_conv = ChannelManager_send_spontaneous_payment_with_retry(&this_arg_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33566         return tag_ptr(ret_conv, true);
33567 }
33568
33569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
33570         LDKChannelManager this_arg_conv;
33571         this_arg_conv.inner = untag_ptr(this_arg);
33572         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33574         this_arg_conv.is_owned = false;
33575         LDKPath path_conv;
33576         path_conv.inner = untag_ptr(path);
33577         path_conv.is_owned = ptr_is_owned(path);
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
33579         path_conv = Path_clone(&path_conv);
33580         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
33581         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
33582         return tag_ptr(ret_conv, true);
33583 }
33584
33585 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) {
33586         LDKChannelManager this_arg_conv;
33587         this_arg_conv.inner = untag_ptr(this_arg);
33588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33590         this_arg_conv.is_owned = false;
33591         uint8_t temporary_channel_id_arr[32];
33592         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33593         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33594         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33595         LDKPublicKey counterparty_node_id_ref;
33596         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33597         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33598         LDKTransaction funding_transaction_ref;
33599         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33600         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33601         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33602         funding_transaction_ref.data_is_owned = true;
33603         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33604         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33605         return tag_ptr(ret_conv, true);
33606 }
33607
33608 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) {
33609         LDKChannelManager this_arg_conv;
33610         this_arg_conv.inner = untag_ptr(this_arg);
33611         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33613         this_arg_conv.is_owned = false;
33614         LDKPublicKey counterparty_node_id_ref;
33615         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33616         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33617         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33618         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33619         if (channel_ids_constr.datalen > 0)
33620                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33621         else
33622                 channel_ids_constr.data = NULL;
33623         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33624                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33625                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33626                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33627                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33628                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33629         }
33630         LDKChannelConfig config_conv;
33631         config_conv.inner = untag_ptr(config);
33632         config_conv.is_owned = ptr_is_owned(config);
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33634         config_conv.is_owned = false;
33635         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33636         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33637         return tag_ptr(ret_conv, true);
33638 }
33639
33640 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) {
33641         LDKChannelManager this_arg_conv;
33642         this_arg_conv.inner = untag_ptr(this_arg);
33643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33645         this_arg_conv.is_owned = false;
33646         LDKThirtyTwoBytes intercept_id_ref;
33647         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33648         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33649         uint8_t next_hop_channel_id_arr[32];
33650         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33651         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33652         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33653         LDKPublicKey next_node_id_ref;
33654         CHECK((*env)->GetArrayLength(env, next_node_id) == 33);
33655         (*env)->GetByteArrayRegion(env, next_node_id, 0, 33, next_node_id_ref.compressed_form);
33656         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33657         *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);
33658         return tag_ptr(ret_conv, true);
33659 }
33660
33661 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) {
33662         LDKChannelManager this_arg_conv;
33663         this_arg_conv.inner = untag_ptr(this_arg);
33664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33666         this_arg_conv.is_owned = false;
33667         LDKThirtyTwoBytes intercept_id_ref;
33668         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33669         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33670         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33671         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33672         return tag_ptr(ret_conv, true);
33673 }
33674
33675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33676         LDKChannelManager this_arg_conv;
33677         this_arg_conv.inner = untag_ptr(this_arg);
33678         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33680         this_arg_conv.is_owned = false;
33681         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33682 }
33683
33684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33685         LDKChannelManager this_arg_conv;
33686         this_arg_conv.inner = untag_ptr(this_arg);
33687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33689         this_arg_conv.is_owned = false;
33690         ChannelManager_timer_tick_occurred(&this_arg_conv);
33691 }
33692
33693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33694         LDKChannelManager this_arg_conv;
33695         this_arg_conv.inner = untag_ptr(this_arg);
33696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33698         this_arg_conv.is_owned = false;
33699         uint8_t payment_hash_arr[32];
33700         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33701         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33702         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33703         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33704 }
33705
33706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards_1with_1reason(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, jclass failure_code) {
33707         LDKChannelManager this_arg_conv;
33708         this_arg_conv.inner = untag_ptr(this_arg);
33709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33711         this_arg_conv.is_owned = false;
33712         uint8_t payment_hash_arr[32];
33713         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33714         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33715         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33716         LDKFailureCode failure_code_conv = LDKFailureCode_from_java(env, failure_code);
33717         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
33718 }
33719
33720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33721         LDKChannelManager this_arg_conv;
33722         this_arg_conv.inner = untag_ptr(this_arg);
33723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33725         this_arg_conv.is_owned = false;
33726         LDKThirtyTwoBytes payment_preimage_ref;
33727         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33728         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33729         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33730 }
33731
33732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33733         LDKChannelManager this_arg_conv;
33734         this_arg_conv.inner = untag_ptr(this_arg);
33735         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33737         this_arg_conv.is_owned = false;
33738         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33739         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33740         return ret_arr;
33741 }
33742
33743 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) {
33744         LDKChannelManager this_arg_conv;
33745         this_arg_conv.inner = untag_ptr(this_arg);
33746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33748         this_arg_conv.is_owned = false;
33749         uint8_t temporary_channel_id_arr[32];
33750         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33751         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33752         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33753         LDKPublicKey counterparty_node_id_ref;
33754         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33755         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33756         LDKU128 user_channel_id_ref;
33757         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33758         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33759         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33760         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33761         return tag_ptr(ret_conv, true);
33762 }
33763
33764 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) {
33765         LDKChannelManager this_arg_conv;
33766         this_arg_conv.inner = untag_ptr(this_arg);
33767         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33769         this_arg_conv.is_owned = false;
33770         uint8_t temporary_channel_id_arr[32];
33771         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33772         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33773         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33774         LDKPublicKey counterparty_node_id_ref;
33775         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33776         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33777         LDKU128 user_channel_id_ref;
33778         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33779         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33780         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33781         *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);
33782         return tag_ptr(ret_conv, true);
33783 }
33784
33785 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, int64_t min_final_cltv_expiry_delta) {
33786         LDKChannelManager this_arg_conv;
33787         this_arg_conv.inner = untag_ptr(this_arg);
33788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33790         this_arg_conv.is_owned = false;
33791         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33792         CHECK_ACCESS(min_value_msat_ptr);
33793         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33794         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33795         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
33796         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
33797         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
33798         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
33799         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33800         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
33801         return tag_ptr(ret_conv, true);
33802 }
33803
33804 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) {
33805         LDKChannelManager this_arg_conv;
33806         this_arg_conv.inner = untag_ptr(this_arg);
33807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33809         this_arg_conv.is_owned = false;
33810         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33811         CHECK_ACCESS(min_value_msat_ptr);
33812         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33813         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33814         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33815         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33816         return tag_ptr(ret_conv, true);
33817 }
33818
33819 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, int64_t min_final_cltv_expiry) {
33820         LDKChannelManager this_arg_conv;
33821         this_arg_conv.inner = untag_ptr(this_arg);
33822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33824         this_arg_conv.is_owned = false;
33825         LDKThirtyTwoBytes payment_hash_ref;
33826         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33827         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33828         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33829         CHECK_ACCESS(min_value_msat_ptr);
33830         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33831         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33832         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
33833         CHECK_ACCESS(min_final_cltv_expiry_ptr);
33834         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
33835         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
33836         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33837         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_conv);
33838         return tag_ptr(ret_conv, true);
33839 }
33840
33841 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) {
33842         LDKChannelManager this_arg_conv;
33843         this_arg_conv.inner = untag_ptr(this_arg);
33844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33846         this_arg_conv.is_owned = false;
33847         LDKThirtyTwoBytes payment_hash_ref;
33848         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33849         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33850         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33851         CHECK_ACCESS(min_value_msat_ptr);
33852         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33853         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33854         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33855         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33856         return tag_ptr(ret_conv, true);
33857 }
33858
33859 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) {
33860         LDKChannelManager this_arg_conv;
33861         this_arg_conv.inner = untag_ptr(this_arg);
33862         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33864         this_arg_conv.is_owned = false;
33865         LDKThirtyTwoBytes payment_hash_ref;
33866         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33867         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33868         LDKThirtyTwoBytes payment_secret_ref;
33869         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33870         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33871         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33872         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33873         return tag_ptr(ret_conv, true);
33874 }
33875
33876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33877         LDKChannelManager this_arg_conv;
33878         this_arg_conv.inner = untag_ptr(this_arg);
33879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33881         this_arg_conv.is_owned = false;
33882         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33883         return ret_conv;
33884 }
33885
33886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33887         LDKChannelManager this_arg_conv;
33888         this_arg_conv.inner = untag_ptr(this_arg);
33889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33891         this_arg_conv.is_owned = false;
33892         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33893         int64_t ret_ref = 0;
33894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33896         return ret_ref;
33897 }
33898
33899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33900         LDKChannelManager this_arg_conv;
33901         this_arg_conv.inner = untag_ptr(this_arg);
33902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33904         this_arg_conv.is_owned = false;
33905         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33906         return ret_conv;
33907 }
33908
33909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33910         LDKChannelManager this_arg_conv;
33911         this_arg_conv.inner = untag_ptr(this_arg);
33912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33914         this_arg_conv.is_owned = false;
33915         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33916         int64_t ret_ref = 0;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33918         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33919         return ret_ref;
33920 }
33921
33922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33923         LDKChannelManager this_arg_conv;
33924         this_arg_conv.inner = untag_ptr(this_arg);
33925         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33927         this_arg_conv.is_owned = false;
33928         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33929         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33930         return tag_ptr(ret_ret, true);
33931 }
33932
33933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33934         LDKChannelManager this_arg_conv;
33935         this_arg_conv.inner = untag_ptr(this_arg);
33936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33938         this_arg_conv.is_owned = false;
33939         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33940         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33941         return tag_ptr(ret_ret, true);
33942 }
33943
33944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33945         LDKChannelManager this_arg_conv;
33946         this_arg_conv.inner = untag_ptr(this_arg);
33947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33949         this_arg_conv.is_owned = false;
33950         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33951         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33952         return tag_ptr(ret_ret, true);
33953 }
33954
33955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33956         LDKChannelManager this_arg_conv;
33957         this_arg_conv.inner = untag_ptr(this_arg);
33958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33960         this_arg_conv.is_owned = false;
33961         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33962         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33963         return tag_ptr(ret_ret, true);
33964 }
33965
33966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33967         LDKChannelManager this_arg_conv;
33968         this_arg_conv.inner = untag_ptr(this_arg);
33969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33971         this_arg_conv.is_owned = false;
33972         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33973         int64_t ret_ref = 0;
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33976         return ret_ref;
33977 }
33978
33979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33980         LDKChannelManager this_arg_conv;
33981         this_arg_conv.inner = untag_ptr(this_arg);
33982         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33984         this_arg_conv.is_owned = false;
33985         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33986         int64_t ret_ref = 0;
33987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33989         return ret_ref;
33990 }
33991
33992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33993         LDKChannelManager this_arg_conv;
33994         this_arg_conv.inner = untag_ptr(this_arg);
33995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33997         this_arg_conv.is_owned = false;
33998         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
33999         int64_t ret_ref = 0;
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34002         return ret_ref;
34003 }
34004
34005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34006         LDKChannelManager this_arg_conv;
34007         this_arg_conv.inner = untag_ptr(this_arg);
34008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34010         this_arg_conv.is_owned = false;
34011         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
34012         int64_t ret_ref = 0;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34015         return ret_ref;
34016 }
34017
34018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1type_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34019         LDKChannelManager this_arg_conv;
34020         this_arg_conv.inner = untag_ptr(this_arg);
34021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34023         this_arg_conv.is_owned = false;
34024         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
34025         int64_t ret_ref = 0;
34026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34028         return ret_ref;
34029 }
34030
34031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34032         LDKChannelManager this_arg_conv;
34033         this_arg_conv.inner = untag_ptr(this_arg);
34034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34036         this_arg_conv.is_owned = false;
34037         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
34038         int64_t ret_ref = 0;
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34041         return ret_ref;
34042 }
34043
34044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34045         LDKChannelManager this_arg_conv;
34046         this_arg_conv.inner = untag_ptr(this_arg);
34047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34049         this_arg_conv.is_owned = false;
34050         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34051         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
34052         return tag_ptr(ret_ret, true);
34053 }
34054
34055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz, int64_t _config) {
34056         LDKUserConfig _config_conv;
34057         _config_conv.inner = untag_ptr(_config);
34058         _config_conv.is_owned = ptr_is_owned(_config);
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(_config_conv);
34060         _config_conv.is_owned = false;
34061         LDKInitFeatures ret_var = provided_init_features(&_config_conv);
34062         int64_t ret_ref = 0;
34063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34065         return ret_ref;
34066 }
34067
34068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
34069         LDKCounterpartyForwardingInfo obj_conv;
34070         obj_conv.inner = untag_ptr(obj);
34071         obj_conv.is_owned = ptr_is_owned(obj);
34072         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34073         obj_conv.is_owned = false;
34074         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
34075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34077         CVec_u8Z_free(ret_var);
34078         return ret_arr;
34079 }
34080
34081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34082         LDKu8slice ser_ref;
34083         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34084         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34085         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
34086         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
34087         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34088         return tag_ptr(ret_conv, true);
34089 }
34090
34091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
34092         LDKChannelCounterparty obj_conv;
34093         obj_conv.inner = untag_ptr(obj);
34094         obj_conv.is_owned = ptr_is_owned(obj);
34095         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34096         obj_conv.is_owned = false;
34097         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
34098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34100         CVec_u8Z_free(ret_var);
34101         return ret_arr;
34102 }
34103
34104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34105         LDKu8slice ser_ref;
34106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34108         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
34109         *ret_conv = ChannelCounterparty_read(ser_ref);
34110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34111         return tag_ptr(ret_conv, true);
34112 }
34113
34114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
34115         LDKChannelDetails obj_conv;
34116         obj_conv.inner = untag_ptr(obj);
34117         obj_conv.is_owned = ptr_is_owned(obj);
34118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34119         obj_conv.is_owned = false;
34120         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
34121         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34122         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34123         CVec_u8Z_free(ret_var);
34124         return ret_arr;
34125 }
34126
34127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34128         LDKu8slice ser_ref;
34129         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34130         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34131         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
34132         *ret_conv = ChannelDetails_read(ser_ref);
34133         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34134         return tag_ptr(ret_conv, true);
34135 }
34136
34137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
34138         LDKPhantomRouteHints obj_conv;
34139         obj_conv.inner = untag_ptr(obj);
34140         obj_conv.is_owned = ptr_is_owned(obj);
34141         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34142         obj_conv.is_owned = false;
34143         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
34144         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34145         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34146         CVec_u8Z_free(ret_var);
34147         return ret_arr;
34148 }
34149
34150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34151         LDKu8slice ser_ref;
34152         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34153         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34154         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
34155         *ret_conv = PhantomRouteHints_read(ser_ref);
34156         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34157         return tag_ptr(ret_conv, true);
34158 }
34159
34160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
34161         LDKChannelManager obj_conv;
34162         obj_conv.inner = untag_ptr(obj);
34163         obj_conv.is_owned = ptr_is_owned(obj);
34164         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34165         obj_conv.is_owned = false;
34166         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
34167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34169         CVec_u8Z_free(ret_var);
34170         return ret_arr;
34171 }
34172
34173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34174         LDKChannelManagerReadArgs this_obj_conv;
34175         this_obj_conv.inner = untag_ptr(this_obj);
34176         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34178         ChannelManagerReadArgs_free(this_obj_conv);
34179 }
34180
34181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr) {
34182         LDKChannelManagerReadArgs this_ptr_conv;
34183         this_ptr_conv.inner = untag_ptr(this_ptr);
34184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34186         this_ptr_conv.is_owned = false;
34187         // WARNING: This object doesn't live past this scope, needs clone!
34188         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
34189         return ret_ret;
34190 }
34191
34192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34193         LDKChannelManagerReadArgs this_ptr_conv;
34194         this_ptr_conv.inner = untag_ptr(this_ptr);
34195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34197         this_ptr_conv.is_owned = false;
34198         void* val_ptr = untag_ptr(val);
34199         CHECK_ACCESS(val_ptr);
34200         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
34201         if (val_conv.free == LDKEntropySource_JCalls_free) {
34202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34203                 LDKEntropySource_JCalls_cloned(&val_conv);
34204         }
34205         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
34206 }
34207
34208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr) {
34209         LDKChannelManagerReadArgs this_ptr_conv;
34210         this_ptr_conv.inner = untag_ptr(this_ptr);
34211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34213         this_ptr_conv.is_owned = false;
34214         // WARNING: This object doesn't live past this scope, needs clone!
34215         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
34216         return ret_ret;
34217 }
34218
34219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34220         LDKChannelManagerReadArgs this_ptr_conv;
34221         this_ptr_conv.inner = untag_ptr(this_ptr);
34222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34224         this_ptr_conv.is_owned = false;
34225         void* val_ptr = untag_ptr(val);
34226         CHECK_ACCESS(val_ptr);
34227         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
34228         if (val_conv.free == LDKNodeSigner_JCalls_free) {
34229                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34230                 LDKNodeSigner_JCalls_cloned(&val_conv);
34231         }
34232         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
34233 }
34234
34235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr) {
34236         LDKChannelManagerReadArgs this_ptr_conv;
34237         this_ptr_conv.inner = untag_ptr(this_ptr);
34238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34240         this_ptr_conv.is_owned = false;
34241         // WARNING: This object doesn't live past this scope, needs clone!
34242         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
34243         return ret_ret;
34244 }
34245
34246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34247         LDKChannelManagerReadArgs this_ptr_conv;
34248         this_ptr_conv.inner = untag_ptr(this_ptr);
34249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34251         this_ptr_conv.is_owned = false;
34252         void* val_ptr = untag_ptr(val);
34253         CHECK_ACCESS(val_ptr);
34254         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
34255         if (val_conv.free == LDKSignerProvider_JCalls_free) {
34256                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34257                 LDKSignerProvider_JCalls_cloned(&val_conv);
34258         }
34259         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
34260 }
34261
34262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
34263         LDKChannelManagerReadArgs this_ptr_conv;
34264         this_ptr_conv.inner = untag_ptr(this_ptr);
34265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34267         this_ptr_conv.is_owned = false;
34268         // WARNING: This object doesn't live past this scope, needs clone!
34269         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
34270         return ret_ret;
34271 }
34272
34273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34274         LDKChannelManagerReadArgs this_ptr_conv;
34275         this_ptr_conv.inner = untag_ptr(this_ptr);
34276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34278         this_ptr_conv.is_owned = false;
34279         void* val_ptr = untag_ptr(val);
34280         CHECK_ACCESS(val_ptr);
34281         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
34282         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
34283                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34284                 LDKFeeEstimator_JCalls_cloned(&val_conv);
34285         }
34286         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
34287 }
34288
34289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
34290         LDKChannelManagerReadArgs this_ptr_conv;
34291         this_ptr_conv.inner = untag_ptr(this_ptr);
34292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34294         this_ptr_conv.is_owned = false;
34295         // WARNING: This object doesn't live past this scope, needs clone!
34296         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
34297         return ret_ret;
34298 }
34299
34300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34301         LDKChannelManagerReadArgs 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         void* val_ptr = untag_ptr(val);
34307         CHECK_ACCESS(val_ptr);
34308         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
34309         if (val_conv.free == LDKWatch_JCalls_free) {
34310                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34311                 LDKWatch_JCalls_cloned(&val_conv);
34312         }
34313         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
34314 }
34315
34316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
34317         LDKChannelManagerReadArgs this_ptr_conv;
34318         this_ptr_conv.inner = untag_ptr(this_ptr);
34319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34321         this_ptr_conv.is_owned = false;
34322         // WARNING: This object doesn't live past this scope, needs clone!
34323         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
34324         return ret_ret;
34325 }
34326
34327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34328         LDKChannelManagerReadArgs this_ptr_conv;
34329         this_ptr_conv.inner = untag_ptr(this_ptr);
34330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34332         this_ptr_conv.is_owned = false;
34333         void* val_ptr = untag_ptr(val);
34334         CHECK_ACCESS(val_ptr);
34335         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
34336         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
34337                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34338                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
34339         }
34340         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
34341 }
34342
34343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1router(JNIEnv *env, jclass clz, int64_t this_ptr) {
34344         LDKChannelManagerReadArgs this_ptr_conv;
34345         this_ptr_conv.inner = untag_ptr(this_ptr);
34346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34348         this_ptr_conv.is_owned = false;
34349         // WARNING: This object doesn't live past this scope, needs clone!
34350         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
34351         return ret_ret;
34352 }
34353
34354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1router(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34355         LDKChannelManagerReadArgs this_ptr_conv;
34356         this_ptr_conv.inner = untag_ptr(this_ptr);
34357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34359         this_ptr_conv.is_owned = false;
34360         void* val_ptr = untag_ptr(val);
34361         CHECK_ACCESS(val_ptr);
34362         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
34363         if (val_conv.free == LDKRouter_JCalls_free) {
34364                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34365                 LDKRouter_JCalls_cloned(&val_conv);
34366         }
34367         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
34368 }
34369
34370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
34371         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
34377         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
34378         return ret_ret;
34379 }
34380
34381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34382         LDKChannelManagerReadArgs this_ptr_conv;
34383         this_ptr_conv.inner = untag_ptr(this_ptr);
34384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34386         this_ptr_conv.is_owned = false;
34387         void* val_ptr = untag_ptr(val);
34388         CHECK_ACCESS(val_ptr);
34389         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
34390         if (val_conv.free == LDKLogger_JCalls_free) {
34391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34392                 LDKLogger_JCalls_cloned(&val_conv);
34393         }
34394         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
34395 }
34396
34397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
34398         LDKChannelManagerReadArgs this_ptr_conv;
34399         this_ptr_conv.inner = untag_ptr(this_ptr);
34400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34402         this_ptr_conv.is_owned = false;
34403         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
34404         int64_t ret_ref = 0;
34405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34407         return ret_ref;
34408 }
34409
34410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34411         LDKChannelManagerReadArgs this_ptr_conv;
34412         this_ptr_conv.inner = untag_ptr(this_ptr);
34413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34415         this_ptr_conv.is_owned = false;
34416         LDKUserConfig val_conv;
34417         val_conv.inner = untag_ptr(val);
34418         val_conv.is_owned = ptr_is_owned(val);
34419         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34420         val_conv = UserConfig_clone(&val_conv);
34421         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
34422 }
34423
34424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t entropy_source, int64_t node_signer, int64_t signer_provider, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t router, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
34425         void* entropy_source_ptr = untag_ptr(entropy_source);
34426         CHECK_ACCESS(entropy_source_ptr);
34427         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
34428         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
34429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34430                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
34431         }
34432         void* node_signer_ptr = untag_ptr(node_signer);
34433         CHECK_ACCESS(node_signer_ptr);
34434         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
34435         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
34436                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34437                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
34438         }
34439         void* signer_provider_ptr = untag_ptr(signer_provider);
34440         CHECK_ACCESS(signer_provider_ptr);
34441         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
34442         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
34443                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34444                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
34445         }
34446         void* fee_estimator_ptr = untag_ptr(fee_estimator);
34447         CHECK_ACCESS(fee_estimator_ptr);
34448         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
34449         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
34450                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34451                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
34452         }
34453         void* chain_monitor_ptr = untag_ptr(chain_monitor);
34454         CHECK_ACCESS(chain_monitor_ptr);
34455         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
34456         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
34457                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34458                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
34459         }
34460         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
34461         CHECK_ACCESS(tx_broadcaster_ptr);
34462         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
34463         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
34464                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34465                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
34466         }
34467         void* router_ptr = untag_ptr(router);
34468         CHECK_ACCESS(router_ptr);
34469         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
34470         if (router_conv.free == LDKRouter_JCalls_free) {
34471                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34472                 LDKRouter_JCalls_cloned(&router_conv);
34473         }
34474         void* logger_ptr = untag_ptr(logger);
34475         CHECK_ACCESS(logger_ptr);
34476         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34477         if (logger_conv.free == LDKLogger_JCalls_free) {
34478                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34479                 LDKLogger_JCalls_cloned(&logger_conv);
34480         }
34481         LDKUserConfig default_config_conv;
34482         default_config_conv.inner = untag_ptr(default_config);
34483         default_config_conv.is_owned = ptr_is_owned(default_config);
34484         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
34485         default_config_conv = UserConfig_clone(&default_config_conv);
34486         LDKCVec_ChannelMonitorZ channel_monitors_constr;
34487         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
34488         if (channel_monitors_constr.datalen > 0)
34489                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
34490         else
34491                 channel_monitors_constr.data = NULL;
34492         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
34493         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
34494                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
34495                 LDKChannelMonitor channel_monitors_conv_16_conv;
34496                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
34497                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
34498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
34499                 channel_monitors_conv_16_conv.is_owned = false;
34500                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
34501         }
34502         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
34503         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(entropy_source_conv, node_signer_conv, signer_provider_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, router_conv, logger_conv, default_config_conv, channel_monitors_constr);
34504         int64_t ret_ref = 0;
34505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34507         return ret_ref;
34508 }
34509
34510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
34511         LDKu8slice ser_ref;
34512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34514         LDKChannelManagerReadArgs arg_conv;
34515         arg_conv.inner = untag_ptr(arg);
34516         arg_conv.is_owned = ptr_is_owned(arg);
34517         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34518         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
34519         
34520         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
34521         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
34522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34523         return tag_ptr(ret_conv, true);
34524 }
34525
34526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34527         LDKExpandedKey this_obj_conv;
34528         this_obj_conv.inner = untag_ptr(this_obj);
34529         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34531         ExpandedKey_free(this_obj_conv);
34532 }
34533
34534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
34535         uint8_t key_material_arr[32];
34536         CHECK((*env)->GetArrayLength(env, key_material) == 32);
34537         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
34538         uint8_t (*key_material_ref)[32] = &key_material_arr;
34539         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
34540         int64_t ret_ref = 0;
34541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34543         return ret_ref;
34544 }
34545
34546 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 entropy_source, int64_t current_time, int64_t min_final_cltv_expiry_delta) {
34547         LDKExpandedKey keys_conv;
34548         keys_conv.inner = untag_ptr(keys);
34549         keys_conv.is_owned = ptr_is_owned(keys);
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34551         keys_conv.is_owned = false;
34552         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34553         CHECK_ACCESS(min_value_msat_ptr);
34554         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34555         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34556         void* entropy_source_ptr = untag_ptr(entropy_source);
34557         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
34558         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
34559         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34560         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34561         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34562         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34563         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
34564         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
34565         return tag_ptr(ret_conv, true);
34566 }
34567
34568 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, int64_t min_final_cltv_expiry_delta) {
34569         LDKExpandedKey keys_conv;
34570         keys_conv.inner = untag_ptr(keys);
34571         keys_conv.is_owned = ptr_is_owned(keys);
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34573         keys_conv.is_owned = false;
34574         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34575         CHECK_ACCESS(min_value_msat_ptr);
34576         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34577         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34578         LDKThirtyTwoBytes payment_hash_ref;
34579         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
34580         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
34581         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34582         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34583         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34584         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34585         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
34586         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time, min_final_cltv_expiry_delta_conv);
34587         return tag_ptr(ret_conv, true);
34588 }
34589
34590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34591         if (!ptr_is_owned(this_ptr)) return;
34592         void* this_ptr_ptr = untag_ptr(this_ptr);
34593         CHECK_ACCESS(this_ptr_ptr);
34594         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
34595         FREE(untag_ptr(this_ptr));
34596         DecodeError_free(this_ptr_conv);
34597 }
34598
34599 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
34600         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34601         *ret_copy = DecodeError_clone(arg);
34602         int64_t ret_ref = tag_ptr(ret_copy, true);
34603         return ret_ref;
34604 }
34605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34606         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
34607         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
34608         return ret_conv;
34609 }
34610
34611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34612         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
34613         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34614         *ret_copy = DecodeError_clone(orig_conv);
34615         int64_t ret_ref = tag_ptr(ret_copy, true);
34616         return ret_ref;
34617 }
34618
34619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
34620         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34621         *ret_copy = DecodeError_unknown_version();
34622         int64_t ret_ref = tag_ptr(ret_copy, true);
34623         return ret_ref;
34624 }
34625
34626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
34627         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34628         *ret_copy = DecodeError_unknown_required_feature();
34629         int64_t ret_ref = tag_ptr(ret_copy, true);
34630         return ret_ref;
34631 }
34632
34633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
34634         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34635         *ret_copy = DecodeError_invalid_value();
34636         int64_t ret_ref = tag_ptr(ret_copy, true);
34637         return ret_ref;
34638 }
34639
34640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
34641         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34642         *ret_copy = DecodeError_short_read();
34643         int64_t ret_ref = tag_ptr(ret_copy, true);
34644         return ret_ref;
34645 }
34646
34647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
34648         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34649         *ret_copy = DecodeError_bad_length_descriptor();
34650         int64_t ret_ref = tag_ptr(ret_copy, true);
34651         return ret_ref;
34652 }
34653
34654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
34655         LDKIOError a_conv = LDKIOError_from_java(env, a);
34656         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34657         *ret_copy = DecodeError_io(a_conv);
34658         int64_t ret_ref = tag_ptr(ret_copy, true);
34659         return ret_ref;
34660 }
34661
34662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
34663         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34664         *ret_copy = DecodeError_unsupported_compression();
34665         int64_t ret_ref = tag_ptr(ret_copy, true);
34666         return ret_ref;
34667 }
34668
34669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34670         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
34671         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
34672         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
34673         return ret_conv;
34674 }
34675
34676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34677         LDKInit this_obj_conv;
34678         this_obj_conv.inner = untag_ptr(this_obj);
34679         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34681         Init_free(this_obj_conv);
34682 }
34683
34684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34685         LDKInit this_ptr_conv;
34686         this_ptr_conv.inner = untag_ptr(this_ptr);
34687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34689         this_ptr_conv.is_owned = false;
34690         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
34691         int64_t ret_ref = 0;
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34694         return ret_ref;
34695 }
34696
34697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34698         LDKInit this_ptr_conv;
34699         this_ptr_conv.inner = untag_ptr(this_ptr);
34700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34702         this_ptr_conv.is_owned = false;
34703         LDKInitFeatures val_conv;
34704         val_conv.inner = untag_ptr(val);
34705         val_conv.is_owned = ptr_is_owned(val);
34706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34707         val_conv = InitFeatures_clone(&val_conv);
34708         Init_set_features(&this_ptr_conv, val_conv);
34709 }
34710
34711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
34712         LDKInit this_ptr_conv;
34713         this_ptr_conv.inner = untag_ptr(this_ptr);
34714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34716         this_ptr_conv.is_owned = false;
34717         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
34718         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
34719         int64_t ret_ref = tag_ptr(ret_copy, true);
34720         return ret_ref;
34721 }
34722
34723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34724         LDKInit this_ptr_conv;
34725         this_ptr_conv.inner = untag_ptr(this_ptr);
34726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34728         this_ptr_conv.is_owned = false;
34729         void* val_ptr = untag_ptr(val);
34730         CHECK_ACCESS(val_ptr);
34731         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
34732         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
34733         Init_set_remote_network_address(&this_ptr_conv, val_conv);
34734 }
34735
34736 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) {
34737         LDKInitFeatures features_arg_conv;
34738         features_arg_conv.inner = untag_ptr(features_arg);
34739         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34741         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34742         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
34743         CHECK_ACCESS(remote_network_address_arg_ptr);
34744         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
34745         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
34746         int64_t ret_ref = 0;
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34749         return ret_ref;
34750 }
34751
34752 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34753         LDKInit ret_var = Init_clone(arg);
34754         int64_t ret_ref = 0;
34755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34757         return ret_ref;
34758 }
34759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34760         LDKInit arg_conv;
34761         arg_conv.inner = untag_ptr(arg);
34762         arg_conv.is_owned = ptr_is_owned(arg);
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34764         arg_conv.is_owned = false;
34765         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34766         return ret_conv;
34767 }
34768
34769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34770         LDKInit orig_conv;
34771         orig_conv.inner = untag_ptr(orig);
34772         orig_conv.is_owned = ptr_is_owned(orig);
34773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34774         orig_conv.is_owned = false;
34775         LDKInit ret_var = Init_clone(&orig_conv);
34776         int64_t ret_ref = 0;
34777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34779         return ret_ref;
34780 }
34781
34782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34783         LDKInit a_conv;
34784         a_conv.inner = untag_ptr(a);
34785         a_conv.is_owned = ptr_is_owned(a);
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34787         a_conv.is_owned = false;
34788         LDKInit b_conv;
34789         b_conv.inner = untag_ptr(b);
34790         b_conv.is_owned = ptr_is_owned(b);
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34792         b_conv.is_owned = false;
34793         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34794         return ret_conv;
34795 }
34796
34797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34798         LDKErrorMessage this_obj_conv;
34799         this_obj_conv.inner = untag_ptr(this_obj);
34800         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34802         ErrorMessage_free(this_obj_conv);
34803 }
34804
34805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34806         LDKErrorMessage 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_tArray ret_arr = (*env)->NewByteArray(env, 32);
34812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34813         return ret_arr;
34814 }
34815
34816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34817         LDKErrorMessage this_ptr_conv;
34818         this_ptr_conv.inner = untag_ptr(this_ptr);
34819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34821         this_ptr_conv.is_owned = false;
34822         LDKThirtyTwoBytes val_ref;
34823         CHECK((*env)->GetArrayLength(env, val) == 32);
34824         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34825         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34826 }
34827
34828 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34829         LDKErrorMessage this_ptr_conv;
34830         this_ptr_conv.inner = untag_ptr(this_ptr);
34831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34833         this_ptr_conv.is_owned = false;
34834         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34835         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34836         Str_free(ret_str);
34837         return ret_conv;
34838 }
34839
34840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34841         LDKErrorMessage this_ptr_conv;
34842         this_ptr_conv.inner = untag_ptr(this_ptr);
34843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34845         this_ptr_conv.is_owned = false;
34846         LDKStr val_conv = java_to_owned_str(env, val);
34847         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34848 }
34849
34850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34851         LDKThirtyTwoBytes channel_id_arg_ref;
34852         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34853         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34854         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34855         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34856         int64_t ret_ref = 0;
34857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34859         return ret_ref;
34860 }
34861
34862 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34863         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34864         int64_t ret_ref = 0;
34865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34867         return ret_ref;
34868 }
34869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34870         LDKErrorMessage arg_conv;
34871         arg_conv.inner = untag_ptr(arg);
34872         arg_conv.is_owned = ptr_is_owned(arg);
34873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34874         arg_conv.is_owned = false;
34875         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34876         return ret_conv;
34877 }
34878
34879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34880         LDKErrorMessage orig_conv;
34881         orig_conv.inner = untag_ptr(orig);
34882         orig_conv.is_owned = ptr_is_owned(orig);
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34884         orig_conv.is_owned = false;
34885         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34886         int64_t ret_ref = 0;
34887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34889         return ret_ref;
34890 }
34891
34892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34893         LDKErrorMessage a_conv;
34894         a_conv.inner = untag_ptr(a);
34895         a_conv.is_owned = ptr_is_owned(a);
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34897         a_conv.is_owned = false;
34898         LDKErrorMessage b_conv;
34899         b_conv.inner = untag_ptr(b);
34900         b_conv.is_owned = ptr_is_owned(b);
34901         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34902         b_conv.is_owned = false;
34903         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34904         return ret_conv;
34905 }
34906
34907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34908         LDKWarningMessage this_obj_conv;
34909         this_obj_conv.inner = untag_ptr(this_obj);
34910         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34912         WarningMessage_free(this_obj_conv);
34913 }
34914
34915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34916         LDKWarningMessage 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34922         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34923         return ret_arr;
34924 }
34925
34926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34927         LDKWarningMessage this_ptr_conv;
34928         this_ptr_conv.inner = untag_ptr(this_ptr);
34929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34931         this_ptr_conv.is_owned = false;
34932         LDKThirtyTwoBytes val_ref;
34933         CHECK((*env)->GetArrayLength(env, val) == 32);
34934         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34935         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34936 }
34937
34938 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34939         LDKWarningMessage this_ptr_conv;
34940         this_ptr_conv.inner = untag_ptr(this_ptr);
34941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34943         this_ptr_conv.is_owned = false;
34944         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34945         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34946         Str_free(ret_str);
34947         return ret_conv;
34948 }
34949
34950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34951         LDKWarningMessage this_ptr_conv;
34952         this_ptr_conv.inner = untag_ptr(this_ptr);
34953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34955         this_ptr_conv.is_owned = false;
34956         LDKStr val_conv = java_to_owned_str(env, val);
34957         WarningMessage_set_data(&this_ptr_conv, val_conv);
34958 }
34959
34960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34961         LDKThirtyTwoBytes channel_id_arg_ref;
34962         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34963         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34964         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34965         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34966         int64_t ret_ref = 0;
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34969         return ret_ref;
34970 }
34971
34972 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34973         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34974         int64_t ret_ref = 0;
34975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34977         return ret_ref;
34978 }
34979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34980         LDKWarningMessage arg_conv;
34981         arg_conv.inner = untag_ptr(arg);
34982         arg_conv.is_owned = ptr_is_owned(arg);
34983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34984         arg_conv.is_owned = false;
34985         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34986         return ret_conv;
34987 }
34988
34989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34990         LDKWarningMessage orig_conv;
34991         orig_conv.inner = untag_ptr(orig);
34992         orig_conv.is_owned = ptr_is_owned(orig);
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34994         orig_conv.is_owned = false;
34995         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34996         int64_t ret_ref = 0;
34997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34999         return ret_ref;
35000 }
35001
35002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35003         LDKWarningMessage a_conv;
35004         a_conv.inner = untag_ptr(a);
35005         a_conv.is_owned = ptr_is_owned(a);
35006         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35007         a_conv.is_owned = false;
35008         LDKWarningMessage b_conv;
35009         b_conv.inner = untag_ptr(b);
35010         b_conv.is_owned = ptr_is_owned(b);
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35012         b_conv.is_owned = false;
35013         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
35014         return ret_conv;
35015 }
35016
35017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35018         LDKPing this_obj_conv;
35019         this_obj_conv.inner = untag_ptr(this_obj);
35020         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35022         Ping_free(this_obj_conv);
35023 }
35024
35025 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35026         LDKPing this_ptr_conv;
35027         this_ptr_conv.inner = untag_ptr(this_ptr);
35028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35030         this_ptr_conv.is_owned = false;
35031         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
35032         return ret_conv;
35033 }
35034
35035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35036         LDKPing this_ptr_conv;
35037         this_ptr_conv.inner = untag_ptr(this_ptr);
35038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35040         this_ptr_conv.is_owned = false;
35041         Ping_set_ponglen(&this_ptr_conv, val);
35042 }
35043
35044 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35045         LDKPing this_ptr_conv;
35046         this_ptr_conv.inner = untag_ptr(this_ptr);
35047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35049         this_ptr_conv.is_owned = false;
35050         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
35051         return ret_conv;
35052 }
35053
35054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35055         LDKPing this_ptr_conv;
35056         this_ptr_conv.inner = untag_ptr(this_ptr);
35057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35059         this_ptr_conv.is_owned = false;
35060         Ping_set_byteslen(&this_ptr_conv, val);
35061 }
35062
35063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
35064         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
35065         int64_t ret_ref = 0;
35066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35068         return ret_ref;
35069 }
35070
35071 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
35072         LDKPing ret_var = Ping_clone(arg);
35073         int64_t ret_ref = 0;
35074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35076         return ret_ref;
35077 }
35078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35079         LDKPing arg_conv;
35080         arg_conv.inner = untag_ptr(arg);
35081         arg_conv.is_owned = ptr_is_owned(arg);
35082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35083         arg_conv.is_owned = false;
35084         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
35085         return ret_conv;
35086 }
35087
35088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35089         LDKPing orig_conv;
35090         orig_conv.inner = untag_ptr(orig);
35091         orig_conv.is_owned = ptr_is_owned(orig);
35092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35093         orig_conv.is_owned = false;
35094         LDKPing ret_var = Ping_clone(&orig_conv);
35095         int64_t ret_ref = 0;
35096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35098         return ret_ref;
35099 }
35100
35101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35102         LDKPing a_conv;
35103         a_conv.inner = untag_ptr(a);
35104         a_conv.is_owned = ptr_is_owned(a);
35105         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35106         a_conv.is_owned = false;
35107         LDKPing b_conv;
35108         b_conv.inner = untag_ptr(b);
35109         b_conv.is_owned = ptr_is_owned(b);
35110         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35111         b_conv.is_owned = false;
35112         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
35113         return ret_conv;
35114 }
35115
35116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35117         LDKPong this_obj_conv;
35118         this_obj_conv.inner = untag_ptr(this_obj);
35119         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35121         Pong_free(this_obj_conv);
35122 }
35123
35124 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35125         LDKPong this_ptr_conv;
35126         this_ptr_conv.inner = untag_ptr(this_ptr);
35127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35129         this_ptr_conv.is_owned = false;
35130         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
35131         return ret_conv;
35132 }
35133
35134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35135         LDKPong this_ptr_conv;
35136         this_ptr_conv.inner = untag_ptr(this_ptr);
35137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35139         this_ptr_conv.is_owned = false;
35140         Pong_set_byteslen(&this_ptr_conv, val);
35141 }
35142
35143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
35144         LDKPong ret_var = Pong_new(byteslen_arg);
35145         int64_t ret_ref = 0;
35146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35148         return ret_ref;
35149 }
35150
35151 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
35152         LDKPong ret_var = Pong_clone(arg);
35153         int64_t ret_ref = 0;
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35156         return ret_ref;
35157 }
35158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35159         LDKPong arg_conv;
35160         arg_conv.inner = untag_ptr(arg);
35161         arg_conv.is_owned = ptr_is_owned(arg);
35162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35163         arg_conv.is_owned = false;
35164         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
35165         return ret_conv;
35166 }
35167
35168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35169         LDKPong orig_conv;
35170         orig_conv.inner = untag_ptr(orig);
35171         orig_conv.is_owned = ptr_is_owned(orig);
35172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35173         orig_conv.is_owned = false;
35174         LDKPong ret_var = Pong_clone(&orig_conv);
35175         int64_t ret_ref = 0;
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35178         return ret_ref;
35179 }
35180
35181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35182         LDKPong a_conv;
35183         a_conv.inner = untag_ptr(a);
35184         a_conv.is_owned = ptr_is_owned(a);
35185         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35186         a_conv.is_owned = false;
35187         LDKPong b_conv;
35188         b_conv.inner = untag_ptr(b);
35189         b_conv.is_owned = ptr_is_owned(b);
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35191         b_conv.is_owned = false;
35192         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
35193         return ret_conv;
35194 }
35195
35196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35197         LDKOpenChannel this_obj_conv;
35198         this_obj_conv.inner = untag_ptr(this_obj);
35199         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35201         OpenChannel_free(this_obj_conv);
35202 }
35203
35204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35205         LDKOpenChannel this_ptr_conv;
35206         this_ptr_conv.inner = untag_ptr(this_ptr);
35207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35209         this_ptr_conv.is_owned = false;
35210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
35212         return ret_arr;
35213 }
35214
35215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35216         LDKOpenChannel this_ptr_conv;
35217         this_ptr_conv.inner = untag_ptr(this_ptr);
35218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         this_ptr_conv.is_owned = false;
35221         LDKThirtyTwoBytes val_ref;
35222         CHECK((*env)->GetArrayLength(env, val) == 32);
35223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35224         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
35225 }
35226
35227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35228         LDKOpenChannel this_ptr_conv;
35229         this_ptr_conv.inner = untag_ptr(this_ptr);
35230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35232         this_ptr_conv.is_owned = false;
35233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
35235         return ret_arr;
35236 }
35237
35238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35239         LDKOpenChannel this_ptr_conv;
35240         this_ptr_conv.inner = untag_ptr(this_ptr);
35241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35243         this_ptr_conv.is_owned = false;
35244         LDKThirtyTwoBytes val_ref;
35245         CHECK((*env)->GetArrayLength(env, val) == 32);
35246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35247         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35248 }
35249
35250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35251         LDKOpenChannel this_ptr_conv;
35252         this_ptr_conv.inner = untag_ptr(this_ptr);
35253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35255         this_ptr_conv.is_owned = false;
35256         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
35257         return ret_conv;
35258 }
35259
35260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35261         LDKOpenChannel this_ptr_conv;
35262         this_ptr_conv.inner = untag_ptr(this_ptr);
35263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35265         this_ptr_conv.is_owned = false;
35266         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
35267 }
35268
35269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35270         LDKOpenChannel this_ptr_conv;
35271         this_ptr_conv.inner = untag_ptr(this_ptr);
35272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35274         this_ptr_conv.is_owned = false;
35275         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
35276         return ret_conv;
35277 }
35278
35279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35280         LDKOpenChannel this_ptr_conv;
35281         this_ptr_conv.inner = untag_ptr(this_ptr);
35282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35284         this_ptr_conv.is_owned = false;
35285         OpenChannel_set_push_msat(&this_ptr_conv, val);
35286 }
35287
35288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35289         LDKOpenChannel this_ptr_conv;
35290         this_ptr_conv.inner = untag_ptr(this_ptr);
35291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35293         this_ptr_conv.is_owned = false;
35294         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
35295         return ret_conv;
35296 }
35297
35298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35299         LDKOpenChannel this_ptr_conv;
35300         this_ptr_conv.inner = untag_ptr(this_ptr);
35301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35303         this_ptr_conv.is_owned = false;
35304         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35305 }
35306
35307 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) {
35308         LDKOpenChannel this_ptr_conv;
35309         this_ptr_conv.inner = untag_ptr(this_ptr);
35310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35312         this_ptr_conv.is_owned = false;
35313         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35314         return ret_conv;
35315 }
35316
35317 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) {
35318         LDKOpenChannel this_ptr_conv;
35319         this_ptr_conv.inner = untag_ptr(this_ptr);
35320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35322         this_ptr_conv.is_owned = false;
35323         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35324 }
35325
35326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35327         LDKOpenChannel this_ptr_conv;
35328         this_ptr_conv.inner = untag_ptr(this_ptr);
35329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35331         this_ptr_conv.is_owned = false;
35332         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35333         return ret_conv;
35334 }
35335
35336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35337         LDKOpenChannel this_ptr_conv;
35338         this_ptr_conv.inner = untag_ptr(this_ptr);
35339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35341         this_ptr_conv.is_owned = false;
35342         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35343 }
35344
35345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35346         LDKOpenChannel this_ptr_conv;
35347         this_ptr_conv.inner = untag_ptr(this_ptr);
35348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35350         this_ptr_conv.is_owned = false;
35351         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
35352         return ret_conv;
35353 }
35354
35355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35356         LDKOpenChannel this_ptr_conv;
35357         this_ptr_conv.inner = untag_ptr(this_ptr);
35358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35360         this_ptr_conv.is_owned = false;
35361         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35362 }
35363
35364 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35365         LDKOpenChannel this_ptr_conv;
35366         this_ptr_conv.inner = untag_ptr(this_ptr);
35367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35369         this_ptr_conv.is_owned = false;
35370         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
35371         return ret_conv;
35372 }
35373
35374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35375         LDKOpenChannel this_ptr_conv;
35376         this_ptr_conv.inner = untag_ptr(this_ptr);
35377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35379         this_ptr_conv.is_owned = false;
35380         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
35381 }
35382
35383 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35384         LDKOpenChannel this_ptr_conv;
35385         this_ptr_conv.inner = untag_ptr(this_ptr);
35386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35388         this_ptr_conv.is_owned = false;
35389         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
35390         return ret_conv;
35391 }
35392
35393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35394         LDKOpenChannel this_ptr_conv;
35395         this_ptr_conv.inner = untag_ptr(this_ptr);
35396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35398         this_ptr_conv.is_owned = false;
35399         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
35400 }
35401
35402 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35403         LDKOpenChannel this_ptr_conv;
35404         this_ptr_conv.inner = untag_ptr(this_ptr);
35405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35407         this_ptr_conv.is_owned = false;
35408         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
35409         return ret_conv;
35410 }
35411
35412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35413         LDKOpenChannel this_ptr_conv;
35414         this_ptr_conv.inner = untag_ptr(this_ptr);
35415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35417         this_ptr_conv.is_owned = false;
35418         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35419 }
35420
35421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35422         LDKOpenChannel this_ptr_conv;
35423         this_ptr_conv.inner = untag_ptr(this_ptr);
35424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35426         this_ptr_conv.is_owned = false;
35427         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35428         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35429         return ret_arr;
35430 }
35431
35432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35433         LDKOpenChannel this_ptr_conv;
35434         this_ptr_conv.inner = untag_ptr(this_ptr);
35435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35437         this_ptr_conv.is_owned = false;
35438         LDKPublicKey val_ref;
35439         CHECK((*env)->GetArrayLength(env, val) == 33);
35440         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35441         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35442 }
35443
35444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35445         LDKOpenChannel this_ptr_conv;
35446         this_ptr_conv.inner = untag_ptr(this_ptr);
35447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35449         this_ptr_conv.is_owned = false;
35450         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35452         return ret_arr;
35453 }
35454
35455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35456         LDKOpenChannel this_ptr_conv;
35457         this_ptr_conv.inner = untag_ptr(this_ptr);
35458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35460         this_ptr_conv.is_owned = false;
35461         LDKPublicKey val_ref;
35462         CHECK((*env)->GetArrayLength(env, val) == 33);
35463         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35464         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35465 }
35466
35467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35468         LDKOpenChannel this_ptr_conv;
35469         this_ptr_conv.inner = untag_ptr(this_ptr);
35470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35472         this_ptr_conv.is_owned = false;
35473         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35474         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
35475         return ret_arr;
35476 }
35477
35478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35479         LDKOpenChannel this_ptr_conv;
35480         this_ptr_conv.inner = untag_ptr(this_ptr);
35481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35483         this_ptr_conv.is_owned = false;
35484         LDKPublicKey val_ref;
35485         CHECK((*env)->GetArrayLength(env, val) == 33);
35486         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35487         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
35488 }
35489
35490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35491         LDKOpenChannel this_ptr_conv;
35492         this_ptr_conv.inner = untag_ptr(this_ptr);
35493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35495         this_ptr_conv.is_owned = false;
35496         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35497         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35498         return ret_arr;
35499 }
35500
35501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35502         LDKOpenChannel this_ptr_conv;
35503         this_ptr_conv.inner = untag_ptr(this_ptr);
35504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35506         this_ptr_conv.is_owned = false;
35507         LDKPublicKey val_ref;
35508         CHECK((*env)->GetArrayLength(env, val) == 33);
35509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35510         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35511 }
35512
35513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35514         LDKOpenChannel this_ptr_conv;
35515         this_ptr_conv.inner = untag_ptr(this_ptr);
35516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35518         this_ptr_conv.is_owned = false;
35519         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35521         return ret_arr;
35522 }
35523
35524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35525         LDKOpenChannel this_ptr_conv;
35526         this_ptr_conv.inner = untag_ptr(this_ptr);
35527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35529         this_ptr_conv.is_owned = false;
35530         LDKPublicKey val_ref;
35531         CHECK((*env)->GetArrayLength(env, val) == 33);
35532         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35533         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35534 }
35535
35536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35537         LDKOpenChannel this_ptr_conv;
35538         this_ptr_conv.inner = untag_ptr(this_ptr);
35539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35541         this_ptr_conv.is_owned = false;
35542         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35543         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35544         return ret_arr;
35545 }
35546
35547 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) {
35548         LDKOpenChannel this_ptr_conv;
35549         this_ptr_conv.inner = untag_ptr(this_ptr);
35550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35552         this_ptr_conv.is_owned = false;
35553         LDKPublicKey val_ref;
35554         CHECK((*env)->GetArrayLength(env, val) == 33);
35555         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35556         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35557 }
35558
35559 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35560         LDKOpenChannel this_ptr_conv;
35561         this_ptr_conv.inner = untag_ptr(this_ptr);
35562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35564         this_ptr_conv.is_owned = false;
35565         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
35566         return ret_conv;
35567 }
35568
35569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35570         LDKOpenChannel this_ptr_conv;
35571         this_ptr_conv.inner = untag_ptr(this_ptr);
35572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35574         this_ptr_conv.is_owned = false;
35575         OpenChannel_set_channel_flags(&this_ptr_conv, val);
35576 }
35577
35578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35579         LDKOpenChannel this_ptr_conv;
35580         this_ptr_conv.inner = untag_ptr(this_ptr);
35581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35583         this_ptr_conv.is_owned = false;
35584         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
35585         int64_t ret_ref = 0;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35588         return ret_ref;
35589 }
35590
35591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35592         LDKOpenChannel this_ptr_conv;
35593         this_ptr_conv.inner = untag_ptr(this_ptr);
35594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35596         this_ptr_conv.is_owned = false;
35597         LDKChannelTypeFeatures val_conv;
35598         val_conv.inner = untag_ptr(val);
35599         val_conv.is_owned = ptr_is_owned(val);
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35601         val_conv = ChannelTypeFeatures_clone(&val_conv);
35602         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
35603 }
35604
35605 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
35606         LDKOpenChannel ret_var = OpenChannel_clone(arg);
35607         int64_t ret_ref = 0;
35608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35610         return ret_ref;
35611 }
35612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35613         LDKOpenChannel arg_conv;
35614         arg_conv.inner = untag_ptr(arg);
35615         arg_conv.is_owned = ptr_is_owned(arg);
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35617         arg_conv.is_owned = false;
35618         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
35619         return ret_conv;
35620 }
35621
35622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35623         LDKOpenChannel orig_conv;
35624         orig_conv.inner = untag_ptr(orig);
35625         orig_conv.is_owned = ptr_is_owned(orig);
35626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35627         orig_conv.is_owned = false;
35628         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
35629         int64_t ret_ref = 0;
35630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35632         return ret_ref;
35633 }
35634
35635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35636         LDKOpenChannel a_conv;
35637         a_conv.inner = untag_ptr(a);
35638         a_conv.is_owned = ptr_is_owned(a);
35639         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35640         a_conv.is_owned = false;
35641         LDKOpenChannel b_conv;
35642         b_conv.inner = untag_ptr(b);
35643         b_conv.is_owned = ptr_is_owned(b);
35644         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35645         b_conv.is_owned = false;
35646         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
35647         return ret_conv;
35648 }
35649
35650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35651         LDKAcceptChannel this_obj_conv;
35652         this_obj_conv.inner = untag_ptr(this_obj);
35653         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35655         AcceptChannel_free(this_obj_conv);
35656 }
35657
35658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35659         LDKAcceptChannel this_ptr_conv;
35660         this_ptr_conv.inner = untag_ptr(this_ptr);
35661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35663         this_ptr_conv.is_owned = false;
35664         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35665         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
35666         return ret_arr;
35667 }
35668
35669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35670         LDKAcceptChannel this_ptr_conv;
35671         this_ptr_conv.inner = untag_ptr(this_ptr);
35672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35674         this_ptr_conv.is_owned = false;
35675         LDKThirtyTwoBytes val_ref;
35676         CHECK((*env)->GetArrayLength(env, val) == 32);
35677         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35678         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35679 }
35680
35681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35682         LDKAcceptChannel this_ptr_conv;
35683         this_ptr_conv.inner = untag_ptr(this_ptr);
35684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35686         this_ptr_conv.is_owned = false;
35687         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
35688         return ret_conv;
35689 }
35690
35691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35692         LDKAcceptChannel 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         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35698 }
35699
35700 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) {
35701         LDKAcceptChannel this_ptr_conv;
35702         this_ptr_conv.inner = untag_ptr(this_ptr);
35703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35705         this_ptr_conv.is_owned = false;
35706         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35707         return ret_conv;
35708 }
35709
35710 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) {
35711         LDKAcceptChannel this_ptr_conv;
35712         this_ptr_conv.inner = untag_ptr(this_ptr);
35713         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35715         this_ptr_conv.is_owned = false;
35716         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35717 }
35718
35719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35720         LDKAcceptChannel this_ptr_conv;
35721         this_ptr_conv.inner = untag_ptr(this_ptr);
35722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35724         this_ptr_conv.is_owned = false;
35725         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35726         return ret_conv;
35727 }
35728
35729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35730         LDKAcceptChannel this_ptr_conv;
35731         this_ptr_conv.inner = untag_ptr(this_ptr);
35732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35734         this_ptr_conv.is_owned = false;
35735         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35736 }
35737
35738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35739         LDKAcceptChannel this_ptr_conv;
35740         this_ptr_conv.inner = untag_ptr(this_ptr);
35741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35743         this_ptr_conv.is_owned = false;
35744         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
35745         return ret_conv;
35746 }
35747
35748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35749         LDKAcceptChannel this_ptr_conv;
35750         this_ptr_conv.inner = untag_ptr(this_ptr);
35751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35753         this_ptr_conv.is_owned = false;
35754         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35755 }
35756
35757 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35758         LDKAcceptChannel this_ptr_conv;
35759         this_ptr_conv.inner = untag_ptr(this_ptr);
35760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35762         this_ptr_conv.is_owned = false;
35763         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35764         return ret_conv;
35765 }
35766
35767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35768         LDKAcceptChannel this_ptr_conv;
35769         this_ptr_conv.inner = untag_ptr(this_ptr);
35770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35772         this_ptr_conv.is_owned = false;
35773         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35774 }
35775
35776 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35777         LDKAcceptChannel this_ptr_conv;
35778         this_ptr_conv.inner = untag_ptr(this_ptr);
35779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35781         this_ptr_conv.is_owned = false;
35782         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35783         return ret_conv;
35784 }
35785
35786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35787         LDKAcceptChannel this_ptr_conv;
35788         this_ptr_conv.inner = untag_ptr(this_ptr);
35789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35791         this_ptr_conv.is_owned = false;
35792         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35793 }
35794
35795 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35796         LDKAcceptChannel this_ptr_conv;
35797         this_ptr_conv.inner = untag_ptr(this_ptr);
35798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35800         this_ptr_conv.is_owned = false;
35801         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35802         return ret_conv;
35803 }
35804
35805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35806         LDKAcceptChannel this_ptr_conv;
35807         this_ptr_conv.inner = untag_ptr(this_ptr);
35808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35810         this_ptr_conv.is_owned = false;
35811         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35812 }
35813
35814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35815         LDKAcceptChannel this_ptr_conv;
35816         this_ptr_conv.inner = untag_ptr(this_ptr);
35817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35819         this_ptr_conv.is_owned = false;
35820         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35821         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35822         return ret_arr;
35823 }
35824
35825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35826         LDKAcceptChannel this_ptr_conv;
35827         this_ptr_conv.inner = untag_ptr(this_ptr);
35828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35830         this_ptr_conv.is_owned = false;
35831         LDKPublicKey val_ref;
35832         CHECK((*env)->GetArrayLength(env, val) == 33);
35833         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35834         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35835 }
35836
35837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35838         LDKAcceptChannel this_ptr_conv;
35839         this_ptr_conv.inner = untag_ptr(this_ptr);
35840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35842         this_ptr_conv.is_owned = false;
35843         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35844         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35845         return ret_arr;
35846 }
35847
35848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35849         LDKAcceptChannel this_ptr_conv;
35850         this_ptr_conv.inner = untag_ptr(this_ptr);
35851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35853         this_ptr_conv.is_owned = false;
35854         LDKPublicKey val_ref;
35855         CHECK((*env)->GetArrayLength(env, val) == 33);
35856         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35857         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35858 }
35859
35860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35861         LDKAcceptChannel this_ptr_conv;
35862         this_ptr_conv.inner = untag_ptr(this_ptr);
35863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35865         this_ptr_conv.is_owned = false;
35866         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35867         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35868         return ret_arr;
35869 }
35870
35871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35872         LDKAcceptChannel this_ptr_conv;
35873         this_ptr_conv.inner = untag_ptr(this_ptr);
35874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35876         this_ptr_conv.is_owned = false;
35877         LDKPublicKey val_ref;
35878         CHECK((*env)->GetArrayLength(env, val) == 33);
35879         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35880         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35881 }
35882
35883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35884         LDKAcceptChannel this_ptr_conv;
35885         this_ptr_conv.inner = untag_ptr(this_ptr);
35886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35888         this_ptr_conv.is_owned = false;
35889         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35891         return ret_arr;
35892 }
35893
35894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35895         LDKAcceptChannel this_ptr_conv;
35896         this_ptr_conv.inner = untag_ptr(this_ptr);
35897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35899         this_ptr_conv.is_owned = false;
35900         LDKPublicKey val_ref;
35901         CHECK((*env)->GetArrayLength(env, val) == 33);
35902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35903         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35904 }
35905
35906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35907         LDKAcceptChannel 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, 33);
35913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35914         return ret_arr;
35915 }
35916
35917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35918         LDKAcceptChannel 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         LDKPublicKey val_ref;
35924         CHECK((*env)->GetArrayLength(env, val) == 33);
35925         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35926         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35927 }
35928
35929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35930         LDKAcceptChannel 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35936         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35937         return ret_arr;
35938 }
35939
35940 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) {
35941         LDKAcceptChannel this_ptr_conv;
35942         this_ptr_conv.inner = untag_ptr(this_ptr);
35943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35945         this_ptr_conv.is_owned = false;
35946         LDKPublicKey val_ref;
35947         CHECK((*env)->GetArrayLength(env, val) == 33);
35948         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35949         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35950 }
35951
35952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35953         LDKAcceptChannel this_ptr_conv;
35954         this_ptr_conv.inner = untag_ptr(this_ptr);
35955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35957         this_ptr_conv.is_owned = false;
35958         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35959         int64_t ret_ref = 0;
35960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35962         return ret_ref;
35963 }
35964
35965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35966         LDKAcceptChannel this_ptr_conv;
35967         this_ptr_conv.inner = untag_ptr(this_ptr);
35968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35970         this_ptr_conv.is_owned = false;
35971         LDKChannelTypeFeatures val_conv;
35972         val_conv.inner = untag_ptr(val);
35973         val_conv.is_owned = ptr_is_owned(val);
35974         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35975         val_conv = ChannelTypeFeatures_clone(&val_conv);
35976         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35977 }
35978
35979 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35980         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35981         int64_t ret_ref = 0;
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35984         return ret_ref;
35985 }
35986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35987         LDKAcceptChannel arg_conv;
35988         arg_conv.inner = untag_ptr(arg);
35989         arg_conv.is_owned = ptr_is_owned(arg);
35990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35991         arg_conv.is_owned = false;
35992         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35993         return ret_conv;
35994 }
35995
35996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35997         LDKAcceptChannel orig_conv;
35998         orig_conv.inner = untag_ptr(orig);
35999         orig_conv.is_owned = ptr_is_owned(orig);
36000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36001         orig_conv.is_owned = false;
36002         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
36003         int64_t ret_ref = 0;
36004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36006         return ret_ref;
36007 }
36008
36009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36010         LDKAcceptChannel a_conv;
36011         a_conv.inner = untag_ptr(a);
36012         a_conv.is_owned = ptr_is_owned(a);
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36014         a_conv.is_owned = false;
36015         LDKAcceptChannel b_conv;
36016         b_conv.inner = untag_ptr(b);
36017         b_conv.is_owned = ptr_is_owned(b);
36018         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36019         b_conv.is_owned = false;
36020         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
36021         return ret_conv;
36022 }
36023
36024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36025         LDKFundingCreated this_obj_conv;
36026         this_obj_conv.inner = untag_ptr(this_obj);
36027         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36029         FundingCreated_free(this_obj_conv);
36030 }
36031
36032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36033         LDKFundingCreated this_ptr_conv;
36034         this_ptr_conv.inner = untag_ptr(this_ptr);
36035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36037         this_ptr_conv.is_owned = false;
36038         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
36040         return ret_arr;
36041 }
36042
36043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36044         LDKFundingCreated this_ptr_conv;
36045         this_ptr_conv.inner = untag_ptr(this_ptr);
36046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36048         this_ptr_conv.is_owned = false;
36049         LDKThirtyTwoBytes val_ref;
36050         CHECK((*env)->GetArrayLength(env, val) == 32);
36051         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36052         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
36053 }
36054
36055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
36056         LDKFundingCreated this_ptr_conv;
36057         this_ptr_conv.inner = untag_ptr(this_ptr);
36058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36060         this_ptr_conv.is_owned = false;
36061         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36062         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
36063         return ret_arr;
36064 }
36065
36066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36067         LDKFundingCreated this_ptr_conv;
36068         this_ptr_conv.inner = untag_ptr(this_ptr);
36069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36071         this_ptr_conv.is_owned = false;
36072         LDKThirtyTwoBytes val_ref;
36073         CHECK((*env)->GetArrayLength(env, val) == 32);
36074         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36075         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
36076 }
36077
36078 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36079         LDKFundingCreated this_ptr_conv;
36080         this_ptr_conv.inner = untag_ptr(this_ptr);
36081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36083         this_ptr_conv.is_owned = false;
36084         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
36085         return ret_conv;
36086 }
36087
36088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36089         LDKFundingCreated this_ptr_conv;
36090         this_ptr_conv.inner = untag_ptr(this_ptr);
36091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36093         this_ptr_conv.is_owned = false;
36094         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
36095 }
36096
36097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36098         LDKFundingCreated this_ptr_conv;
36099         this_ptr_conv.inner = untag_ptr(this_ptr);
36100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36102         this_ptr_conv.is_owned = false;
36103         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
36105         return ret_arr;
36106 }
36107
36108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36109         LDKFundingCreated this_ptr_conv;
36110         this_ptr_conv.inner = untag_ptr(this_ptr);
36111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36113         this_ptr_conv.is_owned = false;
36114         LDKSignature val_ref;
36115         CHECK((*env)->GetArrayLength(env, val) == 64);
36116         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36117         FundingCreated_set_signature(&this_ptr_conv, val_ref);
36118 }
36119
36120 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) {
36121         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
36122         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
36123         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
36124         LDKThirtyTwoBytes funding_txid_arg_ref;
36125         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
36126         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
36127         LDKSignature signature_arg_ref;
36128         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36129         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36130         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
36131         int64_t ret_ref = 0;
36132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36134         return ret_ref;
36135 }
36136
36137 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
36138         LDKFundingCreated ret_var = FundingCreated_clone(arg);
36139         int64_t ret_ref = 0;
36140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36142         return ret_ref;
36143 }
36144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36145         LDKFundingCreated arg_conv;
36146         arg_conv.inner = untag_ptr(arg);
36147         arg_conv.is_owned = ptr_is_owned(arg);
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36149         arg_conv.is_owned = false;
36150         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
36151         return ret_conv;
36152 }
36153
36154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36155         LDKFundingCreated orig_conv;
36156         orig_conv.inner = untag_ptr(orig);
36157         orig_conv.is_owned = ptr_is_owned(orig);
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36159         orig_conv.is_owned = false;
36160         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
36161         int64_t ret_ref = 0;
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36163         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36164         return ret_ref;
36165 }
36166
36167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36168         LDKFundingCreated a_conv;
36169         a_conv.inner = untag_ptr(a);
36170         a_conv.is_owned = ptr_is_owned(a);
36171         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36172         a_conv.is_owned = false;
36173         LDKFundingCreated b_conv;
36174         b_conv.inner = untag_ptr(b);
36175         b_conv.is_owned = ptr_is_owned(b);
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36177         b_conv.is_owned = false;
36178         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
36179         return ret_conv;
36180 }
36181
36182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36183         LDKFundingSigned this_obj_conv;
36184         this_obj_conv.inner = untag_ptr(this_obj);
36185         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36187         FundingSigned_free(this_obj_conv);
36188 }
36189
36190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36191         LDKFundingSigned this_ptr_conv;
36192         this_ptr_conv.inner = untag_ptr(this_ptr);
36193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36195         this_ptr_conv.is_owned = false;
36196         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
36198         return ret_arr;
36199 }
36200
36201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36202         LDKFundingSigned this_ptr_conv;
36203         this_ptr_conv.inner = untag_ptr(this_ptr);
36204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36206         this_ptr_conv.is_owned = false;
36207         LDKThirtyTwoBytes val_ref;
36208         CHECK((*env)->GetArrayLength(env, val) == 32);
36209         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36210         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
36211 }
36212
36213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36214         LDKFundingSigned this_ptr_conv;
36215         this_ptr_conv.inner = untag_ptr(this_ptr);
36216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36218         this_ptr_conv.is_owned = false;
36219         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
36221         return ret_arr;
36222 }
36223
36224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36225         LDKFundingSigned this_ptr_conv;
36226         this_ptr_conv.inner = untag_ptr(this_ptr);
36227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36229         this_ptr_conv.is_owned = false;
36230         LDKSignature val_ref;
36231         CHECK((*env)->GetArrayLength(env, val) == 64);
36232         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36233         FundingSigned_set_signature(&this_ptr_conv, val_ref);
36234 }
36235
36236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
36237         LDKThirtyTwoBytes channel_id_arg_ref;
36238         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36239         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36240         LDKSignature signature_arg_ref;
36241         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36242         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36243         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
36244         int64_t ret_ref = 0;
36245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36247         return ret_ref;
36248 }
36249
36250 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
36251         LDKFundingSigned ret_var = FundingSigned_clone(arg);
36252         int64_t ret_ref = 0;
36253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36255         return ret_ref;
36256 }
36257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36258         LDKFundingSigned arg_conv;
36259         arg_conv.inner = untag_ptr(arg);
36260         arg_conv.is_owned = ptr_is_owned(arg);
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36262         arg_conv.is_owned = false;
36263         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
36264         return ret_conv;
36265 }
36266
36267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36268         LDKFundingSigned orig_conv;
36269         orig_conv.inner = untag_ptr(orig);
36270         orig_conv.is_owned = ptr_is_owned(orig);
36271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36272         orig_conv.is_owned = false;
36273         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
36274         int64_t ret_ref = 0;
36275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36277         return ret_ref;
36278 }
36279
36280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36281         LDKFundingSigned a_conv;
36282         a_conv.inner = untag_ptr(a);
36283         a_conv.is_owned = ptr_is_owned(a);
36284         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36285         a_conv.is_owned = false;
36286         LDKFundingSigned b_conv;
36287         b_conv.inner = untag_ptr(b);
36288         b_conv.is_owned = ptr_is_owned(b);
36289         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36290         b_conv.is_owned = false;
36291         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
36292         return ret_conv;
36293 }
36294
36295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36296         LDKChannelReady this_obj_conv;
36297         this_obj_conv.inner = untag_ptr(this_obj);
36298         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36300         ChannelReady_free(this_obj_conv);
36301 }
36302
36303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36304         LDKChannelReady this_ptr_conv;
36305         this_ptr_conv.inner = untag_ptr(this_ptr);
36306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36308         this_ptr_conv.is_owned = false;
36309         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
36311         return ret_arr;
36312 }
36313
36314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36315         LDKChannelReady this_ptr_conv;
36316         this_ptr_conv.inner = untag_ptr(this_ptr);
36317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36319         this_ptr_conv.is_owned = false;
36320         LDKThirtyTwoBytes val_ref;
36321         CHECK((*env)->GetArrayLength(env, val) == 32);
36322         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36323         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
36324 }
36325
36326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36327         LDKChannelReady this_ptr_conv;
36328         this_ptr_conv.inner = untag_ptr(this_ptr);
36329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36331         this_ptr_conv.is_owned = false;
36332         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36334         return ret_arr;
36335 }
36336
36337 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) {
36338         LDKChannelReady this_ptr_conv;
36339         this_ptr_conv.inner = untag_ptr(this_ptr);
36340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36342         this_ptr_conv.is_owned = false;
36343         LDKPublicKey val_ref;
36344         CHECK((*env)->GetArrayLength(env, val) == 33);
36345         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36346         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36347 }
36348
36349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36350         LDKChannelReady this_ptr_conv;
36351         this_ptr_conv.inner = untag_ptr(this_ptr);
36352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36354         this_ptr_conv.is_owned = false;
36355         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36356         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
36357         int64_t ret_ref = tag_ptr(ret_copy, true);
36358         return ret_ref;
36359 }
36360
36361 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) {
36362         LDKChannelReady this_ptr_conv;
36363         this_ptr_conv.inner = untag_ptr(this_ptr);
36364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36366         this_ptr_conv.is_owned = false;
36367         void* val_ptr = untag_ptr(val);
36368         CHECK_ACCESS(val_ptr);
36369         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36370         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
36371         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
36372 }
36373
36374 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) {
36375         LDKThirtyTwoBytes channel_id_arg_ref;
36376         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36377         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36378         LDKPublicKey next_per_commitment_point_arg_ref;
36379         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36380         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36381         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
36382         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
36383         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
36384         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
36385         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
36386         int64_t ret_ref = 0;
36387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36389         return ret_ref;
36390 }
36391
36392 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
36393         LDKChannelReady ret_var = ChannelReady_clone(arg);
36394         int64_t ret_ref = 0;
36395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36397         return ret_ref;
36398 }
36399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36400         LDKChannelReady arg_conv;
36401         arg_conv.inner = untag_ptr(arg);
36402         arg_conv.is_owned = ptr_is_owned(arg);
36403         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36404         arg_conv.is_owned = false;
36405         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
36406         return ret_conv;
36407 }
36408
36409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36410         LDKChannelReady orig_conv;
36411         orig_conv.inner = untag_ptr(orig);
36412         orig_conv.is_owned = ptr_is_owned(orig);
36413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36414         orig_conv.is_owned = false;
36415         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
36416         int64_t ret_ref = 0;
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36419         return ret_ref;
36420 }
36421
36422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36423         LDKChannelReady a_conv;
36424         a_conv.inner = untag_ptr(a);
36425         a_conv.is_owned = ptr_is_owned(a);
36426         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36427         a_conv.is_owned = false;
36428         LDKChannelReady b_conv;
36429         b_conv.inner = untag_ptr(b);
36430         b_conv.is_owned = ptr_is_owned(b);
36431         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36432         b_conv.is_owned = false;
36433         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
36434         return ret_conv;
36435 }
36436
36437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36438         LDKShutdown this_obj_conv;
36439         this_obj_conv.inner = untag_ptr(this_obj);
36440         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36442         Shutdown_free(this_obj_conv);
36443 }
36444
36445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36446         LDKShutdown 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
36453         return ret_arr;
36454 }
36455
36456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36457         LDKShutdown this_ptr_conv;
36458         this_ptr_conv.inner = untag_ptr(this_ptr);
36459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36461         this_ptr_conv.is_owned = false;
36462         LDKThirtyTwoBytes val_ref;
36463         CHECK((*env)->GetArrayLength(env, val) == 32);
36464         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36465         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
36466 }
36467
36468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36469         LDKShutdown this_ptr_conv;
36470         this_ptr_conv.inner = untag_ptr(this_ptr);
36471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36473         this_ptr_conv.is_owned = false;
36474         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
36475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36477         return ret_arr;
36478 }
36479
36480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36481         LDKShutdown this_ptr_conv;
36482         this_ptr_conv.inner = untag_ptr(this_ptr);
36483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36485         this_ptr_conv.is_owned = false;
36486         LDKCVec_u8Z val_ref;
36487         val_ref.datalen = (*env)->GetArrayLength(env, val);
36488         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36489         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36490         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
36491 }
36492
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
36494         LDKThirtyTwoBytes channel_id_arg_ref;
36495         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36496         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36497         LDKCVec_u8Z scriptpubkey_arg_ref;
36498         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
36499         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36500         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
36501         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
36502         int64_t ret_ref = 0;
36503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36505         return ret_ref;
36506 }
36507
36508 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
36509         LDKShutdown ret_var = Shutdown_clone(arg);
36510         int64_t ret_ref = 0;
36511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36513         return ret_ref;
36514 }
36515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36516         LDKShutdown arg_conv;
36517         arg_conv.inner = untag_ptr(arg);
36518         arg_conv.is_owned = ptr_is_owned(arg);
36519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36520         arg_conv.is_owned = false;
36521         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
36522         return ret_conv;
36523 }
36524
36525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36526         LDKShutdown orig_conv;
36527         orig_conv.inner = untag_ptr(orig);
36528         orig_conv.is_owned = ptr_is_owned(orig);
36529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36530         orig_conv.is_owned = false;
36531         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
36532         int64_t ret_ref = 0;
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36535         return ret_ref;
36536 }
36537
36538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36539         LDKShutdown a_conv;
36540         a_conv.inner = untag_ptr(a);
36541         a_conv.is_owned = ptr_is_owned(a);
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36543         a_conv.is_owned = false;
36544         LDKShutdown b_conv;
36545         b_conv.inner = untag_ptr(b);
36546         b_conv.is_owned = ptr_is_owned(b);
36547         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36548         b_conv.is_owned = false;
36549         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
36550         return ret_conv;
36551 }
36552
36553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36554         LDKClosingSignedFeeRange this_obj_conv;
36555         this_obj_conv.inner = untag_ptr(this_obj);
36556         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36558         ClosingSignedFeeRange_free(this_obj_conv);
36559 }
36560
36561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36562         LDKClosingSignedFeeRange this_ptr_conv;
36563         this_ptr_conv.inner = untag_ptr(this_ptr);
36564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36566         this_ptr_conv.is_owned = false;
36567         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
36568         return ret_conv;
36569 }
36570
36571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36572         LDKClosingSignedFeeRange 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         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
36578 }
36579
36580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36581         LDKClosingSignedFeeRange this_ptr_conv;
36582         this_ptr_conv.inner = untag_ptr(this_ptr);
36583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36585         this_ptr_conv.is_owned = false;
36586         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
36587         return ret_conv;
36588 }
36589
36590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36591         LDKClosingSignedFeeRange this_ptr_conv;
36592         this_ptr_conv.inner = untag_ptr(this_ptr);
36593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36595         this_ptr_conv.is_owned = false;
36596         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
36597 }
36598
36599 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) {
36600         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
36601         int64_t ret_ref = 0;
36602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36604         return ret_ref;
36605 }
36606
36607 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
36608         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
36609         int64_t ret_ref = 0;
36610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36612         return ret_ref;
36613 }
36614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36615         LDKClosingSignedFeeRange arg_conv;
36616         arg_conv.inner = untag_ptr(arg);
36617         arg_conv.is_owned = ptr_is_owned(arg);
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36619         arg_conv.is_owned = false;
36620         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
36621         return ret_conv;
36622 }
36623
36624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36625         LDKClosingSignedFeeRange orig_conv;
36626         orig_conv.inner = untag_ptr(orig);
36627         orig_conv.is_owned = ptr_is_owned(orig);
36628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36629         orig_conv.is_owned = false;
36630         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
36631         int64_t ret_ref = 0;
36632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36634         return ret_ref;
36635 }
36636
36637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36638         LDKClosingSignedFeeRange a_conv;
36639         a_conv.inner = untag_ptr(a);
36640         a_conv.is_owned = ptr_is_owned(a);
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36642         a_conv.is_owned = false;
36643         LDKClosingSignedFeeRange b_conv;
36644         b_conv.inner = untag_ptr(b);
36645         b_conv.is_owned = ptr_is_owned(b);
36646         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36647         b_conv.is_owned = false;
36648         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
36649         return ret_conv;
36650 }
36651
36652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36653         LDKClosingSigned this_obj_conv;
36654         this_obj_conv.inner = untag_ptr(this_obj);
36655         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36657         ClosingSigned_free(this_obj_conv);
36658 }
36659
36660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36661         LDKClosingSigned this_ptr_conv;
36662         this_ptr_conv.inner = untag_ptr(this_ptr);
36663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36665         this_ptr_conv.is_owned = false;
36666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
36668         return ret_arr;
36669 }
36670
36671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36672         LDKClosingSigned this_ptr_conv;
36673         this_ptr_conv.inner = untag_ptr(this_ptr);
36674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36676         this_ptr_conv.is_owned = false;
36677         LDKThirtyTwoBytes val_ref;
36678         CHECK((*env)->GetArrayLength(env, val) == 32);
36679         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36680         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
36681 }
36682
36683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36684         LDKClosingSigned this_ptr_conv;
36685         this_ptr_conv.inner = untag_ptr(this_ptr);
36686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36688         this_ptr_conv.is_owned = false;
36689         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
36690         return ret_conv;
36691 }
36692
36693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36694         LDKClosingSigned this_ptr_conv;
36695         this_ptr_conv.inner = untag_ptr(this_ptr);
36696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36698         this_ptr_conv.is_owned = false;
36699         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
36700 }
36701
36702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36703         LDKClosingSigned this_ptr_conv;
36704         this_ptr_conv.inner = untag_ptr(this_ptr);
36705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36707         this_ptr_conv.is_owned = false;
36708         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
36710         return ret_arr;
36711 }
36712
36713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36714         LDKClosingSigned this_ptr_conv;
36715         this_ptr_conv.inner = untag_ptr(this_ptr);
36716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36718         this_ptr_conv.is_owned = false;
36719         LDKSignature val_ref;
36720         CHECK((*env)->GetArrayLength(env, val) == 64);
36721         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36722         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
36723 }
36724
36725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36726         LDKClosingSigned this_ptr_conv;
36727         this_ptr_conv.inner = untag_ptr(this_ptr);
36728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36730         this_ptr_conv.is_owned = false;
36731         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
36732         int64_t ret_ref = 0;
36733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36735         return ret_ref;
36736 }
36737
36738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36739         LDKClosingSigned this_ptr_conv;
36740         this_ptr_conv.inner = untag_ptr(this_ptr);
36741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36743         this_ptr_conv.is_owned = false;
36744         LDKClosingSignedFeeRange val_conv;
36745         val_conv.inner = untag_ptr(val);
36746         val_conv.is_owned = ptr_is_owned(val);
36747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36748         val_conv = ClosingSignedFeeRange_clone(&val_conv);
36749         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
36750 }
36751
36752 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) {
36753         LDKThirtyTwoBytes channel_id_arg_ref;
36754         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36755         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36756         LDKSignature signature_arg_ref;
36757         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36758         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36759         LDKClosingSignedFeeRange fee_range_arg_conv;
36760         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36761         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36763         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36764         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36765         int64_t ret_ref = 0;
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36768         return ret_ref;
36769 }
36770
36771 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36772         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36773         int64_t ret_ref = 0;
36774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36776         return ret_ref;
36777 }
36778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36779         LDKClosingSigned arg_conv;
36780         arg_conv.inner = untag_ptr(arg);
36781         arg_conv.is_owned = ptr_is_owned(arg);
36782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36783         arg_conv.is_owned = false;
36784         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36785         return ret_conv;
36786 }
36787
36788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36789         LDKClosingSigned orig_conv;
36790         orig_conv.inner = untag_ptr(orig);
36791         orig_conv.is_owned = ptr_is_owned(orig);
36792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36793         orig_conv.is_owned = false;
36794         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36795         int64_t ret_ref = 0;
36796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36798         return ret_ref;
36799 }
36800
36801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36802         LDKClosingSigned a_conv;
36803         a_conv.inner = untag_ptr(a);
36804         a_conv.is_owned = ptr_is_owned(a);
36805         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36806         a_conv.is_owned = false;
36807         LDKClosingSigned b_conv;
36808         b_conv.inner = untag_ptr(b);
36809         b_conv.is_owned = ptr_is_owned(b);
36810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36811         b_conv.is_owned = false;
36812         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36813         return ret_conv;
36814 }
36815
36816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36817         LDKUpdateAddHTLC this_obj_conv;
36818         this_obj_conv.inner = untag_ptr(this_obj);
36819         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36821         UpdateAddHTLC_free(this_obj_conv);
36822 }
36823
36824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36825         LDKUpdateAddHTLC this_ptr_conv;
36826         this_ptr_conv.inner = untag_ptr(this_ptr);
36827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36829         this_ptr_conv.is_owned = false;
36830         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36832         return ret_arr;
36833 }
36834
36835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36836         LDKUpdateAddHTLC this_ptr_conv;
36837         this_ptr_conv.inner = untag_ptr(this_ptr);
36838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36840         this_ptr_conv.is_owned = false;
36841         LDKThirtyTwoBytes val_ref;
36842         CHECK((*env)->GetArrayLength(env, val) == 32);
36843         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36844         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36845 }
36846
36847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36848         LDKUpdateAddHTLC this_ptr_conv;
36849         this_ptr_conv.inner = untag_ptr(this_ptr);
36850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36852         this_ptr_conv.is_owned = false;
36853         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36854         return ret_conv;
36855 }
36856
36857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36858         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36864 }
36865
36866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36867         LDKUpdateAddHTLC this_ptr_conv;
36868         this_ptr_conv.inner = untag_ptr(this_ptr);
36869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36871         this_ptr_conv.is_owned = false;
36872         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36873         return ret_conv;
36874 }
36875
36876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36877         LDKUpdateAddHTLC this_ptr_conv;
36878         this_ptr_conv.inner = untag_ptr(this_ptr);
36879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36881         this_ptr_conv.is_owned = false;
36882         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36883 }
36884
36885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36886         LDKUpdateAddHTLC this_ptr_conv;
36887         this_ptr_conv.inner = untag_ptr(this_ptr);
36888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36890         this_ptr_conv.is_owned = false;
36891         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36893         return ret_arr;
36894 }
36895
36896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36897         LDKUpdateAddHTLC this_ptr_conv;
36898         this_ptr_conv.inner = untag_ptr(this_ptr);
36899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36901         this_ptr_conv.is_owned = false;
36902         LDKThirtyTwoBytes val_ref;
36903         CHECK((*env)->GetArrayLength(env, val) == 32);
36904         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36905         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36906 }
36907
36908 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36909         LDKUpdateAddHTLC this_ptr_conv;
36910         this_ptr_conv.inner = untag_ptr(this_ptr);
36911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36913         this_ptr_conv.is_owned = false;
36914         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36915         return ret_conv;
36916 }
36917
36918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36919         LDKUpdateAddHTLC this_ptr_conv;
36920         this_ptr_conv.inner = untag_ptr(this_ptr);
36921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36923         this_ptr_conv.is_owned = false;
36924         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36925 }
36926
36927 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36928         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36929         int64_t ret_ref = 0;
36930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36932         return ret_ref;
36933 }
36934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36935         LDKUpdateAddHTLC arg_conv;
36936         arg_conv.inner = untag_ptr(arg);
36937         arg_conv.is_owned = ptr_is_owned(arg);
36938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36939         arg_conv.is_owned = false;
36940         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36941         return ret_conv;
36942 }
36943
36944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36945         LDKUpdateAddHTLC orig_conv;
36946         orig_conv.inner = untag_ptr(orig);
36947         orig_conv.is_owned = ptr_is_owned(orig);
36948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36949         orig_conv.is_owned = false;
36950         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36951         int64_t ret_ref = 0;
36952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36954         return ret_ref;
36955 }
36956
36957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36958         LDKUpdateAddHTLC a_conv;
36959         a_conv.inner = untag_ptr(a);
36960         a_conv.is_owned = ptr_is_owned(a);
36961         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36962         a_conv.is_owned = false;
36963         LDKUpdateAddHTLC b_conv;
36964         b_conv.inner = untag_ptr(b);
36965         b_conv.is_owned = ptr_is_owned(b);
36966         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36967         b_conv.is_owned = false;
36968         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36969         return ret_conv;
36970 }
36971
36972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36973         LDKOnionMessage this_obj_conv;
36974         this_obj_conv.inner = untag_ptr(this_obj);
36975         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36977         OnionMessage_free(this_obj_conv);
36978 }
36979
36980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36981         LDKOnionMessage this_ptr_conv;
36982         this_ptr_conv.inner = untag_ptr(this_ptr);
36983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36985         this_ptr_conv.is_owned = false;
36986         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36988         return ret_arr;
36989 }
36990
36991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36992         LDKOnionMessage this_ptr_conv;
36993         this_ptr_conv.inner = untag_ptr(this_ptr);
36994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36996         this_ptr_conv.is_owned = false;
36997         LDKPublicKey val_ref;
36998         CHECK((*env)->GetArrayLength(env, val) == 33);
36999         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37000         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
37001 }
37002
37003 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
37004         LDKOnionMessage ret_var = OnionMessage_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_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37011         LDKOnionMessage 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 = OnionMessage_clone_ptr(&arg_conv);
37017         return ret_conv;
37018 }
37019
37020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37021         LDKOnionMessage 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         LDKOnionMessage ret_var = OnionMessage_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_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37034         LDKOnionMessage 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         LDKOnionMessage 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 = OnionMessage_eq(&a_conv, &b_conv);
37045         return ret_conv;
37046 }
37047
37048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37049         LDKUpdateFulfillHTLC 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         UpdateFulfillHTLC_free(this_obj_conv);
37054 }
37055
37056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37057         LDKUpdateFulfillHTLC 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, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
37064         return ret_arr;
37065 }
37066
37067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37068         LDKUpdateFulfillHTLC 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         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
37077 }
37078
37079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37080         LDKUpdateFulfillHTLC 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         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
37086         return ret_conv;
37087 }
37088
37089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37090         LDKUpdateFulfillHTLC this_ptr_conv;
37091         this_ptr_conv.inner = untag_ptr(this_ptr);
37092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37094         this_ptr_conv.is_owned = false;
37095         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
37096 }
37097
37098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
37099         LDKUpdateFulfillHTLC this_ptr_conv;
37100         this_ptr_conv.inner = untag_ptr(this_ptr);
37101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37103         this_ptr_conv.is_owned = false;
37104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
37106         return ret_arr;
37107 }
37108
37109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37110         LDKUpdateFulfillHTLC this_ptr_conv;
37111         this_ptr_conv.inner = untag_ptr(this_ptr);
37112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37114         this_ptr_conv.is_owned = false;
37115         LDKThirtyTwoBytes val_ref;
37116         CHECK((*env)->GetArrayLength(env, val) == 32);
37117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37118         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
37119 }
37120
37121 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) {
37122         LDKThirtyTwoBytes channel_id_arg_ref;
37123         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37124         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37125         LDKThirtyTwoBytes payment_preimage_arg_ref;
37126         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
37127         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
37128         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
37129         int64_t ret_ref = 0;
37130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37132         return ret_ref;
37133 }
37134
37135 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
37136         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
37137         int64_t ret_ref = 0;
37138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37140         return ret_ref;
37141 }
37142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37143         LDKUpdateFulfillHTLC arg_conv;
37144         arg_conv.inner = untag_ptr(arg);
37145         arg_conv.is_owned = ptr_is_owned(arg);
37146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37147         arg_conv.is_owned = false;
37148         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
37149         return ret_conv;
37150 }
37151
37152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37153         LDKUpdateFulfillHTLC orig_conv;
37154         orig_conv.inner = untag_ptr(orig);
37155         orig_conv.is_owned = ptr_is_owned(orig);
37156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37157         orig_conv.is_owned = false;
37158         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
37159         int64_t ret_ref = 0;
37160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37162         return ret_ref;
37163 }
37164
37165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37166         LDKUpdateFulfillHTLC a_conv;
37167         a_conv.inner = untag_ptr(a);
37168         a_conv.is_owned = ptr_is_owned(a);
37169         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37170         a_conv.is_owned = false;
37171         LDKUpdateFulfillHTLC b_conv;
37172         b_conv.inner = untag_ptr(b);
37173         b_conv.is_owned = ptr_is_owned(b);
37174         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37175         b_conv.is_owned = false;
37176         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
37177         return ret_conv;
37178 }
37179
37180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37181         LDKUpdateFailHTLC this_obj_conv;
37182         this_obj_conv.inner = untag_ptr(this_obj);
37183         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37185         UpdateFailHTLC_free(this_obj_conv);
37186 }
37187
37188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37189         LDKUpdateFailHTLC this_ptr_conv;
37190         this_ptr_conv.inner = untag_ptr(this_ptr);
37191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37193         this_ptr_conv.is_owned = false;
37194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
37196         return ret_arr;
37197 }
37198
37199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37200         LDKUpdateFailHTLC this_ptr_conv;
37201         this_ptr_conv.inner = untag_ptr(this_ptr);
37202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37204         this_ptr_conv.is_owned = false;
37205         LDKThirtyTwoBytes val_ref;
37206         CHECK((*env)->GetArrayLength(env, val) == 32);
37207         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37208         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
37209 }
37210
37211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37212         LDKUpdateFailHTLC 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 = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
37218         return ret_conv;
37219 }
37220
37221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37222         LDKUpdateFailHTLC 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         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
37228 }
37229
37230 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
37231         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_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_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37238         LDKUpdateFailHTLC 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 = UpdateFailHTLC_clone_ptr(&arg_conv);
37244         return ret_conv;
37245 }
37246
37247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37248         LDKUpdateFailHTLC 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         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_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_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37261         LDKUpdateFailHTLC 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         LDKUpdateFailHTLC 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 = UpdateFailHTLC_eq(&a_conv, &b_conv);
37272         return ret_conv;
37273 }
37274
37275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37276         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_free(this_obj_conv);
37281 }
37282
37283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37284         LDKUpdateFailMalformedHTLC 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, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
37291         return ret_arr;
37292 }
37293
37294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37295         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
37304 }
37305
37306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37307         LDKUpdateFailMalformedHTLC 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 = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
37313         return ret_conv;
37314 }
37315
37316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37317         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
37323 }
37324
37325 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
37326         LDKUpdateFailMalformedHTLC 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         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
37332         return ret_conv;
37333 }
37334
37335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37336         LDKUpdateFailMalformedHTLC this_ptr_conv;
37337         this_ptr_conv.inner = untag_ptr(this_ptr);
37338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37340         this_ptr_conv.is_owned = false;
37341         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
37342 }
37343
37344 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
37345         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
37346         int64_t ret_ref = 0;
37347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37349         return ret_ref;
37350 }
37351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37352         LDKUpdateFailMalformedHTLC arg_conv;
37353         arg_conv.inner = untag_ptr(arg);
37354         arg_conv.is_owned = ptr_is_owned(arg);
37355         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37356         arg_conv.is_owned = false;
37357         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
37358         return ret_conv;
37359 }
37360
37361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37362         LDKUpdateFailMalformedHTLC orig_conv;
37363         orig_conv.inner = untag_ptr(orig);
37364         orig_conv.is_owned = ptr_is_owned(orig);
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37366         orig_conv.is_owned = false;
37367         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
37368         int64_t ret_ref = 0;
37369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37371         return ret_ref;
37372 }
37373
37374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37375         LDKUpdateFailMalformedHTLC a_conv;
37376         a_conv.inner = untag_ptr(a);
37377         a_conv.is_owned = ptr_is_owned(a);
37378         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37379         a_conv.is_owned = false;
37380         LDKUpdateFailMalformedHTLC b_conv;
37381         b_conv.inner = untag_ptr(b);
37382         b_conv.is_owned = ptr_is_owned(b);
37383         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37384         b_conv.is_owned = false;
37385         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
37386         return ret_conv;
37387 }
37388
37389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37390         LDKCommitmentSigned this_obj_conv;
37391         this_obj_conv.inner = untag_ptr(this_obj);
37392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37394         CommitmentSigned_free(this_obj_conv);
37395 }
37396
37397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37398         LDKCommitmentSigned this_ptr_conv;
37399         this_ptr_conv.inner = untag_ptr(this_ptr);
37400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37402         this_ptr_conv.is_owned = false;
37403         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
37405         return ret_arr;
37406 }
37407
37408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37409         LDKCommitmentSigned this_ptr_conv;
37410         this_ptr_conv.inner = untag_ptr(this_ptr);
37411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37413         this_ptr_conv.is_owned = false;
37414         LDKThirtyTwoBytes val_ref;
37415         CHECK((*env)->GetArrayLength(env, val) == 32);
37416         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37417         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
37418 }
37419
37420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37421         LDKCommitmentSigned this_ptr_conv;
37422         this_ptr_conv.inner = untag_ptr(this_ptr);
37423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37425         this_ptr_conv.is_owned = false;
37426         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
37428         return ret_arr;
37429 }
37430
37431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37432         LDKCommitmentSigned this_ptr_conv;
37433         this_ptr_conv.inner = untag_ptr(this_ptr);
37434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37436         this_ptr_conv.is_owned = false;
37437         LDKSignature val_ref;
37438         CHECK((*env)->GetArrayLength(env, val) == 64);
37439         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37440         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
37441 }
37442
37443 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
37444         LDKCommitmentSigned this_ptr_conv;
37445         this_ptr_conv.inner = untag_ptr(this_ptr);
37446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37448         this_ptr_conv.is_owned = false;
37449         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
37450         jobjectArray ret_arr = NULL;
37451         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37452         ;
37453         for (size_t i = 0; i < ret_var.datalen; i++) {
37454                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
37455                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
37456                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37457         }
37458         
37459         FREE(ret_var.data);
37460         return ret_arr;
37461 }
37462
37463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37464         LDKCommitmentSigned this_ptr_conv;
37465         this_ptr_conv.inner = untag_ptr(this_ptr);
37466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37468         this_ptr_conv.is_owned = false;
37469         LDKCVec_SignatureZ val_constr;
37470         val_constr.datalen = (*env)->GetArrayLength(env, val);
37471         if (val_constr.datalen > 0)
37472                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37473         else
37474                 val_constr.data = NULL;
37475         for (size_t i = 0; i < val_constr.datalen; i++) {
37476                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37477                 LDKSignature val_conv_8_ref;
37478                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37479                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37480                 val_constr.data[i] = val_conv_8_ref;
37481         }
37482         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
37483 }
37484
37485 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) {
37486         LDKThirtyTwoBytes channel_id_arg_ref;
37487         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37488         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37489         LDKSignature signature_arg_ref;
37490         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37491         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37492         LDKCVec_SignatureZ htlc_signatures_arg_constr;
37493         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
37494         if (htlc_signatures_arg_constr.datalen > 0)
37495                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37496         else
37497                 htlc_signatures_arg_constr.data = NULL;
37498         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
37499                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
37500                 LDKSignature htlc_signatures_arg_conv_8_ref;
37501                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
37502                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
37503                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
37504         }
37505         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
37506         int64_t ret_ref = 0;
37507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37509         return ret_ref;
37510 }
37511
37512 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
37513         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
37514         int64_t ret_ref = 0;
37515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37517         return ret_ref;
37518 }
37519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37520         LDKCommitmentSigned arg_conv;
37521         arg_conv.inner = untag_ptr(arg);
37522         arg_conv.is_owned = ptr_is_owned(arg);
37523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37524         arg_conv.is_owned = false;
37525         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
37526         return ret_conv;
37527 }
37528
37529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37530         LDKCommitmentSigned orig_conv;
37531         orig_conv.inner = untag_ptr(orig);
37532         orig_conv.is_owned = ptr_is_owned(orig);
37533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37534         orig_conv.is_owned = false;
37535         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
37536         int64_t ret_ref = 0;
37537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37539         return ret_ref;
37540 }
37541
37542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37543         LDKCommitmentSigned a_conv;
37544         a_conv.inner = untag_ptr(a);
37545         a_conv.is_owned = ptr_is_owned(a);
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37547         a_conv.is_owned = false;
37548         LDKCommitmentSigned b_conv;
37549         b_conv.inner = untag_ptr(b);
37550         b_conv.is_owned = ptr_is_owned(b);
37551         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37552         b_conv.is_owned = false;
37553         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
37554         return ret_conv;
37555 }
37556
37557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37558         LDKRevokeAndACK this_obj_conv;
37559         this_obj_conv.inner = untag_ptr(this_obj);
37560         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37562         RevokeAndACK_free(this_obj_conv);
37563 }
37564
37565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37566         LDKRevokeAndACK this_ptr_conv;
37567         this_ptr_conv.inner = untag_ptr(this_ptr);
37568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37570         this_ptr_conv.is_owned = false;
37571         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
37573         return ret_arr;
37574 }
37575
37576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37577         LDKRevokeAndACK this_ptr_conv;
37578         this_ptr_conv.inner = untag_ptr(this_ptr);
37579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37581         this_ptr_conv.is_owned = false;
37582         LDKThirtyTwoBytes val_ref;
37583         CHECK((*env)->GetArrayLength(env, val) == 32);
37584         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37585         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
37586 }
37587
37588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37589         LDKRevokeAndACK this_ptr_conv;
37590         this_ptr_conv.inner = untag_ptr(this_ptr);
37591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37593         this_ptr_conv.is_owned = false;
37594         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
37596         return ret_arr;
37597 }
37598
37599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37600         LDKRevokeAndACK this_ptr_conv;
37601         this_ptr_conv.inner = untag_ptr(this_ptr);
37602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37604         this_ptr_conv.is_owned = false;
37605         LDKThirtyTwoBytes val_ref;
37606         CHECK((*env)->GetArrayLength(env, val) == 32);
37607         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37608         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
37609 }
37610
37611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37612         LDKRevokeAndACK this_ptr_conv;
37613         this_ptr_conv.inner = untag_ptr(this_ptr);
37614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37616         this_ptr_conv.is_owned = false;
37617         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
37619         return ret_arr;
37620 }
37621
37622 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) {
37623         LDKRevokeAndACK this_ptr_conv;
37624         this_ptr_conv.inner = untag_ptr(this_ptr);
37625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37627         this_ptr_conv.is_owned = false;
37628         LDKPublicKey val_ref;
37629         CHECK((*env)->GetArrayLength(env, val) == 33);
37630         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37631         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
37632 }
37633
37634 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) {
37635         LDKThirtyTwoBytes channel_id_arg_ref;
37636         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37637         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37638         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
37639         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
37640         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
37641         LDKPublicKey next_per_commitment_point_arg_ref;
37642         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
37643         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
37644         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
37645         int64_t ret_ref = 0;
37646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37648         return ret_ref;
37649 }
37650
37651 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
37652         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
37653         int64_t ret_ref = 0;
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37656         return ret_ref;
37657 }
37658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37659         LDKRevokeAndACK arg_conv;
37660         arg_conv.inner = untag_ptr(arg);
37661         arg_conv.is_owned = ptr_is_owned(arg);
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37663         arg_conv.is_owned = false;
37664         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
37665         return ret_conv;
37666 }
37667
37668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37669         LDKRevokeAndACK orig_conv;
37670         orig_conv.inner = untag_ptr(orig);
37671         orig_conv.is_owned = ptr_is_owned(orig);
37672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37673         orig_conv.is_owned = false;
37674         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
37675         int64_t ret_ref = 0;
37676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37678         return ret_ref;
37679 }
37680
37681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37682         LDKRevokeAndACK a_conv;
37683         a_conv.inner = untag_ptr(a);
37684         a_conv.is_owned = ptr_is_owned(a);
37685         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37686         a_conv.is_owned = false;
37687         LDKRevokeAndACK b_conv;
37688         b_conv.inner = untag_ptr(b);
37689         b_conv.is_owned = ptr_is_owned(b);
37690         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37691         b_conv.is_owned = false;
37692         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
37693         return ret_conv;
37694 }
37695
37696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37697         LDKUpdateFee this_obj_conv;
37698         this_obj_conv.inner = untag_ptr(this_obj);
37699         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37701         UpdateFee_free(this_obj_conv);
37702 }
37703
37704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37705         LDKUpdateFee this_ptr_conv;
37706         this_ptr_conv.inner = untag_ptr(this_ptr);
37707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37709         this_ptr_conv.is_owned = false;
37710         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
37712         return ret_arr;
37713 }
37714
37715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37716         LDKUpdateFee this_ptr_conv;
37717         this_ptr_conv.inner = untag_ptr(this_ptr);
37718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37720         this_ptr_conv.is_owned = false;
37721         LDKThirtyTwoBytes val_ref;
37722         CHECK((*env)->GetArrayLength(env, val) == 32);
37723         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37724         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
37725 }
37726
37727 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
37728         LDKUpdateFee this_ptr_conv;
37729         this_ptr_conv.inner = untag_ptr(this_ptr);
37730         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37732         this_ptr_conv.is_owned = false;
37733         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
37734         return ret_conv;
37735 }
37736
37737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37738         LDKUpdateFee this_ptr_conv;
37739         this_ptr_conv.inner = untag_ptr(this_ptr);
37740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37742         this_ptr_conv.is_owned = false;
37743         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
37744 }
37745
37746 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) {
37747         LDKThirtyTwoBytes channel_id_arg_ref;
37748         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37749         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37750         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
37751         int64_t ret_ref = 0;
37752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37754         return ret_ref;
37755 }
37756
37757 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37758         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37759         int64_t ret_ref = 0;
37760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37762         return ret_ref;
37763 }
37764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37765         LDKUpdateFee arg_conv;
37766         arg_conv.inner = untag_ptr(arg);
37767         arg_conv.is_owned = ptr_is_owned(arg);
37768         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37769         arg_conv.is_owned = false;
37770         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37771         return ret_conv;
37772 }
37773
37774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37775         LDKUpdateFee orig_conv;
37776         orig_conv.inner = untag_ptr(orig);
37777         orig_conv.is_owned = ptr_is_owned(orig);
37778         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37779         orig_conv.is_owned = false;
37780         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37781         int64_t ret_ref = 0;
37782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37784         return ret_ref;
37785 }
37786
37787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37788         LDKUpdateFee a_conv;
37789         a_conv.inner = untag_ptr(a);
37790         a_conv.is_owned = ptr_is_owned(a);
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37792         a_conv.is_owned = false;
37793         LDKUpdateFee b_conv;
37794         b_conv.inner = untag_ptr(b);
37795         b_conv.is_owned = ptr_is_owned(b);
37796         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37797         b_conv.is_owned = false;
37798         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37799         return ret_conv;
37800 }
37801
37802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37803         LDKDataLossProtect this_obj_conv;
37804         this_obj_conv.inner = untag_ptr(this_obj);
37805         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37807         DataLossProtect_free(this_obj_conv);
37808 }
37809
37810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37811         LDKDataLossProtect this_ptr_conv;
37812         this_ptr_conv.inner = untag_ptr(this_ptr);
37813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37815         this_ptr_conv.is_owned = false;
37816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37818         return ret_arr;
37819 }
37820
37821 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) {
37822         LDKDataLossProtect this_ptr_conv;
37823         this_ptr_conv.inner = untag_ptr(this_ptr);
37824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37826         this_ptr_conv.is_owned = false;
37827         LDKThirtyTwoBytes val_ref;
37828         CHECK((*env)->GetArrayLength(env, val) == 32);
37829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37830         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37831 }
37832
37833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37834         LDKDataLossProtect this_ptr_conv;
37835         this_ptr_conv.inner = untag_ptr(this_ptr);
37836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37838         this_ptr_conv.is_owned = false;
37839         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37841         return ret_arr;
37842 }
37843
37844 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) {
37845         LDKDataLossProtect this_ptr_conv;
37846         this_ptr_conv.inner = untag_ptr(this_ptr);
37847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37849         this_ptr_conv.is_owned = false;
37850         LDKPublicKey val_ref;
37851         CHECK((*env)->GetArrayLength(env, val) == 33);
37852         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37853         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37854 }
37855
37856 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) {
37857         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37858         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37859         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37860         LDKPublicKey my_current_per_commitment_point_arg_ref;
37861         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37862         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37863         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37864         int64_t ret_ref = 0;
37865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37867         return ret_ref;
37868 }
37869
37870 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37871         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37872         int64_t ret_ref = 0;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37875         return ret_ref;
37876 }
37877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37878         LDKDataLossProtect arg_conv;
37879         arg_conv.inner = untag_ptr(arg);
37880         arg_conv.is_owned = ptr_is_owned(arg);
37881         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37882         arg_conv.is_owned = false;
37883         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37884         return ret_conv;
37885 }
37886
37887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37888         LDKDataLossProtect orig_conv;
37889         orig_conv.inner = untag_ptr(orig);
37890         orig_conv.is_owned = ptr_is_owned(orig);
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37892         orig_conv.is_owned = false;
37893         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37894         int64_t ret_ref = 0;
37895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37897         return ret_ref;
37898 }
37899
37900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37901         LDKDataLossProtect a_conv;
37902         a_conv.inner = untag_ptr(a);
37903         a_conv.is_owned = ptr_is_owned(a);
37904         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37905         a_conv.is_owned = false;
37906         LDKDataLossProtect b_conv;
37907         b_conv.inner = untag_ptr(b);
37908         b_conv.is_owned = ptr_is_owned(b);
37909         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37910         b_conv.is_owned = false;
37911         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37912         return ret_conv;
37913 }
37914
37915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37916         LDKChannelReestablish this_obj_conv;
37917         this_obj_conv.inner = untag_ptr(this_obj);
37918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37920         ChannelReestablish_free(this_obj_conv);
37921 }
37922
37923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37924         LDKChannelReestablish this_ptr_conv;
37925         this_ptr_conv.inner = untag_ptr(this_ptr);
37926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37928         this_ptr_conv.is_owned = false;
37929         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37931         return ret_arr;
37932 }
37933
37934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37935         LDKChannelReestablish this_ptr_conv;
37936         this_ptr_conv.inner = untag_ptr(this_ptr);
37937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37939         this_ptr_conv.is_owned = false;
37940         LDKThirtyTwoBytes val_ref;
37941         CHECK((*env)->GetArrayLength(env, val) == 32);
37942         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37943         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37944 }
37945
37946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37947         LDKChannelReestablish this_ptr_conv;
37948         this_ptr_conv.inner = untag_ptr(this_ptr);
37949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37951         this_ptr_conv.is_owned = false;
37952         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37953         return ret_conv;
37954 }
37955
37956 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) {
37957         LDKChannelReestablish this_ptr_conv;
37958         this_ptr_conv.inner = untag_ptr(this_ptr);
37959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37961         this_ptr_conv.is_owned = false;
37962         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37963 }
37964
37965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37966         LDKChannelReestablish this_ptr_conv;
37967         this_ptr_conv.inner = untag_ptr(this_ptr);
37968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37970         this_ptr_conv.is_owned = false;
37971         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37972         return ret_conv;
37973 }
37974
37975 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) {
37976         LDKChannelReestablish this_ptr_conv;
37977         this_ptr_conv.inner = untag_ptr(this_ptr);
37978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37980         this_ptr_conv.is_owned = false;
37981         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37982 }
37983
37984 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37985         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37986         int64_t ret_ref = 0;
37987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37989         return ret_ref;
37990 }
37991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37992         LDKChannelReestablish arg_conv;
37993         arg_conv.inner = untag_ptr(arg);
37994         arg_conv.is_owned = ptr_is_owned(arg);
37995         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37996         arg_conv.is_owned = false;
37997         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37998         return ret_conv;
37999 }
38000
38001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38002         LDKChannelReestablish orig_conv;
38003         orig_conv.inner = untag_ptr(orig);
38004         orig_conv.is_owned = ptr_is_owned(orig);
38005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38006         orig_conv.is_owned = false;
38007         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
38008         int64_t ret_ref = 0;
38009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38011         return ret_ref;
38012 }
38013
38014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38015         LDKChannelReestablish a_conv;
38016         a_conv.inner = untag_ptr(a);
38017         a_conv.is_owned = ptr_is_owned(a);
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38019         a_conv.is_owned = false;
38020         LDKChannelReestablish b_conv;
38021         b_conv.inner = untag_ptr(b);
38022         b_conv.is_owned = ptr_is_owned(b);
38023         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38024         b_conv.is_owned = false;
38025         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
38026         return ret_conv;
38027 }
38028
38029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38030         LDKAnnouncementSignatures this_obj_conv;
38031         this_obj_conv.inner = untag_ptr(this_obj);
38032         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38034         AnnouncementSignatures_free(this_obj_conv);
38035 }
38036
38037 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38038         LDKAnnouncementSignatures this_ptr_conv;
38039         this_ptr_conv.inner = untag_ptr(this_ptr);
38040         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38042         this_ptr_conv.is_owned = false;
38043         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
38045         return ret_arr;
38046 }
38047
38048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38049         LDKAnnouncementSignatures this_ptr_conv;
38050         this_ptr_conv.inner = untag_ptr(this_ptr);
38051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38053         this_ptr_conv.is_owned = false;
38054         LDKThirtyTwoBytes val_ref;
38055         CHECK((*env)->GetArrayLength(env, val) == 32);
38056         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38057         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
38058 }
38059
38060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38061         LDKAnnouncementSignatures this_ptr_conv;
38062         this_ptr_conv.inner = untag_ptr(this_ptr);
38063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38065         this_ptr_conv.is_owned = false;
38066         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
38067         return ret_conv;
38068 }
38069
38070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38071         LDKAnnouncementSignatures this_ptr_conv;
38072         this_ptr_conv.inner = untag_ptr(this_ptr);
38073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38075         this_ptr_conv.is_owned = false;
38076         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
38077 }
38078
38079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38080         LDKAnnouncementSignatures this_ptr_conv;
38081         this_ptr_conv.inner = untag_ptr(this_ptr);
38082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38084         this_ptr_conv.is_owned = false;
38085         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
38087         return ret_arr;
38088 }
38089
38090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38091         LDKAnnouncementSignatures this_ptr_conv;
38092         this_ptr_conv.inner = untag_ptr(this_ptr);
38093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38095         this_ptr_conv.is_owned = false;
38096         LDKSignature val_ref;
38097         CHECK((*env)->GetArrayLength(env, val) == 64);
38098         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38099         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
38100 }
38101
38102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38103         LDKAnnouncementSignatures this_ptr_conv;
38104         this_ptr_conv.inner = untag_ptr(this_ptr);
38105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38107         this_ptr_conv.is_owned = false;
38108         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38109         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
38110         return ret_arr;
38111 }
38112
38113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38114         LDKAnnouncementSignatures this_ptr_conv;
38115         this_ptr_conv.inner = untag_ptr(this_ptr);
38116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38118         this_ptr_conv.is_owned = false;
38119         LDKSignature val_ref;
38120         CHECK((*env)->GetArrayLength(env, val) == 64);
38121         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38122         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
38123 }
38124
38125 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) {
38126         LDKThirtyTwoBytes channel_id_arg_ref;
38127         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
38128         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
38129         LDKSignature node_signature_arg_ref;
38130         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
38131         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
38132         LDKSignature bitcoin_signature_arg_ref;
38133         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
38134         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
38135         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
38136         int64_t ret_ref = 0;
38137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38139         return ret_ref;
38140 }
38141
38142 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
38143         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
38144         int64_t ret_ref = 0;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38147         return ret_ref;
38148 }
38149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38150         LDKAnnouncementSignatures arg_conv;
38151         arg_conv.inner = untag_ptr(arg);
38152         arg_conv.is_owned = ptr_is_owned(arg);
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38154         arg_conv.is_owned = false;
38155         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
38156         return ret_conv;
38157 }
38158
38159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38160         LDKAnnouncementSignatures orig_conv;
38161         orig_conv.inner = untag_ptr(orig);
38162         orig_conv.is_owned = ptr_is_owned(orig);
38163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38164         orig_conv.is_owned = false;
38165         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
38166         int64_t ret_ref = 0;
38167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38169         return ret_ref;
38170 }
38171
38172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38173         LDKAnnouncementSignatures a_conv;
38174         a_conv.inner = untag_ptr(a);
38175         a_conv.is_owned = ptr_is_owned(a);
38176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38177         a_conv.is_owned = false;
38178         LDKAnnouncementSignatures b_conv;
38179         b_conv.inner = untag_ptr(b);
38180         b_conv.is_owned = ptr_is_owned(b);
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38182         b_conv.is_owned = false;
38183         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
38184         return ret_conv;
38185 }
38186
38187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38188         if (!ptr_is_owned(this_ptr)) return;
38189         void* this_ptr_ptr = untag_ptr(this_ptr);
38190         CHECK_ACCESS(this_ptr_ptr);
38191         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
38192         FREE(untag_ptr(this_ptr));
38193         NetAddress_free(this_ptr_conv);
38194 }
38195
38196 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
38197         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38198         *ret_copy = NetAddress_clone(arg);
38199         int64_t ret_ref = tag_ptr(ret_copy, true);
38200         return ret_ref;
38201 }
38202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38203         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
38204         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
38205         return ret_conv;
38206 }
38207
38208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38209         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
38210         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38211         *ret_copy = NetAddress_clone(orig_conv);
38212         int64_t ret_ref = tag_ptr(ret_copy, true);
38213         return ret_ref;
38214 }
38215
38216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38217         LDKFourBytes addr_ref;
38218         CHECK((*env)->GetArrayLength(env, addr) == 4);
38219         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
38220         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38221         *ret_copy = NetAddress_ipv4(addr_ref, port);
38222         int64_t ret_ref = tag_ptr(ret_copy, true);
38223         return ret_ref;
38224 }
38225
38226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38227         LDKSixteenBytes addr_ref;
38228         CHECK((*env)->GetArrayLength(env, addr) == 16);
38229         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
38230         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38231         *ret_copy = NetAddress_ipv6(addr_ref, port);
38232         int64_t ret_ref = tag_ptr(ret_copy, true);
38233         return ret_ref;
38234 }
38235
38236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
38237         LDKTwelveBytes a_ref;
38238         CHECK((*env)->GetArrayLength(env, a) == 12);
38239         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
38240         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38241         *ret_copy = NetAddress_onion_v2(a_ref);
38242         int64_t ret_ref = tag_ptr(ret_copy, true);
38243         return ret_ref;
38244 }
38245
38246 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) {
38247         LDKThirtyTwoBytes ed25519_pubkey_ref;
38248         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
38249         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
38250         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38251         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
38252         int64_t ret_ref = tag_ptr(ret_copy, true);
38253         return ret_ref;
38254 }
38255
38256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
38257         LDKHostname hostname_conv;
38258         hostname_conv.inner = untag_ptr(hostname);
38259         hostname_conv.is_owned = ptr_is_owned(hostname);
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
38261         hostname_conv = Hostname_clone(&hostname_conv);
38262         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38263         *ret_copy = NetAddress_hostname(hostname_conv, port);
38264         int64_t ret_ref = tag_ptr(ret_copy, true);
38265         return ret_ref;
38266 }
38267
38268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38269         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
38270         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
38271         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
38272         return ret_conv;
38273 }
38274
38275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
38276         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
38277         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
38278         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38279         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38280         CVec_u8Z_free(ret_var);
38281         return ret_arr;
38282 }
38283
38284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38285         LDKu8slice ser_ref;
38286         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38287         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38288         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
38289         *ret_conv = NetAddress_read(ser_ref);
38290         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38291         return tag_ptr(ret_conv, true);
38292 }
38293
38294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38295         if (!ptr_is_owned(this_ptr)) return;
38296         void* this_ptr_ptr = untag_ptr(this_ptr);
38297         CHECK_ACCESS(this_ptr_ptr);
38298         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
38299         FREE(untag_ptr(this_ptr));
38300         UnsignedGossipMessage_free(this_ptr_conv);
38301 }
38302
38303 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
38304         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38305         *ret_copy = UnsignedGossipMessage_clone(arg);
38306         int64_t ret_ref = tag_ptr(ret_copy, true);
38307         return ret_ref;
38308 }
38309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38310         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
38311         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
38312         return ret_conv;
38313 }
38314
38315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38316         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
38317         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38318         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
38319         int64_t ret_ref = tag_ptr(ret_copy, true);
38320         return ret_ref;
38321 }
38322
38323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38324         LDKUnsignedChannelAnnouncement a_conv;
38325         a_conv.inner = untag_ptr(a);
38326         a_conv.is_owned = ptr_is_owned(a);
38327         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38328         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
38329         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38330         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
38331         int64_t ret_ref = tag_ptr(ret_copy, true);
38332         return ret_ref;
38333 }
38334
38335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1update(JNIEnv *env, jclass clz, int64_t a) {
38336         LDKUnsignedChannelUpdate a_conv;
38337         a_conv.inner = untag_ptr(a);
38338         a_conv.is_owned = ptr_is_owned(a);
38339         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38340         a_conv = UnsignedChannelUpdate_clone(&a_conv);
38341         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38342         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
38343         int64_t ret_ref = tag_ptr(ret_copy, true);
38344         return ret_ref;
38345 }
38346
38347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1node_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38348         LDKUnsignedNodeAnnouncement a_conv;
38349         a_conv.inner = untag_ptr(a);
38350         a_conv.is_owned = ptr_is_owned(a);
38351         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38352         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
38353         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38354         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
38355         int64_t ret_ref = tag_ptr(ret_copy, true);
38356         return ret_ref;
38357 }
38358
38359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38360         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
38361         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
38362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38364         CVec_u8Z_free(ret_var);
38365         return ret_arr;
38366 }
38367
38368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38369         LDKUnsignedNodeAnnouncement this_obj_conv;
38370         this_obj_conv.inner = untag_ptr(this_obj);
38371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38373         UnsignedNodeAnnouncement_free(this_obj_conv);
38374 }
38375
38376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38377         LDKUnsignedNodeAnnouncement this_ptr_conv;
38378         this_ptr_conv.inner = untag_ptr(this_ptr);
38379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38381         this_ptr_conv.is_owned = false;
38382         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
38383         int64_t ret_ref = 0;
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38386         return ret_ref;
38387 }
38388
38389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38390         LDKUnsignedNodeAnnouncement this_ptr_conv;
38391         this_ptr_conv.inner = untag_ptr(this_ptr);
38392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38394         this_ptr_conv.is_owned = false;
38395         LDKNodeFeatures val_conv;
38396         val_conv.inner = untag_ptr(val);
38397         val_conv.is_owned = ptr_is_owned(val);
38398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38399         val_conv = NodeFeatures_clone(&val_conv);
38400         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
38401 }
38402
38403 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38404         LDKUnsignedNodeAnnouncement this_ptr_conv;
38405         this_ptr_conv.inner = untag_ptr(this_ptr);
38406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38408         this_ptr_conv.is_owned = false;
38409         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
38410         return ret_conv;
38411 }
38412
38413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38414         LDKUnsignedNodeAnnouncement this_ptr_conv;
38415         this_ptr_conv.inner = untag_ptr(this_ptr);
38416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38418         this_ptr_conv.is_owned = false;
38419         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
38420 }
38421
38422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38423         LDKUnsignedNodeAnnouncement this_ptr_conv;
38424         this_ptr_conv.inner = untag_ptr(this_ptr);
38425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38427         this_ptr_conv.is_owned = false;
38428         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
38429         int64_t ret_ref = 0;
38430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38432         return ret_ref;
38433 }
38434
38435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38436         LDKUnsignedNodeAnnouncement this_ptr_conv;
38437         this_ptr_conv.inner = untag_ptr(this_ptr);
38438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38440         this_ptr_conv.is_owned = false;
38441         LDKNodeId val_conv;
38442         val_conv.inner = untag_ptr(val);
38443         val_conv.is_owned = ptr_is_owned(val);
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38445         val_conv = NodeId_clone(&val_conv);
38446         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
38447 }
38448
38449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38450         LDKUnsignedNodeAnnouncement this_ptr_conv;
38451         this_ptr_conv.inner = untag_ptr(this_ptr);
38452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38454         this_ptr_conv.is_owned = false;
38455         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38456         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
38457         return ret_arr;
38458 }
38459
38460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38461         LDKUnsignedNodeAnnouncement this_ptr_conv;
38462         this_ptr_conv.inner = untag_ptr(this_ptr);
38463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38465         this_ptr_conv.is_owned = false;
38466         LDKThreeBytes val_ref;
38467         CHECK((*env)->GetArrayLength(env, val) == 3);
38468         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38469         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
38470 }
38471
38472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
38473         LDKUnsignedNodeAnnouncement this_ptr_conv;
38474         this_ptr_conv.inner = untag_ptr(this_ptr);
38475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38477         this_ptr_conv.is_owned = false;
38478         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
38479         int64_t ret_ref = 0;
38480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38482         return ret_ref;
38483 }
38484
38485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38486         LDKUnsignedNodeAnnouncement this_ptr_conv;
38487         this_ptr_conv.inner = untag_ptr(this_ptr);
38488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38490         this_ptr_conv.is_owned = false;
38491         LDKNodeAlias val_conv;
38492         val_conv.inner = untag_ptr(val);
38493         val_conv.is_owned = ptr_is_owned(val);
38494         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38495         val_conv = NodeAlias_clone(&val_conv);
38496         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
38497 }
38498
38499 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
38500         LDKUnsignedNodeAnnouncement this_ptr_conv;
38501         this_ptr_conv.inner = untag_ptr(this_ptr);
38502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38504         this_ptr_conv.is_owned = false;
38505         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
38506         int64_tArray ret_arr = NULL;
38507         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38508         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38509         for (size_t m = 0; m < ret_var.datalen; m++) {
38510                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38511                 *ret_conv_12_copy = ret_var.data[m];
38512                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
38513                 ret_arr_ptr[m] = ret_conv_12_ref;
38514         }
38515         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38516         FREE(ret_var.data);
38517         return ret_arr;
38518 }
38519
38520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38521         LDKUnsignedNodeAnnouncement this_ptr_conv;
38522         this_ptr_conv.inner = untag_ptr(this_ptr);
38523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38525         this_ptr_conv.is_owned = false;
38526         LDKCVec_NetAddressZ val_constr;
38527         val_constr.datalen = (*env)->GetArrayLength(env, val);
38528         if (val_constr.datalen > 0)
38529                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38530         else
38531                 val_constr.data = NULL;
38532         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38533         for (size_t m = 0; m < val_constr.datalen; m++) {
38534                 int64_t val_conv_12 = val_vals[m];
38535                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
38536                 CHECK_ACCESS(val_conv_12_ptr);
38537                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38538                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
38539                 val_constr.data[m] = val_conv_12_conv;
38540         }
38541         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38542         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
38543 }
38544
38545 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
38546         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
38547         int64_t ret_ref = 0;
38548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38550         return ret_ref;
38551 }
38552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38553         LDKUnsignedNodeAnnouncement arg_conv;
38554         arg_conv.inner = untag_ptr(arg);
38555         arg_conv.is_owned = ptr_is_owned(arg);
38556         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38557         arg_conv.is_owned = false;
38558         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
38559         return ret_conv;
38560 }
38561
38562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38563         LDKUnsignedNodeAnnouncement orig_conv;
38564         orig_conv.inner = untag_ptr(orig);
38565         orig_conv.is_owned = ptr_is_owned(orig);
38566         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38567         orig_conv.is_owned = false;
38568         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
38569         int64_t ret_ref = 0;
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38572         return ret_ref;
38573 }
38574
38575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38576         LDKUnsignedNodeAnnouncement a_conv;
38577         a_conv.inner = untag_ptr(a);
38578         a_conv.is_owned = ptr_is_owned(a);
38579         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38580         a_conv.is_owned = false;
38581         LDKUnsignedNodeAnnouncement b_conv;
38582         b_conv.inner = untag_ptr(b);
38583         b_conv.is_owned = ptr_is_owned(b);
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38585         b_conv.is_owned = false;
38586         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
38587         return ret_conv;
38588 }
38589
38590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38591         LDKNodeAnnouncement this_obj_conv;
38592         this_obj_conv.inner = untag_ptr(this_obj);
38593         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38595         NodeAnnouncement_free(this_obj_conv);
38596 }
38597
38598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38599         LDKNodeAnnouncement this_ptr_conv;
38600         this_ptr_conv.inner = untag_ptr(this_ptr);
38601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38603         this_ptr_conv.is_owned = false;
38604         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
38606         return ret_arr;
38607 }
38608
38609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38610         LDKNodeAnnouncement this_ptr_conv;
38611         this_ptr_conv.inner = untag_ptr(this_ptr);
38612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38614         this_ptr_conv.is_owned = false;
38615         LDKSignature val_ref;
38616         CHECK((*env)->GetArrayLength(env, val) == 64);
38617         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38618         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
38619 }
38620
38621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38622         LDKNodeAnnouncement this_ptr_conv;
38623         this_ptr_conv.inner = untag_ptr(this_ptr);
38624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38626         this_ptr_conv.is_owned = false;
38627         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
38628         int64_t ret_ref = 0;
38629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38631         return ret_ref;
38632 }
38633
38634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38635         LDKNodeAnnouncement this_ptr_conv;
38636         this_ptr_conv.inner = untag_ptr(this_ptr);
38637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38639         this_ptr_conv.is_owned = false;
38640         LDKUnsignedNodeAnnouncement val_conv;
38641         val_conv.inner = untag_ptr(val);
38642         val_conv.is_owned = ptr_is_owned(val);
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38644         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
38645         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
38646 }
38647
38648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38649         LDKSignature signature_arg_ref;
38650         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38651         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38652         LDKUnsignedNodeAnnouncement contents_arg_conv;
38653         contents_arg_conv.inner = untag_ptr(contents_arg);
38654         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38655         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38656         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
38657         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
38658         int64_t ret_ref = 0;
38659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38660         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38661         return ret_ref;
38662 }
38663
38664 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
38665         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
38666         int64_t ret_ref = 0;
38667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38669         return ret_ref;
38670 }
38671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38672         LDKNodeAnnouncement arg_conv;
38673         arg_conv.inner = untag_ptr(arg);
38674         arg_conv.is_owned = ptr_is_owned(arg);
38675         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38676         arg_conv.is_owned = false;
38677         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
38678         return ret_conv;
38679 }
38680
38681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38682         LDKNodeAnnouncement orig_conv;
38683         orig_conv.inner = untag_ptr(orig);
38684         orig_conv.is_owned = ptr_is_owned(orig);
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38686         orig_conv.is_owned = false;
38687         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
38688         int64_t ret_ref = 0;
38689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38691         return ret_ref;
38692 }
38693
38694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38695         LDKNodeAnnouncement a_conv;
38696         a_conv.inner = untag_ptr(a);
38697         a_conv.is_owned = ptr_is_owned(a);
38698         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38699         a_conv.is_owned = false;
38700         LDKNodeAnnouncement b_conv;
38701         b_conv.inner = untag_ptr(b);
38702         b_conv.is_owned = ptr_is_owned(b);
38703         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38704         b_conv.is_owned = false;
38705         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
38706         return ret_conv;
38707 }
38708
38709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38710         LDKUnsignedChannelAnnouncement this_obj_conv;
38711         this_obj_conv.inner = untag_ptr(this_obj);
38712         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38714         UnsignedChannelAnnouncement_free(this_obj_conv);
38715 }
38716
38717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38718         LDKUnsignedChannelAnnouncement this_ptr_conv;
38719         this_ptr_conv.inner = untag_ptr(this_ptr);
38720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38722         this_ptr_conv.is_owned = false;
38723         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
38724         int64_t ret_ref = 0;
38725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38727         return ret_ref;
38728 }
38729
38730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38731         LDKUnsignedChannelAnnouncement this_ptr_conv;
38732         this_ptr_conv.inner = untag_ptr(this_ptr);
38733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38735         this_ptr_conv.is_owned = false;
38736         LDKChannelFeatures val_conv;
38737         val_conv.inner = untag_ptr(val);
38738         val_conv.is_owned = ptr_is_owned(val);
38739         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38740         val_conv = ChannelFeatures_clone(&val_conv);
38741         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
38742 }
38743
38744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38745         LDKUnsignedChannelAnnouncement this_ptr_conv;
38746         this_ptr_conv.inner = untag_ptr(this_ptr);
38747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38749         this_ptr_conv.is_owned = false;
38750         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38751         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
38752         return ret_arr;
38753 }
38754
38755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38756         LDKUnsignedChannelAnnouncement this_ptr_conv;
38757         this_ptr_conv.inner = untag_ptr(this_ptr);
38758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38760         this_ptr_conv.is_owned = false;
38761         LDKThirtyTwoBytes val_ref;
38762         CHECK((*env)->GetArrayLength(env, val) == 32);
38763         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38764         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
38765 }
38766
38767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38768         LDKUnsignedChannelAnnouncement this_ptr_conv;
38769         this_ptr_conv.inner = untag_ptr(this_ptr);
38770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38772         this_ptr_conv.is_owned = false;
38773         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
38774         return ret_conv;
38775 }
38776
38777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38778         LDKUnsignedChannelAnnouncement this_ptr_conv;
38779         this_ptr_conv.inner = untag_ptr(this_ptr);
38780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38782         this_ptr_conv.is_owned = false;
38783         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
38784 }
38785
38786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38787         LDKUnsignedChannelAnnouncement this_ptr_conv;
38788         this_ptr_conv.inner = untag_ptr(this_ptr);
38789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38791         this_ptr_conv.is_owned = false;
38792         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
38793         int64_t ret_ref = 0;
38794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38796         return ret_ref;
38797 }
38798
38799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38800         LDKUnsignedChannelAnnouncement this_ptr_conv;
38801         this_ptr_conv.inner = untag_ptr(this_ptr);
38802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38804         this_ptr_conv.is_owned = false;
38805         LDKNodeId val_conv;
38806         val_conv.inner = untag_ptr(val);
38807         val_conv.is_owned = ptr_is_owned(val);
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38809         val_conv = NodeId_clone(&val_conv);
38810         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
38811 }
38812
38813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38814         LDKUnsignedChannelAnnouncement this_ptr_conv;
38815         this_ptr_conv.inner = untag_ptr(this_ptr);
38816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38818         this_ptr_conv.is_owned = false;
38819         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
38820         int64_t ret_ref = 0;
38821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38823         return ret_ref;
38824 }
38825
38826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38827         LDKUnsignedChannelAnnouncement this_ptr_conv;
38828         this_ptr_conv.inner = untag_ptr(this_ptr);
38829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38831         this_ptr_conv.is_owned = false;
38832         LDKNodeId val_conv;
38833         val_conv.inner = untag_ptr(val);
38834         val_conv.is_owned = ptr_is_owned(val);
38835         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38836         val_conv = NodeId_clone(&val_conv);
38837         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
38838 }
38839
38840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38841         LDKUnsignedChannelAnnouncement this_ptr_conv;
38842         this_ptr_conv.inner = untag_ptr(this_ptr);
38843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38845         this_ptr_conv.is_owned = false;
38846         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
38847         int64_t ret_ref = 0;
38848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38850         return ret_ref;
38851 }
38852
38853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38854         LDKUnsignedChannelAnnouncement this_ptr_conv;
38855         this_ptr_conv.inner = untag_ptr(this_ptr);
38856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38858         this_ptr_conv.is_owned = false;
38859         LDKNodeId val_conv;
38860         val_conv.inner = untag_ptr(val);
38861         val_conv.is_owned = ptr_is_owned(val);
38862         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38863         val_conv = NodeId_clone(&val_conv);
38864         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
38865 }
38866
38867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38868         LDKUnsignedChannelAnnouncement this_ptr_conv;
38869         this_ptr_conv.inner = untag_ptr(this_ptr);
38870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38872         this_ptr_conv.is_owned = false;
38873         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
38874         int64_t ret_ref = 0;
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38877         return ret_ref;
38878 }
38879
38880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38881         LDKUnsignedChannelAnnouncement this_ptr_conv;
38882         this_ptr_conv.inner = untag_ptr(this_ptr);
38883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38885         this_ptr_conv.is_owned = false;
38886         LDKNodeId val_conv;
38887         val_conv.inner = untag_ptr(val);
38888         val_conv.is_owned = ptr_is_owned(val);
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38890         val_conv = NodeId_clone(&val_conv);
38891         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
38892 }
38893
38894 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38895         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38896         int64_t ret_ref = 0;
38897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38899         return ret_ref;
38900 }
38901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38902         LDKUnsignedChannelAnnouncement arg_conv;
38903         arg_conv.inner = untag_ptr(arg);
38904         arg_conv.is_owned = ptr_is_owned(arg);
38905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38906         arg_conv.is_owned = false;
38907         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38908         return ret_conv;
38909 }
38910
38911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38912         LDKUnsignedChannelAnnouncement orig_conv;
38913         orig_conv.inner = untag_ptr(orig);
38914         orig_conv.is_owned = ptr_is_owned(orig);
38915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38916         orig_conv.is_owned = false;
38917         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38918         int64_t ret_ref = 0;
38919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38921         return ret_ref;
38922 }
38923
38924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38925         LDKUnsignedChannelAnnouncement a_conv;
38926         a_conv.inner = untag_ptr(a);
38927         a_conv.is_owned = ptr_is_owned(a);
38928         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38929         a_conv.is_owned = false;
38930         LDKUnsignedChannelAnnouncement b_conv;
38931         b_conv.inner = untag_ptr(b);
38932         b_conv.is_owned = ptr_is_owned(b);
38933         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38934         b_conv.is_owned = false;
38935         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38936         return ret_conv;
38937 }
38938
38939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38940         LDKChannelAnnouncement this_obj_conv;
38941         this_obj_conv.inner = untag_ptr(this_obj);
38942         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38944         ChannelAnnouncement_free(this_obj_conv);
38945 }
38946
38947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38948         LDKChannelAnnouncement this_ptr_conv;
38949         this_ptr_conv.inner = untag_ptr(this_ptr);
38950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38952         this_ptr_conv.is_owned = false;
38953         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38955         return ret_arr;
38956 }
38957
38958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38959         LDKChannelAnnouncement this_ptr_conv;
38960         this_ptr_conv.inner = untag_ptr(this_ptr);
38961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38963         this_ptr_conv.is_owned = false;
38964         LDKSignature val_ref;
38965         CHECK((*env)->GetArrayLength(env, val) == 64);
38966         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38967         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38968 }
38969
38970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38971         LDKChannelAnnouncement this_ptr_conv;
38972         this_ptr_conv.inner = untag_ptr(this_ptr);
38973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38975         this_ptr_conv.is_owned = false;
38976         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38978         return ret_arr;
38979 }
38980
38981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38982         LDKChannelAnnouncement this_ptr_conv;
38983         this_ptr_conv.inner = untag_ptr(this_ptr);
38984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38986         this_ptr_conv.is_owned = false;
38987         LDKSignature val_ref;
38988         CHECK((*env)->GetArrayLength(env, val) == 64);
38989         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38990         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38991 }
38992
38993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38994         LDKChannelAnnouncement this_ptr_conv;
38995         this_ptr_conv.inner = untag_ptr(this_ptr);
38996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38998         this_ptr_conv.is_owned = false;
38999         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
39001         return ret_arr;
39002 }
39003
39004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39005         LDKChannelAnnouncement this_ptr_conv;
39006         this_ptr_conv.inner = untag_ptr(this_ptr);
39007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39009         this_ptr_conv.is_owned = false;
39010         LDKSignature val_ref;
39011         CHECK((*env)->GetArrayLength(env, val) == 64);
39012         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39013         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
39014 }
39015
39016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
39017         LDKChannelAnnouncement this_ptr_conv;
39018         this_ptr_conv.inner = untag_ptr(this_ptr);
39019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39021         this_ptr_conv.is_owned = false;
39022         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
39024         return ret_arr;
39025 }
39026
39027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39028         LDKChannelAnnouncement this_ptr_conv;
39029         this_ptr_conv.inner = untag_ptr(this_ptr);
39030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39032         this_ptr_conv.is_owned = false;
39033         LDKSignature val_ref;
39034         CHECK((*env)->GetArrayLength(env, val) == 64);
39035         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39036         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
39037 }
39038
39039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39040         LDKChannelAnnouncement this_ptr_conv;
39041         this_ptr_conv.inner = untag_ptr(this_ptr);
39042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39044         this_ptr_conv.is_owned = false;
39045         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
39046         int64_t ret_ref = 0;
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39049         return ret_ref;
39050 }
39051
39052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39053         LDKChannelAnnouncement this_ptr_conv;
39054         this_ptr_conv.inner = untag_ptr(this_ptr);
39055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39057         this_ptr_conv.is_owned = false;
39058         LDKUnsignedChannelAnnouncement val_conv;
39059         val_conv.inner = untag_ptr(val);
39060         val_conv.is_owned = ptr_is_owned(val);
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39062         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
39063         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
39064 }
39065
39066 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) {
39067         LDKSignature node_signature_1_arg_ref;
39068         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
39069         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
39070         LDKSignature node_signature_2_arg_ref;
39071         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
39072         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
39073         LDKSignature bitcoin_signature_1_arg_ref;
39074         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
39075         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
39076         LDKSignature bitcoin_signature_2_arg_ref;
39077         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
39078         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
39079         LDKUnsignedChannelAnnouncement contents_arg_conv;
39080         contents_arg_conv.inner = untag_ptr(contents_arg);
39081         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39082         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39083         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
39084         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);
39085         int64_t ret_ref = 0;
39086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39088         return ret_ref;
39089 }
39090
39091 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
39092         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
39093         int64_t ret_ref = 0;
39094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39096         return ret_ref;
39097 }
39098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39099         LDKChannelAnnouncement arg_conv;
39100         arg_conv.inner = untag_ptr(arg);
39101         arg_conv.is_owned = ptr_is_owned(arg);
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39103         arg_conv.is_owned = false;
39104         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
39105         return ret_conv;
39106 }
39107
39108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39109         LDKChannelAnnouncement orig_conv;
39110         orig_conv.inner = untag_ptr(orig);
39111         orig_conv.is_owned = ptr_is_owned(orig);
39112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39113         orig_conv.is_owned = false;
39114         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
39115         int64_t ret_ref = 0;
39116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39118         return ret_ref;
39119 }
39120
39121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39122         LDKChannelAnnouncement a_conv;
39123         a_conv.inner = untag_ptr(a);
39124         a_conv.is_owned = ptr_is_owned(a);
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39126         a_conv.is_owned = false;
39127         LDKChannelAnnouncement b_conv;
39128         b_conv.inner = untag_ptr(b);
39129         b_conv.is_owned = ptr_is_owned(b);
39130         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39131         b_conv.is_owned = false;
39132         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
39133         return ret_conv;
39134 }
39135
39136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39137         LDKUnsignedChannelUpdate this_obj_conv;
39138         this_obj_conv.inner = untag_ptr(this_obj);
39139         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39141         UnsignedChannelUpdate_free(this_obj_conv);
39142 }
39143
39144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39145         LDKUnsignedChannelUpdate this_ptr_conv;
39146         this_ptr_conv.inner = untag_ptr(this_ptr);
39147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39149         this_ptr_conv.is_owned = false;
39150         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39151         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
39152         return ret_arr;
39153 }
39154
39155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39156         LDKUnsignedChannelUpdate this_ptr_conv;
39157         this_ptr_conv.inner = untag_ptr(this_ptr);
39158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39160         this_ptr_conv.is_owned = false;
39161         LDKThirtyTwoBytes val_ref;
39162         CHECK((*env)->GetArrayLength(env, val) == 32);
39163         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39164         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
39165 }
39166
39167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39168         LDKUnsignedChannelUpdate this_ptr_conv;
39169         this_ptr_conv.inner = untag_ptr(this_ptr);
39170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39172         this_ptr_conv.is_owned = false;
39173         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
39174         return ret_conv;
39175 }
39176
39177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39178         LDKUnsignedChannelUpdate this_ptr_conv;
39179         this_ptr_conv.inner = untag_ptr(this_ptr);
39180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39182         this_ptr_conv.is_owned = false;
39183         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
39184 }
39185
39186 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39187         LDKUnsignedChannelUpdate this_ptr_conv;
39188         this_ptr_conv.inner = untag_ptr(this_ptr);
39189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39191         this_ptr_conv.is_owned = false;
39192         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
39193         return ret_conv;
39194 }
39195
39196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39197         LDKUnsignedChannelUpdate this_ptr_conv;
39198         this_ptr_conv.inner = untag_ptr(this_ptr);
39199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39201         this_ptr_conv.is_owned = false;
39202         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
39203 }
39204
39205 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
39206         LDKUnsignedChannelUpdate this_ptr_conv;
39207         this_ptr_conv.inner = untag_ptr(this_ptr);
39208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39210         this_ptr_conv.is_owned = false;
39211         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
39212         return ret_conv;
39213 }
39214
39215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
39216         LDKUnsignedChannelUpdate this_ptr_conv;
39217         this_ptr_conv.inner = untag_ptr(this_ptr);
39218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39220         this_ptr_conv.is_owned = false;
39221         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
39222 }
39223
39224 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39225         LDKUnsignedChannelUpdate this_ptr_conv;
39226         this_ptr_conv.inner = untag_ptr(this_ptr);
39227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39229         this_ptr_conv.is_owned = false;
39230         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
39231         return ret_conv;
39232 }
39233
39234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39235         LDKUnsignedChannelUpdate this_ptr_conv;
39236         this_ptr_conv.inner = untag_ptr(this_ptr);
39237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39239         this_ptr_conv.is_owned = false;
39240         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
39241 }
39242
39243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39244         LDKUnsignedChannelUpdate this_ptr_conv;
39245         this_ptr_conv.inner = untag_ptr(this_ptr);
39246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39248         this_ptr_conv.is_owned = false;
39249         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
39250         return ret_conv;
39251 }
39252
39253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39254         LDKUnsignedChannelUpdate this_ptr_conv;
39255         this_ptr_conv.inner = untag_ptr(this_ptr);
39256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39258         this_ptr_conv.is_owned = false;
39259         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
39260 }
39261
39262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39263         LDKUnsignedChannelUpdate this_ptr_conv;
39264         this_ptr_conv.inner = untag_ptr(this_ptr);
39265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39267         this_ptr_conv.is_owned = false;
39268         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
39269         return ret_conv;
39270 }
39271
39272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39273         LDKUnsignedChannelUpdate this_ptr_conv;
39274         this_ptr_conv.inner = untag_ptr(this_ptr);
39275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39277         this_ptr_conv.is_owned = false;
39278         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
39279 }
39280
39281 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39282         LDKUnsignedChannelUpdate this_ptr_conv;
39283         this_ptr_conv.inner = untag_ptr(this_ptr);
39284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39286         this_ptr_conv.is_owned = false;
39287         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
39288         return ret_conv;
39289 }
39290
39291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39292         LDKUnsignedChannelUpdate this_ptr_conv;
39293         this_ptr_conv.inner = untag_ptr(this_ptr);
39294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39296         this_ptr_conv.is_owned = false;
39297         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
39298 }
39299
39300 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39301         LDKUnsignedChannelUpdate this_ptr_conv;
39302         this_ptr_conv.inner = untag_ptr(this_ptr);
39303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39305         this_ptr_conv.is_owned = false;
39306         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
39307         return ret_conv;
39308 }
39309
39310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39311         LDKUnsignedChannelUpdate this_ptr_conv;
39312         this_ptr_conv.inner = untag_ptr(this_ptr);
39313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39315         this_ptr_conv.is_owned = false;
39316         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
39317 }
39318
39319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39320         LDKUnsignedChannelUpdate this_ptr_conv;
39321         this_ptr_conv.inner = untag_ptr(this_ptr);
39322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39324         this_ptr_conv.is_owned = false;
39325         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
39326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39328         CVec_u8Z_free(ret_var);
39329         return ret_arr;
39330 }
39331
39332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39333         LDKUnsignedChannelUpdate this_ptr_conv;
39334         this_ptr_conv.inner = untag_ptr(this_ptr);
39335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39337         this_ptr_conv.is_owned = false;
39338         LDKCVec_u8Z val_ref;
39339         val_ref.datalen = (*env)->GetArrayLength(env, val);
39340         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39341         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39342         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
39343 }
39344
39345 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) {
39346         LDKThirtyTwoBytes chain_hash_arg_ref;
39347         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39348         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39349         LDKCVec_u8Z excess_data_arg_ref;
39350         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
39351         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39352         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
39353         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);
39354         int64_t ret_ref = 0;
39355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39357         return ret_ref;
39358 }
39359
39360 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
39361         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
39362         int64_t ret_ref = 0;
39363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39365         return ret_ref;
39366 }
39367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39368         LDKUnsignedChannelUpdate arg_conv;
39369         arg_conv.inner = untag_ptr(arg);
39370         arg_conv.is_owned = ptr_is_owned(arg);
39371         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39372         arg_conv.is_owned = false;
39373         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
39374         return ret_conv;
39375 }
39376
39377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39378         LDKUnsignedChannelUpdate orig_conv;
39379         orig_conv.inner = untag_ptr(orig);
39380         orig_conv.is_owned = ptr_is_owned(orig);
39381         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39382         orig_conv.is_owned = false;
39383         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
39384         int64_t ret_ref = 0;
39385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39387         return ret_ref;
39388 }
39389
39390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39391         LDKUnsignedChannelUpdate a_conv;
39392         a_conv.inner = untag_ptr(a);
39393         a_conv.is_owned = ptr_is_owned(a);
39394         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39395         a_conv.is_owned = false;
39396         LDKUnsignedChannelUpdate b_conv;
39397         b_conv.inner = untag_ptr(b);
39398         b_conv.is_owned = ptr_is_owned(b);
39399         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39400         b_conv.is_owned = false;
39401         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
39402         return ret_conv;
39403 }
39404
39405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39406         LDKChannelUpdate this_obj_conv;
39407         this_obj_conv.inner = untag_ptr(this_obj);
39408         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39410         ChannelUpdate_free(this_obj_conv);
39411 }
39412
39413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
39414         LDKChannelUpdate this_ptr_conv;
39415         this_ptr_conv.inner = untag_ptr(this_ptr);
39416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39418         this_ptr_conv.is_owned = false;
39419         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39420         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
39421         return ret_arr;
39422 }
39423
39424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39425         LDKChannelUpdate this_ptr_conv;
39426         this_ptr_conv.inner = untag_ptr(this_ptr);
39427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39429         this_ptr_conv.is_owned = false;
39430         LDKSignature val_ref;
39431         CHECK((*env)->GetArrayLength(env, val) == 64);
39432         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39433         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
39434 }
39435
39436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39437         LDKChannelUpdate this_ptr_conv;
39438         this_ptr_conv.inner = untag_ptr(this_ptr);
39439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39441         this_ptr_conv.is_owned = false;
39442         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
39443         int64_t ret_ref = 0;
39444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39446         return ret_ref;
39447 }
39448
39449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39450         LDKChannelUpdate this_ptr_conv;
39451         this_ptr_conv.inner = untag_ptr(this_ptr);
39452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39454         this_ptr_conv.is_owned = false;
39455         LDKUnsignedChannelUpdate val_conv;
39456         val_conv.inner = untag_ptr(val);
39457         val_conv.is_owned = ptr_is_owned(val);
39458         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39459         val_conv = UnsignedChannelUpdate_clone(&val_conv);
39460         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
39461 }
39462
39463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
39464         LDKSignature signature_arg_ref;
39465         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
39466         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
39467         LDKUnsignedChannelUpdate contents_arg_conv;
39468         contents_arg_conv.inner = untag_ptr(contents_arg);
39469         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39471         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
39472         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
39473         int64_t ret_ref = 0;
39474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39476         return ret_ref;
39477 }
39478
39479 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
39480         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
39481         int64_t ret_ref = 0;
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39484         return ret_ref;
39485 }
39486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39487         LDKChannelUpdate arg_conv;
39488         arg_conv.inner = untag_ptr(arg);
39489         arg_conv.is_owned = ptr_is_owned(arg);
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39491         arg_conv.is_owned = false;
39492         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
39493         return ret_conv;
39494 }
39495
39496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39497         LDKChannelUpdate orig_conv;
39498         orig_conv.inner = untag_ptr(orig);
39499         orig_conv.is_owned = ptr_is_owned(orig);
39500         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39501         orig_conv.is_owned = false;
39502         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
39503         int64_t ret_ref = 0;
39504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39506         return ret_ref;
39507 }
39508
39509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39510         LDKChannelUpdate a_conv;
39511         a_conv.inner = untag_ptr(a);
39512         a_conv.is_owned = ptr_is_owned(a);
39513         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39514         a_conv.is_owned = false;
39515         LDKChannelUpdate b_conv;
39516         b_conv.inner = untag_ptr(b);
39517         b_conv.is_owned = ptr_is_owned(b);
39518         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39519         b_conv.is_owned = false;
39520         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
39521         return ret_conv;
39522 }
39523
39524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39525         LDKQueryChannelRange this_obj_conv;
39526         this_obj_conv.inner = untag_ptr(this_obj);
39527         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39529         QueryChannelRange_free(this_obj_conv);
39530 }
39531
39532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39533         LDKQueryChannelRange this_ptr_conv;
39534         this_ptr_conv.inner = untag_ptr(this_ptr);
39535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39537         this_ptr_conv.is_owned = false;
39538         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
39540         return ret_arr;
39541 }
39542
39543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39544         LDKQueryChannelRange this_ptr_conv;
39545         this_ptr_conv.inner = untag_ptr(this_ptr);
39546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39548         this_ptr_conv.is_owned = false;
39549         LDKThirtyTwoBytes val_ref;
39550         CHECK((*env)->GetArrayLength(env, val) == 32);
39551         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39552         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39553 }
39554
39555 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39556         LDKQueryChannelRange this_ptr_conv;
39557         this_ptr_conv.inner = untag_ptr(this_ptr);
39558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39560         this_ptr_conv.is_owned = false;
39561         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
39562         return ret_conv;
39563 }
39564
39565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39566         LDKQueryChannelRange this_ptr_conv;
39567         this_ptr_conv.inner = untag_ptr(this_ptr);
39568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39570         this_ptr_conv.is_owned = false;
39571         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
39572 }
39573
39574 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39575         LDKQueryChannelRange this_ptr_conv;
39576         this_ptr_conv.inner = untag_ptr(this_ptr);
39577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39579         this_ptr_conv.is_owned = false;
39580         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
39581         return ret_conv;
39582 }
39583
39584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39585         LDKQueryChannelRange this_ptr_conv;
39586         this_ptr_conv.inner = untag_ptr(this_ptr);
39587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39589         this_ptr_conv.is_owned = false;
39590         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39591 }
39592
39593 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) {
39594         LDKThirtyTwoBytes chain_hash_arg_ref;
39595         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39596         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39597         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
39598         int64_t ret_ref = 0;
39599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39601         return ret_ref;
39602 }
39603
39604 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
39605         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
39606         int64_t ret_ref = 0;
39607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39609         return ret_ref;
39610 }
39611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39612         LDKQueryChannelRange arg_conv;
39613         arg_conv.inner = untag_ptr(arg);
39614         arg_conv.is_owned = ptr_is_owned(arg);
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39616         arg_conv.is_owned = false;
39617         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
39618         return ret_conv;
39619 }
39620
39621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39622         LDKQueryChannelRange orig_conv;
39623         orig_conv.inner = untag_ptr(orig);
39624         orig_conv.is_owned = ptr_is_owned(orig);
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39626         orig_conv.is_owned = false;
39627         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
39628         int64_t ret_ref = 0;
39629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39631         return ret_ref;
39632 }
39633
39634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39635         LDKQueryChannelRange a_conv;
39636         a_conv.inner = untag_ptr(a);
39637         a_conv.is_owned = ptr_is_owned(a);
39638         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39639         a_conv.is_owned = false;
39640         LDKQueryChannelRange b_conv;
39641         b_conv.inner = untag_ptr(b);
39642         b_conv.is_owned = ptr_is_owned(b);
39643         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39644         b_conv.is_owned = false;
39645         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
39646         return ret_conv;
39647 }
39648
39649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39650         LDKReplyChannelRange this_obj_conv;
39651         this_obj_conv.inner = untag_ptr(this_obj);
39652         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39654         ReplyChannelRange_free(this_obj_conv);
39655 }
39656
39657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39658         LDKReplyChannelRange this_ptr_conv;
39659         this_ptr_conv.inner = untag_ptr(this_ptr);
39660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39662         this_ptr_conv.is_owned = false;
39663         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
39665         return ret_arr;
39666 }
39667
39668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39669         LDKReplyChannelRange this_ptr_conv;
39670         this_ptr_conv.inner = untag_ptr(this_ptr);
39671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39673         this_ptr_conv.is_owned = false;
39674         LDKThirtyTwoBytes val_ref;
39675         CHECK((*env)->GetArrayLength(env, val) == 32);
39676         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39677         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39678 }
39679
39680 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39681         LDKReplyChannelRange this_ptr_conv;
39682         this_ptr_conv.inner = untag_ptr(this_ptr);
39683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39685         this_ptr_conv.is_owned = false;
39686         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
39687         return ret_conv;
39688 }
39689
39690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39691         LDKReplyChannelRange this_ptr_conv;
39692         this_ptr_conv.inner = untag_ptr(this_ptr);
39693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39695         this_ptr_conv.is_owned = false;
39696         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
39697 }
39698
39699 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39700         LDKReplyChannelRange this_ptr_conv;
39701         this_ptr_conv.inner = untag_ptr(this_ptr);
39702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39704         this_ptr_conv.is_owned = false;
39705         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
39706         return ret_conv;
39707 }
39708
39709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39710         LDKReplyChannelRange this_ptr_conv;
39711         this_ptr_conv.inner = untag_ptr(this_ptr);
39712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39714         this_ptr_conv.is_owned = false;
39715         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39716 }
39717
39718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
39719         LDKReplyChannelRange this_ptr_conv;
39720         this_ptr_conv.inner = untag_ptr(this_ptr);
39721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39723         this_ptr_conv.is_owned = false;
39724         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
39725         return ret_conv;
39726 }
39727
39728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39729         LDKReplyChannelRange this_ptr_conv;
39730         this_ptr_conv.inner = untag_ptr(this_ptr);
39731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39733         this_ptr_conv.is_owned = false;
39734         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
39735 }
39736
39737 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39738         LDKReplyChannelRange this_ptr_conv;
39739         this_ptr_conv.inner = untag_ptr(this_ptr);
39740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39742         this_ptr_conv.is_owned = false;
39743         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
39744         int64_tArray ret_arr = NULL;
39745         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39746         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39747         for (size_t g = 0; g < ret_var.datalen; g++) {
39748                 int64_t ret_conv_6_conv = ret_var.data[g];
39749                 ret_arr_ptr[g] = ret_conv_6_conv;
39750         }
39751         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39752         FREE(ret_var.data);
39753         return ret_arr;
39754 }
39755
39756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39757         LDKReplyChannelRange this_ptr_conv;
39758         this_ptr_conv.inner = untag_ptr(this_ptr);
39759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39761         this_ptr_conv.is_owned = false;
39762         LDKCVec_u64Z val_constr;
39763         val_constr.datalen = (*env)->GetArrayLength(env, val);
39764         if (val_constr.datalen > 0)
39765                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39766         else
39767                 val_constr.data = NULL;
39768         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39769         for (size_t g = 0; g < val_constr.datalen; g++) {
39770                 int64_t val_conv_6 = val_vals[g];
39771                 val_constr.data[g] = val_conv_6;
39772         }
39773         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39774         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
39775 }
39776
39777 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) {
39778         LDKThirtyTwoBytes chain_hash_arg_ref;
39779         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39780         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39781         LDKCVec_u64Z short_channel_ids_arg_constr;
39782         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39783         if (short_channel_ids_arg_constr.datalen > 0)
39784                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39785         else
39786                 short_channel_ids_arg_constr.data = NULL;
39787         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39788         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39789                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39790                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39791         }
39792         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39793         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
39794         int64_t ret_ref = 0;
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39797         return ret_ref;
39798 }
39799
39800 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
39801         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
39802         int64_t ret_ref = 0;
39803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39805         return ret_ref;
39806 }
39807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39808         LDKReplyChannelRange arg_conv;
39809         arg_conv.inner = untag_ptr(arg);
39810         arg_conv.is_owned = ptr_is_owned(arg);
39811         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39812         arg_conv.is_owned = false;
39813         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
39814         return ret_conv;
39815 }
39816
39817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39818         LDKReplyChannelRange orig_conv;
39819         orig_conv.inner = untag_ptr(orig);
39820         orig_conv.is_owned = ptr_is_owned(orig);
39821         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39822         orig_conv.is_owned = false;
39823         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
39824         int64_t ret_ref = 0;
39825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39827         return ret_ref;
39828 }
39829
39830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39831         LDKReplyChannelRange a_conv;
39832         a_conv.inner = untag_ptr(a);
39833         a_conv.is_owned = ptr_is_owned(a);
39834         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39835         a_conv.is_owned = false;
39836         LDKReplyChannelRange b_conv;
39837         b_conv.inner = untag_ptr(b);
39838         b_conv.is_owned = ptr_is_owned(b);
39839         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39840         b_conv.is_owned = false;
39841         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
39842         return ret_conv;
39843 }
39844
39845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39846         LDKQueryShortChannelIds this_obj_conv;
39847         this_obj_conv.inner = untag_ptr(this_obj);
39848         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39850         QueryShortChannelIds_free(this_obj_conv);
39851 }
39852
39853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39854         LDKQueryShortChannelIds this_ptr_conv;
39855         this_ptr_conv.inner = untag_ptr(this_ptr);
39856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39858         this_ptr_conv.is_owned = false;
39859         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39861         return ret_arr;
39862 }
39863
39864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39865         LDKQueryShortChannelIds this_ptr_conv;
39866         this_ptr_conv.inner = untag_ptr(this_ptr);
39867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39869         this_ptr_conv.is_owned = false;
39870         LDKThirtyTwoBytes val_ref;
39871         CHECK((*env)->GetArrayLength(env, val) == 32);
39872         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39873         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39874 }
39875
39876 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39877         LDKQueryShortChannelIds this_ptr_conv;
39878         this_ptr_conv.inner = untag_ptr(this_ptr);
39879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39881         this_ptr_conv.is_owned = false;
39882         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39883         int64_tArray ret_arr = NULL;
39884         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39885         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39886         for (size_t g = 0; g < ret_var.datalen; g++) {
39887                 int64_t ret_conv_6_conv = ret_var.data[g];
39888                 ret_arr_ptr[g] = ret_conv_6_conv;
39889         }
39890         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39891         FREE(ret_var.data);
39892         return ret_arr;
39893 }
39894
39895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39896         LDKQueryShortChannelIds this_ptr_conv;
39897         this_ptr_conv.inner = untag_ptr(this_ptr);
39898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39900         this_ptr_conv.is_owned = false;
39901         LDKCVec_u64Z val_constr;
39902         val_constr.datalen = (*env)->GetArrayLength(env, val);
39903         if (val_constr.datalen > 0)
39904                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39905         else
39906                 val_constr.data = NULL;
39907         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39908         for (size_t g = 0; g < val_constr.datalen; g++) {
39909                 int64_t val_conv_6 = val_vals[g];
39910                 val_constr.data[g] = val_conv_6;
39911         }
39912         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39913         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39914 }
39915
39916 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) {
39917         LDKThirtyTwoBytes chain_hash_arg_ref;
39918         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39919         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39920         LDKCVec_u64Z short_channel_ids_arg_constr;
39921         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39922         if (short_channel_ids_arg_constr.datalen > 0)
39923                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39924         else
39925                 short_channel_ids_arg_constr.data = NULL;
39926         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39927         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39928                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39929                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39930         }
39931         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39932         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39933         int64_t ret_ref = 0;
39934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39936         return ret_ref;
39937 }
39938
39939 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39940         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39941         int64_t ret_ref = 0;
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39944         return ret_ref;
39945 }
39946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39947         LDKQueryShortChannelIds arg_conv;
39948         arg_conv.inner = untag_ptr(arg);
39949         arg_conv.is_owned = ptr_is_owned(arg);
39950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39951         arg_conv.is_owned = false;
39952         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39953         return ret_conv;
39954 }
39955
39956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39957         LDKQueryShortChannelIds orig_conv;
39958         orig_conv.inner = untag_ptr(orig);
39959         orig_conv.is_owned = ptr_is_owned(orig);
39960         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39961         orig_conv.is_owned = false;
39962         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39963         int64_t ret_ref = 0;
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39966         return ret_ref;
39967 }
39968
39969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39970         LDKQueryShortChannelIds a_conv;
39971         a_conv.inner = untag_ptr(a);
39972         a_conv.is_owned = ptr_is_owned(a);
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39974         a_conv.is_owned = false;
39975         LDKQueryShortChannelIds b_conv;
39976         b_conv.inner = untag_ptr(b);
39977         b_conv.is_owned = ptr_is_owned(b);
39978         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39979         b_conv.is_owned = false;
39980         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39981         return ret_conv;
39982 }
39983
39984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39985         LDKReplyShortChannelIdsEnd this_obj_conv;
39986         this_obj_conv.inner = untag_ptr(this_obj);
39987         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39989         ReplyShortChannelIdsEnd_free(this_obj_conv);
39990 }
39991
39992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39993         LDKReplyShortChannelIdsEnd this_ptr_conv;
39994         this_ptr_conv.inner = untag_ptr(this_ptr);
39995         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39997         this_ptr_conv.is_owned = false;
39998         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39999         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
40000         return ret_arr;
40001 }
40002
40003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40004         LDKReplyShortChannelIdsEnd this_ptr_conv;
40005         this_ptr_conv.inner = untag_ptr(this_ptr);
40006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40008         this_ptr_conv.is_owned = false;
40009         LDKThirtyTwoBytes val_ref;
40010         CHECK((*env)->GetArrayLength(env, val) == 32);
40011         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40012         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
40013 }
40014
40015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
40016         LDKReplyShortChannelIdsEnd this_ptr_conv;
40017         this_ptr_conv.inner = untag_ptr(this_ptr);
40018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40020         this_ptr_conv.is_owned = false;
40021         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
40022         return ret_conv;
40023 }
40024
40025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40026         LDKReplyShortChannelIdsEnd this_ptr_conv;
40027         this_ptr_conv.inner = untag_ptr(this_ptr);
40028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40030         this_ptr_conv.is_owned = false;
40031         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
40032 }
40033
40034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
40035         LDKThirtyTwoBytes chain_hash_arg_ref;
40036         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40037         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40038         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
40039         int64_t ret_ref = 0;
40040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40042         return ret_ref;
40043 }
40044
40045 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
40046         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
40047         int64_t ret_ref = 0;
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40050         return ret_ref;
40051 }
40052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40053         LDKReplyShortChannelIdsEnd arg_conv;
40054         arg_conv.inner = untag_ptr(arg);
40055         arg_conv.is_owned = ptr_is_owned(arg);
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40057         arg_conv.is_owned = false;
40058         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
40059         return ret_conv;
40060 }
40061
40062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40063         LDKReplyShortChannelIdsEnd orig_conv;
40064         orig_conv.inner = untag_ptr(orig);
40065         orig_conv.is_owned = ptr_is_owned(orig);
40066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40067         orig_conv.is_owned = false;
40068         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
40069         int64_t ret_ref = 0;
40070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40072         return ret_ref;
40073 }
40074
40075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40076         LDKReplyShortChannelIdsEnd a_conv;
40077         a_conv.inner = untag_ptr(a);
40078         a_conv.is_owned = ptr_is_owned(a);
40079         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40080         a_conv.is_owned = false;
40081         LDKReplyShortChannelIdsEnd b_conv;
40082         b_conv.inner = untag_ptr(b);
40083         b_conv.is_owned = ptr_is_owned(b);
40084         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40085         b_conv.is_owned = false;
40086         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
40087         return ret_conv;
40088 }
40089
40090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40091         LDKGossipTimestampFilter this_obj_conv;
40092         this_obj_conv.inner = untag_ptr(this_obj);
40093         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40095         GossipTimestampFilter_free(this_obj_conv);
40096 }
40097
40098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
40099         LDKGossipTimestampFilter this_ptr_conv;
40100         this_ptr_conv.inner = untag_ptr(this_ptr);
40101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40103         this_ptr_conv.is_owned = false;
40104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
40106         return ret_arr;
40107 }
40108
40109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40110         LDKGossipTimestampFilter this_ptr_conv;
40111         this_ptr_conv.inner = untag_ptr(this_ptr);
40112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40114         this_ptr_conv.is_owned = false;
40115         LDKThirtyTwoBytes val_ref;
40116         CHECK((*env)->GetArrayLength(env, val) == 32);
40117         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40118         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
40119 }
40120
40121 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40122         LDKGossipTimestampFilter this_ptr_conv;
40123         this_ptr_conv.inner = untag_ptr(this_ptr);
40124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40126         this_ptr_conv.is_owned = false;
40127         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
40128         return ret_conv;
40129 }
40130
40131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40132         LDKGossipTimestampFilter this_ptr_conv;
40133         this_ptr_conv.inner = untag_ptr(this_ptr);
40134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40136         this_ptr_conv.is_owned = false;
40137         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
40138 }
40139
40140 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
40141         LDKGossipTimestampFilter this_ptr_conv;
40142         this_ptr_conv.inner = untag_ptr(this_ptr);
40143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40145         this_ptr_conv.is_owned = false;
40146         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
40147         return ret_conv;
40148 }
40149
40150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40151         LDKGossipTimestampFilter this_ptr_conv;
40152         this_ptr_conv.inner = untag_ptr(this_ptr);
40153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40155         this_ptr_conv.is_owned = false;
40156         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
40157 }
40158
40159 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) {
40160         LDKThirtyTwoBytes chain_hash_arg_ref;
40161         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40162         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40163         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
40164         int64_t ret_ref = 0;
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40167         return ret_ref;
40168 }
40169
40170 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
40171         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
40172         int64_t ret_ref = 0;
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40175         return ret_ref;
40176 }
40177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40178         LDKGossipTimestampFilter arg_conv;
40179         arg_conv.inner = untag_ptr(arg);
40180         arg_conv.is_owned = ptr_is_owned(arg);
40181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40182         arg_conv.is_owned = false;
40183         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
40184         return ret_conv;
40185 }
40186
40187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40188         LDKGossipTimestampFilter orig_conv;
40189         orig_conv.inner = untag_ptr(orig);
40190         orig_conv.is_owned = ptr_is_owned(orig);
40191         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40192         orig_conv.is_owned = false;
40193         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
40194         int64_t ret_ref = 0;
40195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40197         return ret_ref;
40198 }
40199
40200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40201         LDKGossipTimestampFilter a_conv;
40202         a_conv.inner = untag_ptr(a);
40203         a_conv.is_owned = ptr_is_owned(a);
40204         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40205         a_conv.is_owned = false;
40206         LDKGossipTimestampFilter b_conv;
40207         b_conv.inner = untag_ptr(b);
40208         b_conv.is_owned = ptr_is_owned(b);
40209         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40210         b_conv.is_owned = false;
40211         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
40212         return ret_conv;
40213 }
40214
40215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40216         if (!ptr_is_owned(this_ptr)) return;
40217         void* this_ptr_ptr = untag_ptr(this_ptr);
40218         CHECK_ACCESS(this_ptr_ptr);
40219         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
40220         FREE(untag_ptr(this_ptr));
40221         ErrorAction_free(this_ptr_conv);
40222 }
40223
40224 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
40225         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40226         *ret_copy = ErrorAction_clone(arg);
40227         int64_t ret_ref = tag_ptr(ret_copy, true);
40228         return ret_ref;
40229 }
40230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40231         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
40232         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
40233         return ret_conv;
40234 }
40235
40236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40237         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
40238         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40239         *ret_copy = ErrorAction_clone(orig_conv);
40240         int64_t ret_ref = tag_ptr(ret_copy, true);
40241         return ret_ref;
40242 }
40243
40244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
40245         LDKErrorMessage msg_conv;
40246         msg_conv.inner = untag_ptr(msg);
40247         msg_conv.is_owned = ptr_is_owned(msg);
40248         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40249         msg_conv = ErrorMessage_clone(&msg_conv);
40250         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40251         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
40252         int64_t ret_ref = tag_ptr(ret_copy, true);
40253         return ret_ref;
40254 }
40255
40256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
40257         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40258         *ret_copy = ErrorAction_ignore_error();
40259         int64_t ret_ref = tag_ptr(ret_copy, true);
40260         return ret_ref;
40261 }
40262
40263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
40264         LDKLevel a_conv = LDKLevel_from_java(env, a);
40265         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40266         *ret_copy = ErrorAction_ignore_and_log(a_conv);
40267         int64_t ret_ref = tag_ptr(ret_copy, true);
40268         return ret_ref;
40269 }
40270
40271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
40272         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40273         *ret_copy = ErrorAction_ignore_duplicate_gossip();
40274         int64_t ret_ref = tag_ptr(ret_copy, true);
40275         return ret_ref;
40276 }
40277
40278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
40279         LDKErrorMessage msg_conv;
40280         msg_conv.inner = untag_ptr(msg);
40281         msg_conv.is_owned = ptr_is_owned(msg);
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40283         msg_conv = ErrorMessage_clone(&msg_conv);
40284         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40285         *ret_copy = ErrorAction_send_error_message(msg_conv);
40286         int64_t ret_ref = tag_ptr(ret_copy, true);
40287         return ret_ref;
40288 }
40289
40290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
40291         LDKWarningMessage msg_conv;
40292         msg_conv.inner = untag_ptr(msg);
40293         msg_conv.is_owned = ptr_is_owned(msg);
40294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40295         msg_conv = WarningMessage_clone(&msg_conv);
40296         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
40297         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40298         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
40299         int64_t ret_ref = tag_ptr(ret_copy, true);
40300         return ret_ref;
40301 }
40302
40303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40304         LDKLightningError this_obj_conv;
40305         this_obj_conv.inner = untag_ptr(this_obj);
40306         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40308         LightningError_free(this_obj_conv);
40309 }
40310
40311 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
40312         LDKLightningError this_ptr_conv;
40313         this_ptr_conv.inner = untag_ptr(this_ptr);
40314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40316         this_ptr_conv.is_owned = false;
40317         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
40318         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40319         Str_free(ret_str);
40320         return ret_conv;
40321 }
40322
40323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
40324         LDKLightningError this_ptr_conv;
40325         this_ptr_conv.inner = untag_ptr(this_ptr);
40326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40328         this_ptr_conv.is_owned = false;
40329         LDKStr val_conv = java_to_owned_str(env, val);
40330         LightningError_set_err(&this_ptr_conv, val_conv);
40331 }
40332
40333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
40334         LDKLightningError this_ptr_conv;
40335         this_ptr_conv.inner = untag_ptr(this_ptr);
40336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40338         this_ptr_conv.is_owned = false;
40339         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40340         *ret_copy = LightningError_get_action(&this_ptr_conv);
40341         int64_t ret_ref = tag_ptr(ret_copy, true);
40342         return ret_ref;
40343 }
40344
40345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40346         LDKLightningError this_ptr_conv;
40347         this_ptr_conv.inner = untag_ptr(this_ptr);
40348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40350         this_ptr_conv.is_owned = false;
40351         void* val_ptr = untag_ptr(val);
40352         CHECK_ACCESS(val_ptr);
40353         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
40354         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
40355         LightningError_set_action(&this_ptr_conv, val_conv);
40356 }
40357
40358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
40359         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
40360         void* action_arg_ptr = untag_ptr(action_arg);
40361         CHECK_ACCESS(action_arg_ptr);
40362         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
40363         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
40364         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
40365         int64_t ret_ref = 0;
40366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40368         return ret_ref;
40369 }
40370
40371 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
40372         LDKLightningError ret_var = LightningError_clone(arg);
40373         int64_t ret_ref = 0;
40374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40376         return ret_ref;
40377 }
40378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40379         LDKLightningError arg_conv;
40380         arg_conv.inner = untag_ptr(arg);
40381         arg_conv.is_owned = ptr_is_owned(arg);
40382         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40383         arg_conv.is_owned = false;
40384         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
40385         return ret_conv;
40386 }
40387
40388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40389         LDKLightningError orig_conv;
40390         orig_conv.inner = untag_ptr(orig);
40391         orig_conv.is_owned = ptr_is_owned(orig);
40392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40393         orig_conv.is_owned = false;
40394         LDKLightningError ret_var = LightningError_clone(&orig_conv);
40395         int64_t ret_ref = 0;
40396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40397         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40398         return ret_ref;
40399 }
40400
40401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40402         LDKCommitmentUpdate this_obj_conv;
40403         this_obj_conv.inner = untag_ptr(this_obj);
40404         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40406         CommitmentUpdate_free(this_obj_conv);
40407 }
40408
40409 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40410         LDKCommitmentUpdate this_ptr_conv;
40411         this_ptr_conv.inner = untag_ptr(this_ptr);
40412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40414         this_ptr_conv.is_owned = false;
40415         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
40416         int64_tArray ret_arr = NULL;
40417         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40418         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40419         for (size_t p = 0; p < ret_var.datalen; p++) {
40420                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
40421                 int64_t ret_conv_15_ref = 0;
40422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
40423                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
40424                 ret_arr_ptr[p] = ret_conv_15_ref;
40425         }
40426         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40427         FREE(ret_var.data);
40428         return ret_arr;
40429 }
40430
40431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40432         LDKCommitmentUpdate this_ptr_conv;
40433         this_ptr_conv.inner = untag_ptr(this_ptr);
40434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40436         this_ptr_conv.is_owned = false;
40437         LDKCVec_UpdateAddHTLCZ val_constr;
40438         val_constr.datalen = (*env)->GetArrayLength(env, val);
40439         if (val_constr.datalen > 0)
40440                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40441         else
40442                 val_constr.data = NULL;
40443         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40444         for (size_t p = 0; p < val_constr.datalen; p++) {
40445                 int64_t val_conv_15 = val_vals[p];
40446                 LDKUpdateAddHTLC val_conv_15_conv;
40447                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
40448                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
40449                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
40450                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
40451                 val_constr.data[p] = val_conv_15_conv;
40452         }
40453         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40454         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
40455 }
40456
40457 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40458         LDKCommitmentUpdate this_ptr_conv;
40459         this_ptr_conv.inner = untag_ptr(this_ptr);
40460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40462         this_ptr_conv.is_owned = false;
40463         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
40464         int64_tArray ret_arr = NULL;
40465         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40466         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40467         for (size_t t = 0; t < ret_var.datalen; t++) {
40468                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
40469                 int64_t ret_conv_19_ref = 0;
40470                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
40471                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
40472                 ret_arr_ptr[t] = ret_conv_19_ref;
40473         }
40474         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40475         FREE(ret_var.data);
40476         return ret_arr;
40477 }
40478
40479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40480         LDKCommitmentUpdate this_ptr_conv;
40481         this_ptr_conv.inner = untag_ptr(this_ptr);
40482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40484         this_ptr_conv.is_owned = false;
40485         LDKCVec_UpdateFulfillHTLCZ val_constr;
40486         val_constr.datalen = (*env)->GetArrayLength(env, val);
40487         if (val_constr.datalen > 0)
40488                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40489         else
40490                 val_constr.data = NULL;
40491         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40492         for (size_t t = 0; t < val_constr.datalen; t++) {
40493                 int64_t val_conv_19 = val_vals[t];
40494                 LDKUpdateFulfillHTLC val_conv_19_conv;
40495                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
40496                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
40497                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
40498                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
40499                 val_constr.data[t] = val_conv_19_conv;
40500         }
40501         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40502         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
40503 }
40504
40505 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40506         LDKCommitmentUpdate this_ptr_conv;
40507         this_ptr_conv.inner = untag_ptr(this_ptr);
40508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40510         this_ptr_conv.is_owned = false;
40511         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
40512         int64_tArray ret_arr = NULL;
40513         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40514         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40515         for (size_t q = 0; q < ret_var.datalen; q++) {
40516                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
40517                 int64_t ret_conv_16_ref = 0;
40518                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
40519                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
40520                 ret_arr_ptr[q] = ret_conv_16_ref;
40521         }
40522         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40523         FREE(ret_var.data);
40524         return ret_arr;
40525 }
40526
40527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40528         LDKCommitmentUpdate this_ptr_conv;
40529         this_ptr_conv.inner = untag_ptr(this_ptr);
40530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40532         this_ptr_conv.is_owned = false;
40533         LDKCVec_UpdateFailHTLCZ val_constr;
40534         val_constr.datalen = (*env)->GetArrayLength(env, val);
40535         if (val_constr.datalen > 0)
40536                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40537         else
40538                 val_constr.data = NULL;
40539         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40540         for (size_t q = 0; q < val_constr.datalen; q++) {
40541                 int64_t val_conv_16 = val_vals[q];
40542                 LDKUpdateFailHTLC val_conv_16_conv;
40543                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
40544                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
40545                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
40546                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
40547                 val_constr.data[q] = val_conv_16_conv;
40548         }
40549         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40550         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
40551 }
40552
40553 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40554         LDKCommitmentUpdate this_ptr_conv;
40555         this_ptr_conv.inner = untag_ptr(this_ptr);
40556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40558         this_ptr_conv.is_owned = false;
40559         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
40560         int64_tArray ret_arr = NULL;
40561         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40562         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40563         for (size_t z = 0; z < ret_var.datalen; z++) {
40564                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
40565                 int64_t ret_conv_25_ref = 0;
40566                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
40567                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
40568                 ret_arr_ptr[z] = ret_conv_25_ref;
40569         }
40570         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40571         FREE(ret_var.data);
40572         return ret_arr;
40573 }
40574
40575 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) {
40576         LDKCommitmentUpdate this_ptr_conv;
40577         this_ptr_conv.inner = untag_ptr(this_ptr);
40578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40580         this_ptr_conv.is_owned = false;
40581         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
40582         val_constr.datalen = (*env)->GetArrayLength(env, val);
40583         if (val_constr.datalen > 0)
40584                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40585         else
40586                 val_constr.data = NULL;
40587         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40588         for (size_t z = 0; z < val_constr.datalen; z++) {
40589                 int64_t val_conv_25 = val_vals[z];
40590                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
40591                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
40592                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
40593                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
40594                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
40595                 val_constr.data[z] = val_conv_25_conv;
40596         }
40597         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40598         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
40599 }
40600
40601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
40602         LDKCommitmentUpdate this_ptr_conv;
40603         this_ptr_conv.inner = untag_ptr(this_ptr);
40604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40606         this_ptr_conv.is_owned = false;
40607         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
40608         int64_t ret_ref = 0;
40609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40610         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40611         return ret_ref;
40612 }
40613
40614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40615         LDKCommitmentUpdate this_ptr_conv;
40616         this_ptr_conv.inner = untag_ptr(this_ptr);
40617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40619         this_ptr_conv.is_owned = false;
40620         LDKUpdateFee val_conv;
40621         val_conv.inner = untag_ptr(val);
40622         val_conv.is_owned = ptr_is_owned(val);
40623         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40624         val_conv = UpdateFee_clone(&val_conv);
40625         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
40626 }
40627
40628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
40629         LDKCommitmentUpdate this_ptr_conv;
40630         this_ptr_conv.inner = untag_ptr(this_ptr);
40631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40633         this_ptr_conv.is_owned = false;
40634         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
40635         int64_t ret_ref = 0;
40636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40638         return ret_ref;
40639 }
40640
40641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40642         LDKCommitmentUpdate this_ptr_conv;
40643         this_ptr_conv.inner = untag_ptr(this_ptr);
40644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40646         this_ptr_conv.is_owned = false;
40647         LDKCommitmentSigned val_conv;
40648         val_conv.inner = untag_ptr(val);
40649         val_conv.is_owned = ptr_is_owned(val);
40650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40651         val_conv = CommitmentSigned_clone(&val_conv);
40652         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
40653 }
40654
40655 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) {
40656         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
40657         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
40658         if (update_add_htlcs_arg_constr.datalen > 0)
40659                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40660         else
40661                 update_add_htlcs_arg_constr.data = NULL;
40662         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
40663         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
40664                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
40665                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
40666                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
40667                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
40668                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
40669                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
40670                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
40671         }
40672         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
40673         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
40674         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
40675         if (update_fulfill_htlcs_arg_constr.datalen > 0)
40676                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40677         else
40678                 update_fulfill_htlcs_arg_constr.data = NULL;
40679         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
40680         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
40681                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
40682                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
40683                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
40684                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
40685                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
40686                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
40687                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
40688         }
40689         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
40690         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
40691         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
40692         if (update_fail_htlcs_arg_constr.datalen > 0)
40693                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40694         else
40695                 update_fail_htlcs_arg_constr.data = NULL;
40696         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
40697         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
40698                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
40699                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
40700                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
40701                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
40702                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
40703                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
40704                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
40705         }
40706         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
40707         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
40708         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
40709         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
40710                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40711         else
40712                 update_fail_malformed_htlcs_arg_constr.data = NULL;
40713         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
40714         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
40715                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
40716                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
40717                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
40718                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
40719                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
40720                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
40721                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
40722         }
40723         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
40724         LDKUpdateFee update_fee_arg_conv;
40725         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
40726         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
40727         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
40728         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
40729         LDKCommitmentSigned commitment_signed_arg_conv;
40730         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
40731         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
40733         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
40734         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);
40735         int64_t ret_ref = 0;
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40738         return ret_ref;
40739 }
40740
40741 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
40742         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
40743         int64_t ret_ref = 0;
40744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40746         return ret_ref;
40747 }
40748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40749         LDKCommitmentUpdate arg_conv;
40750         arg_conv.inner = untag_ptr(arg);
40751         arg_conv.is_owned = ptr_is_owned(arg);
40752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40753         arg_conv.is_owned = false;
40754         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
40755         return ret_conv;
40756 }
40757
40758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40759         LDKCommitmentUpdate orig_conv;
40760         orig_conv.inner = untag_ptr(orig);
40761         orig_conv.is_owned = ptr_is_owned(orig);
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40763         orig_conv.is_owned = false;
40764         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
40765         int64_t ret_ref = 0;
40766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40768         return ret_ref;
40769 }
40770
40771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40772         LDKCommitmentUpdate a_conv;
40773         a_conv.inner = untag_ptr(a);
40774         a_conv.is_owned = ptr_is_owned(a);
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40776         a_conv.is_owned = false;
40777         LDKCommitmentUpdate b_conv;
40778         b_conv.inner = untag_ptr(b);
40779         b_conv.is_owned = ptr_is_owned(b);
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40781         b_conv.is_owned = false;
40782         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
40783         return ret_conv;
40784 }
40785
40786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40787         if (!ptr_is_owned(this_ptr)) return;
40788         void* this_ptr_ptr = untag_ptr(this_ptr);
40789         CHECK_ACCESS(this_ptr_ptr);
40790         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
40791         FREE(untag_ptr(this_ptr));
40792         ChannelMessageHandler_free(this_ptr_conv);
40793 }
40794
40795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40796         if (!ptr_is_owned(this_ptr)) return;
40797         void* this_ptr_ptr = untag_ptr(this_ptr);
40798         CHECK_ACCESS(this_ptr_ptr);
40799         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
40800         FREE(untag_ptr(this_ptr));
40801         RoutingMessageHandler_free(this_ptr_conv);
40802 }
40803
40804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40805         if (!ptr_is_owned(this_ptr)) return;
40806         void* this_ptr_ptr = untag_ptr(this_ptr);
40807         CHECK_ACCESS(this_ptr_ptr);
40808         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
40809         FREE(untag_ptr(this_ptr));
40810         OnionMessageHandler_free(this_ptr_conv);
40811 }
40812
40813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40814         LDKAcceptChannel obj_conv;
40815         obj_conv.inner = untag_ptr(obj);
40816         obj_conv.is_owned = ptr_is_owned(obj);
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40818         obj_conv.is_owned = false;
40819         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
40820         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40821         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40822         CVec_u8Z_free(ret_var);
40823         return ret_arr;
40824 }
40825
40826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40827         LDKu8slice ser_ref;
40828         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40829         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40830         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
40831         *ret_conv = AcceptChannel_read(ser_ref);
40832         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40833         return tag_ptr(ret_conv, true);
40834 }
40835
40836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40837         LDKAnnouncementSignatures obj_conv;
40838         obj_conv.inner = untag_ptr(obj);
40839         obj_conv.is_owned = ptr_is_owned(obj);
40840         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40841         obj_conv.is_owned = false;
40842         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
40843         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40844         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40845         CVec_u8Z_free(ret_var);
40846         return ret_arr;
40847 }
40848
40849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40850         LDKu8slice ser_ref;
40851         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40852         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40853         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40854         *ret_conv = AnnouncementSignatures_read(ser_ref);
40855         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40856         return tag_ptr(ret_conv, true);
40857 }
40858
40859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40860         LDKChannelReestablish obj_conv;
40861         obj_conv.inner = untag_ptr(obj);
40862         obj_conv.is_owned = ptr_is_owned(obj);
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40864         obj_conv.is_owned = false;
40865         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40868         CVec_u8Z_free(ret_var);
40869         return ret_arr;
40870 }
40871
40872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40873         LDKu8slice ser_ref;
40874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40876         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40877         *ret_conv = ChannelReestablish_read(ser_ref);
40878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40879         return tag_ptr(ret_conv, true);
40880 }
40881
40882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40883         LDKClosingSigned obj_conv;
40884         obj_conv.inner = untag_ptr(obj);
40885         obj_conv.is_owned = ptr_is_owned(obj);
40886         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40887         obj_conv.is_owned = false;
40888         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40891         CVec_u8Z_free(ret_var);
40892         return ret_arr;
40893 }
40894
40895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40896         LDKu8slice ser_ref;
40897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40899         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40900         *ret_conv = ClosingSigned_read(ser_ref);
40901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40902         return tag_ptr(ret_conv, true);
40903 }
40904
40905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40906         LDKClosingSignedFeeRange obj_conv;
40907         obj_conv.inner = untag_ptr(obj);
40908         obj_conv.is_owned = ptr_is_owned(obj);
40909         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40910         obj_conv.is_owned = false;
40911         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40914         CVec_u8Z_free(ret_var);
40915         return ret_arr;
40916 }
40917
40918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40919         LDKu8slice ser_ref;
40920         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40921         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40922         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40923         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40924         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40925         return tag_ptr(ret_conv, true);
40926 }
40927
40928 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40929         LDKCommitmentSigned obj_conv;
40930         obj_conv.inner = untag_ptr(obj);
40931         obj_conv.is_owned = ptr_is_owned(obj);
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40933         obj_conv.is_owned = false;
40934         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40935         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40936         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40937         CVec_u8Z_free(ret_var);
40938         return ret_arr;
40939 }
40940
40941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40942         LDKu8slice ser_ref;
40943         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40944         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40945         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40946         *ret_conv = CommitmentSigned_read(ser_ref);
40947         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40948         return tag_ptr(ret_conv, true);
40949 }
40950
40951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40952         LDKFundingCreated obj_conv;
40953         obj_conv.inner = untag_ptr(obj);
40954         obj_conv.is_owned = ptr_is_owned(obj);
40955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40956         obj_conv.is_owned = false;
40957         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40958         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40959         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40960         CVec_u8Z_free(ret_var);
40961         return ret_arr;
40962 }
40963
40964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40965         LDKu8slice ser_ref;
40966         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40967         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40968         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40969         *ret_conv = FundingCreated_read(ser_ref);
40970         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40971         return tag_ptr(ret_conv, true);
40972 }
40973
40974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40975         LDKFundingSigned obj_conv;
40976         obj_conv.inner = untag_ptr(obj);
40977         obj_conv.is_owned = ptr_is_owned(obj);
40978         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40979         obj_conv.is_owned = false;
40980         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40983         CVec_u8Z_free(ret_var);
40984         return ret_arr;
40985 }
40986
40987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40988         LDKu8slice ser_ref;
40989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40991         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40992         *ret_conv = FundingSigned_read(ser_ref);
40993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40994         return tag_ptr(ret_conv, true);
40995 }
40996
40997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40998         LDKChannelReady obj_conv;
40999         obj_conv.inner = untag_ptr(obj);
41000         obj_conv.is_owned = ptr_is_owned(obj);
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41002         obj_conv.is_owned = false;
41003         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
41004         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41005         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41006         CVec_u8Z_free(ret_var);
41007         return ret_arr;
41008 }
41009
41010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41011         LDKu8slice ser_ref;
41012         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41013         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41014         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
41015         *ret_conv = ChannelReady_read(ser_ref);
41016         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41017         return tag_ptr(ret_conv, true);
41018 }
41019
41020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
41021         LDKInit obj_conv;
41022         obj_conv.inner = untag_ptr(obj);
41023         obj_conv.is_owned = ptr_is_owned(obj);
41024         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41025         obj_conv.is_owned = false;
41026         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
41027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41029         CVec_u8Z_free(ret_var);
41030         return ret_arr;
41031 }
41032
41033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41034         LDKu8slice ser_ref;
41035         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41036         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41037         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
41038         *ret_conv = Init_read(ser_ref);
41039         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41040         return tag_ptr(ret_conv, true);
41041 }
41042
41043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
41044         LDKOpenChannel obj_conv;
41045         obj_conv.inner = untag_ptr(obj);
41046         obj_conv.is_owned = ptr_is_owned(obj);
41047         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41048         obj_conv.is_owned = false;
41049         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
41050         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41051         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41052         CVec_u8Z_free(ret_var);
41053         return ret_arr;
41054 }
41055
41056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41057         LDKu8slice ser_ref;
41058         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41059         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41060         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
41061         *ret_conv = OpenChannel_read(ser_ref);
41062         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41063         return tag_ptr(ret_conv, true);
41064 }
41065
41066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
41067         LDKRevokeAndACK obj_conv;
41068         obj_conv.inner = untag_ptr(obj);
41069         obj_conv.is_owned = ptr_is_owned(obj);
41070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41071         obj_conv.is_owned = false;
41072         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
41073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41075         CVec_u8Z_free(ret_var);
41076         return ret_arr;
41077 }
41078
41079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41080         LDKu8slice ser_ref;
41081         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41082         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41083         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
41084         *ret_conv = RevokeAndACK_read(ser_ref);
41085         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41086         return tag_ptr(ret_conv, true);
41087 }
41088
41089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
41090         LDKShutdown obj_conv;
41091         obj_conv.inner = untag_ptr(obj);
41092         obj_conv.is_owned = ptr_is_owned(obj);
41093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41094         obj_conv.is_owned = false;
41095         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
41096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41098         CVec_u8Z_free(ret_var);
41099         return ret_arr;
41100 }
41101
41102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41103         LDKu8slice ser_ref;
41104         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41105         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41106         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
41107         *ret_conv = Shutdown_read(ser_ref);
41108         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41109         return tag_ptr(ret_conv, true);
41110 }
41111
41112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41113         LDKUpdateFailHTLC obj_conv;
41114         obj_conv.inner = untag_ptr(obj);
41115         obj_conv.is_owned = ptr_is_owned(obj);
41116         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41117         obj_conv.is_owned = false;
41118         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
41119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41121         CVec_u8Z_free(ret_var);
41122         return ret_arr;
41123 }
41124
41125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41126         LDKu8slice ser_ref;
41127         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41128         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41129         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
41130         *ret_conv = UpdateFailHTLC_read(ser_ref);
41131         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41132         return tag_ptr(ret_conv, true);
41133 }
41134
41135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41136         LDKUpdateFailMalformedHTLC obj_conv;
41137         obj_conv.inner = untag_ptr(obj);
41138         obj_conv.is_owned = ptr_is_owned(obj);
41139         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41140         obj_conv.is_owned = false;
41141         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
41142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41144         CVec_u8Z_free(ret_var);
41145         return ret_arr;
41146 }
41147
41148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41149         LDKu8slice ser_ref;
41150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41152         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
41153         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
41154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41155         return tag_ptr(ret_conv, true);
41156 }
41157
41158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
41159         LDKUpdateFee obj_conv;
41160         obj_conv.inner = untag_ptr(obj);
41161         obj_conv.is_owned = ptr_is_owned(obj);
41162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41163         obj_conv.is_owned = false;
41164         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
41165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41167         CVec_u8Z_free(ret_var);
41168         return ret_arr;
41169 }
41170
41171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41172         LDKu8slice ser_ref;
41173         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41174         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41175         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
41176         *ret_conv = UpdateFee_read(ser_ref);
41177         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41178         return tag_ptr(ret_conv, true);
41179 }
41180
41181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41182         LDKUpdateFulfillHTLC obj_conv;
41183         obj_conv.inner = untag_ptr(obj);
41184         obj_conv.is_owned = ptr_is_owned(obj);
41185         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41186         obj_conv.is_owned = false;
41187         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
41188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41190         CVec_u8Z_free(ret_var);
41191         return ret_arr;
41192 }
41193
41194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41195         LDKu8slice ser_ref;
41196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41198         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
41199         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
41200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41201         return tag_ptr(ret_conv, true);
41202 }
41203
41204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41205         LDKUpdateAddHTLC obj_conv;
41206         obj_conv.inner = untag_ptr(obj);
41207         obj_conv.is_owned = ptr_is_owned(obj);
41208         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41209         obj_conv.is_owned = false;
41210         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
41211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41213         CVec_u8Z_free(ret_var);
41214         return ret_arr;
41215 }
41216
41217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41218         LDKu8slice ser_ref;
41219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41221         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
41222         *ret_conv = UpdateAddHTLC_read(ser_ref);
41223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41224         return tag_ptr(ret_conv, true);
41225 }
41226
41227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41228         LDKu8slice ser_ref;
41229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41231         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
41232         *ret_conv = OnionMessage_read(ser_ref);
41233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41234         return tag_ptr(ret_conv, true);
41235 }
41236
41237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41238         LDKOnionMessage obj_conv;
41239         obj_conv.inner = untag_ptr(obj);
41240         obj_conv.is_owned = ptr_is_owned(obj);
41241         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41242         obj_conv.is_owned = false;
41243         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
41244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41246         CVec_u8Z_free(ret_var);
41247         return ret_arr;
41248 }
41249
41250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
41251         LDKPing obj_conv;
41252         obj_conv.inner = untag_ptr(obj);
41253         obj_conv.is_owned = ptr_is_owned(obj);
41254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41255         obj_conv.is_owned = false;
41256         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
41257         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41258         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41259         CVec_u8Z_free(ret_var);
41260         return ret_arr;
41261 }
41262
41263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41264         LDKu8slice ser_ref;
41265         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41266         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41267         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
41268         *ret_conv = Ping_read(ser_ref);
41269         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41270         return tag_ptr(ret_conv, true);
41271 }
41272
41273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
41274         LDKPong obj_conv;
41275         obj_conv.inner = untag_ptr(obj);
41276         obj_conv.is_owned = ptr_is_owned(obj);
41277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41278         obj_conv.is_owned = false;
41279         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
41280         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41281         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41282         CVec_u8Z_free(ret_var);
41283         return ret_arr;
41284 }
41285
41286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41287         LDKu8slice ser_ref;
41288         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41289         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41290         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
41291         *ret_conv = Pong_read(ser_ref);
41292         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41293         return tag_ptr(ret_conv, true);
41294 }
41295
41296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41297         LDKUnsignedChannelAnnouncement obj_conv;
41298         obj_conv.inner = untag_ptr(obj);
41299         obj_conv.is_owned = ptr_is_owned(obj);
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41301         obj_conv.is_owned = false;
41302         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
41303         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41304         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41305         CVec_u8Z_free(ret_var);
41306         return ret_arr;
41307 }
41308
41309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41310         LDKu8slice ser_ref;
41311         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41312         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41313         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
41314         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
41315         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41316         return tag_ptr(ret_conv, true);
41317 }
41318
41319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41320         LDKChannelAnnouncement obj_conv;
41321         obj_conv.inner = untag_ptr(obj);
41322         obj_conv.is_owned = ptr_is_owned(obj);
41323         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41324         obj_conv.is_owned = false;
41325         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
41326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41328         CVec_u8Z_free(ret_var);
41329         return ret_arr;
41330 }
41331
41332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41333         LDKu8slice ser_ref;
41334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41336         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
41337         *ret_conv = ChannelAnnouncement_read(ser_ref);
41338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41339         return tag_ptr(ret_conv, true);
41340 }
41341
41342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41343         LDKUnsignedChannelUpdate obj_conv;
41344         obj_conv.inner = untag_ptr(obj);
41345         obj_conv.is_owned = ptr_is_owned(obj);
41346         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41347         obj_conv.is_owned = false;
41348         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
41349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41351         CVec_u8Z_free(ret_var);
41352         return ret_arr;
41353 }
41354
41355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41356         LDKu8slice ser_ref;
41357         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41358         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41359         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
41360         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
41361         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41362         return tag_ptr(ret_conv, true);
41363 }
41364
41365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41366         LDKChannelUpdate obj_conv;
41367         obj_conv.inner = untag_ptr(obj);
41368         obj_conv.is_owned = ptr_is_owned(obj);
41369         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41370         obj_conv.is_owned = false;
41371         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
41372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41374         CVec_u8Z_free(ret_var);
41375         return ret_arr;
41376 }
41377
41378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41379         LDKu8slice ser_ref;
41380         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41381         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41382         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
41383         *ret_conv = ChannelUpdate_read(ser_ref);
41384         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41385         return tag_ptr(ret_conv, true);
41386 }
41387
41388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41389         LDKErrorMessage obj_conv;
41390         obj_conv.inner = untag_ptr(obj);
41391         obj_conv.is_owned = ptr_is_owned(obj);
41392         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41393         obj_conv.is_owned = false;
41394         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
41395         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41396         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41397         CVec_u8Z_free(ret_var);
41398         return ret_arr;
41399 }
41400
41401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41402         LDKu8slice ser_ref;
41403         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41404         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41405         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
41406         *ret_conv = ErrorMessage_read(ser_ref);
41407         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41408         return tag_ptr(ret_conv, true);
41409 }
41410
41411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41412         LDKWarningMessage obj_conv;
41413         obj_conv.inner = untag_ptr(obj);
41414         obj_conv.is_owned = ptr_is_owned(obj);
41415         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41416         obj_conv.is_owned = false;
41417         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
41418         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41419         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41420         CVec_u8Z_free(ret_var);
41421         return ret_arr;
41422 }
41423
41424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41425         LDKu8slice ser_ref;
41426         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41427         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41428         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
41429         *ret_conv = WarningMessage_read(ser_ref);
41430         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41431         return tag_ptr(ret_conv, true);
41432 }
41433
41434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41435         LDKUnsignedNodeAnnouncement obj_conv;
41436         obj_conv.inner = untag_ptr(obj);
41437         obj_conv.is_owned = ptr_is_owned(obj);
41438         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41439         obj_conv.is_owned = false;
41440         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
41441         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41442         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41443         CVec_u8Z_free(ret_var);
41444         return ret_arr;
41445 }
41446
41447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41448         LDKu8slice ser_ref;
41449         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41450         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41451         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
41452         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
41453         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41454         return tag_ptr(ret_conv, true);
41455 }
41456
41457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41458         LDKNodeAnnouncement obj_conv;
41459         obj_conv.inner = untag_ptr(obj);
41460         obj_conv.is_owned = ptr_is_owned(obj);
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41462         obj_conv.is_owned = false;
41463         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
41464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41466         CVec_u8Z_free(ret_var);
41467         return ret_arr;
41468 }
41469
41470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41471         LDKu8slice ser_ref;
41472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41474         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
41475         *ret_conv = NodeAnnouncement_read(ser_ref);
41476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41477         return tag_ptr(ret_conv, true);
41478 }
41479
41480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41481         LDKu8slice ser_ref;
41482         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41483         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41484         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
41485         *ret_conv = QueryShortChannelIds_read(ser_ref);
41486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41487         return tag_ptr(ret_conv, true);
41488 }
41489
41490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
41491         LDKQueryShortChannelIds obj_conv;
41492         obj_conv.inner = untag_ptr(obj);
41493         obj_conv.is_owned = ptr_is_owned(obj);
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41495         obj_conv.is_owned = false;
41496         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
41497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41499         CVec_u8Z_free(ret_var);
41500         return ret_arr;
41501 }
41502
41503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
41504         LDKReplyShortChannelIdsEnd obj_conv;
41505         obj_conv.inner = untag_ptr(obj);
41506         obj_conv.is_owned = ptr_is_owned(obj);
41507         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41508         obj_conv.is_owned = false;
41509         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
41510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41512         CVec_u8Z_free(ret_var);
41513         return ret_arr;
41514 }
41515
41516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41517         LDKu8slice ser_ref;
41518         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41519         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41520         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
41521         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
41522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41523         return tag_ptr(ret_conv, true);
41524 }
41525
41526 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
41527         LDKQueryChannelRange this_arg_conv;
41528         this_arg_conv.inner = untag_ptr(this_arg);
41529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41531         this_arg_conv.is_owned = false;
41532         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
41533         return ret_conv;
41534 }
41535
41536 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41537         LDKQueryChannelRange obj_conv;
41538         obj_conv.inner = untag_ptr(obj);
41539         obj_conv.is_owned = ptr_is_owned(obj);
41540         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41541         obj_conv.is_owned = false;
41542         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
41543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41545         CVec_u8Z_free(ret_var);
41546         return ret_arr;
41547 }
41548
41549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41550         LDKu8slice ser_ref;
41551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41553         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
41554         *ret_conv = QueryChannelRange_read(ser_ref);
41555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41556         return tag_ptr(ret_conv, true);
41557 }
41558
41559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41560         LDKu8slice ser_ref;
41561         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41562         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41563         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
41564         *ret_conv = ReplyChannelRange_read(ser_ref);
41565         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41566         return tag_ptr(ret_conv, true);
41567 }
41568
41569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41570         LDKReplyChannelRange obj_conv;
41571         obj_conv.inner = untag_ptr(obj);
41572         obj_conv.is_owned = ptr_is_owned(obj);
41573         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41574         obj_conv.is_owned = false;
41575         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
41576         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41577         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41578         CVec_u8Z_free(ret_var);
41579         return ret_arr;
41580 }
41581
41582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
41583         LDKGossipTimestampFilter obj_conv;
41584         obj_conv.inner = untag_ptr(obj);
41585         obj_conv.is_owned = ptr_is_owned(obj);
41586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41587         obj_conv.is_owned = false;
41588         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
41589         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41590         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41591         CVec_u8Z_free(ret_var);
41592         return ret_arr;
41593 }
41594
41595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41596         LDKu8slice ser_ref;
41597         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41598         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41599         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
41600         *ret_conv = GossipTimestampFilter_read(ser_ref);
41601         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41602         return tag_ptr(ret_conv, true);
41603 }
41604
41605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41606         if (!ptr_is_owned(this_ptr)) return;
41607         void* this_ptr_ptr = untag_ptr(this_ptr);
41608         CHECK_ACCESS(this_ptr_ptr);
41609         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
41610         FREE(untag_ptr(this_ptr));
41611         CustomMessageHandler_free(this_ptr_conv);
41612 }
41613
41614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41615         LDKIgnoringMessageHandler this_obj_conv;
41616         this_obj_conv.inner = untag_ptr(this_obj);
41617         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41619         IgnoringMessageHandler_free(this_obj_conv);
41620 }
41621
41622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
41623         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
41624         int64_t ret_ref = 0;
41625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41627         return ret_ref;
41628 }
41629
41630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41631         LDKIgnoringMessageHandler this_arg_conv;
41632         this_arg_conv.inner = untag_ptr(this_arg);
41633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41635         this_arg_conv.is_owned = false;
41636         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41637         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41638         return tag_ptr(ret_ret, true);
41639 }
41640
41641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41642         LDKIgnoringMessageHandler this_arg_conv;
41643         this_arg_conv.inner = untag_ptr(this_arg);
41644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41646         this_arg_conv.is_owned = false;
41647         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41648         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
41649         return tag_ptr(ret_ret, true);
41650 }
41651
41652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41653         LDKIgnoringMessageHandler this_arg_conv;
41654         this_arg_conv.inner = untag_ptr(this_arg);
41655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41657         this_arg_conv.is_owned = false;
41658         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
41659         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
41660         return tag_ptr(ret_ret, true);
41661 }
41662
41663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41664         LDKIgnoringMessageHandler this_arg_conv;
41665         this_arg_conv.inner = untag_ptr(this_arg);
41666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41668         this_arg_conv.is_owned = false;
41669         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
41670         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
41671         return tag_ptr(ret_ret, true);
41672 }
41673
41674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41675         LDKIgnoringMessageHandler this_arg_conv;
41676         this_arg_conv.inner = untag_ptr(this_arg);
41677         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41679         this_arg_conv.is_owned = false;
41680         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
41681         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
41682         return tag_ptr(ret_ret, true);
41683 }
41684
41685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
41686         LDKIgnoringMessageHandler this_arg_conv;
41687         this_arg_conv.inner = untag_ptr(this_arg);
41688         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41690         this_arg_conv.is_owned = false;
41691         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
41692         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
41693         return tag_ptr(ret_ret, true);
41694 }
41695
41696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41697         LDKIgnoringMessageHandler this_arg_conv;
41698         this_arg_conv.inner = untag_ptr(this_arg);
41699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41701         this_arg_conv.is_owned = false;
41702         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
41703         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
41704         return tag_ptr(ret_ret, true);
41705 }
41706
41707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41708         LDKErroringMessageHandler this_obj_conv;
41709         this_obj_conv.inner = untag_ptr(this_obj);
41710         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41712         ErroringMessageHandler_free(this_obj_conv);
41713 }
41714
41715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
41716         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
41717         int64_t ret_ref = 0;
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41720         return ret_ref;
41721 }
41722
41723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41724         LDKErroringMessageHandler this_arg_conv;
41725         this_arg_conv.inner = untag_ptr(this_arg);
41726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41728         this_arg_conv.is_owned = false;
41729         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41730         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41731         return tag_ptr(ret_ret, true);
41732 }
41733
41734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41735         LDKErroringMessageHandler this_arg_conv;
41736         this_arg_conv.inner = untag_ptr(this_arg);
41737         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41739         this_arg_conv.is_owned = false;
41740         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
41741         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
41742         return tag_ptr(ret_ret, true);
41743 }
41744
41745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41746         LDKMessageHandler this_obj_conv;
41747         this_obj_conv.inner = untag_ptr(this_obj);
41748         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41750         MessageHandler_free(this_obj_conv);
41751 }
41752
41753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41754         LDKMessageHandler this_ptr_conv;
41755         this_ptr_conv.inner = untag_ptr(this_ptr);
41756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41758         this_ptr_conv.is_owned = false;
41759         // WARNING: This object doesn't live past this scope, needs clone!
41760         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
41761         return ret_ret;
41762 }
41763
41764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41765         LDKMessageHandler this_ptr_conv;
41766         this_ptr_conv.inner = untag_ptr(this_ptr);
41767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41769         this_ptr_conv.is_owned = false;
41770         void* val_ptr = untag_ptr(val);
41771         CHECK_ACCESS(val_ptr);
41772         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
41773         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
41774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41775                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
41776         }
41777         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
41778 }
41779
41780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41781         LDKMessageHandler this_ptr_conv;
41782         this_ptr_conv.inner = untag_ptr(this_ptr);
41783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41785         this_ptr_conv.is_owned = false;
41786         // WARNING: This object doesn't live past this scope, needs clone!
41787         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
41788         return ret_ret;
41789 }
41790
41791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41792         LDKMessageHandler this_ptr_conv;
41793         this_ptr_conv.inner = untag_ptr(this_ptr);
41794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41796         this_ptr_conv.is_owned = false;
41797         void* val_ptr = untag_ptr(val);
41798         CHECK_ACCESS(val_ptr);
41799         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
41800         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41802                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
41803         }
41804         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
41805 }
41806
41807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41808         LDKMessageHandler 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         // WARNING: This object doesn't live past this scope, needs clone!
41814         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
41815         return ret_ret;
41816 }
41817
41818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41819         LDKMessageHandler this_ptr_conv;
41820         this_ptr_conv.inner = untag_ptr(this_ptr);
41821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41823         this_ptr_conv.is_owned = false;
41824         void* val_ptr = untag_ptr(val);
41825         CHECK_ACCESS(val_ptr);
41826         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
41827         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
41828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41829                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
41830         }
41831         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
41832 }
41833
41834 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) {
41835         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
41836         CHECK_ACCESS(chan_handler_arg_ptr);
41837         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
41838         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
41839                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41840                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
41841         }
41842         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
41843         CHECK_ACCESS(route_handler_arg_ptr);
41844         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
41845         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41847                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
41848         }
41849         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41850         CHECK_ACCESS(onion_message_handler_arg_ptr);
41851         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41852         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41854                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41855         }
41856         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41857         int64_t ret_ref = 0;
41858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41860         return ret_ref;
41861 }
41862
41863 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41864         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41865         *ret_ret = SocketDescriptor_clone(arg);
41866         return tag_ptr(ret_ret, true);
41867 }
41868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41869         void* arg_ptr = untag_ptr(arg);
41870         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41871         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41872         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41873         return ret_conv;
41874 }
41875
41876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41877         void* orig_ptr = untag_ptr(orig);
41878         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41879         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41880         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41881         *ret_ret = SocketDescriptor_clone(orig_conv);
41882         return tag_ptr(ret_ret, true);
41883 }
41884
41885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41886         if (!ptr_is_owned(this_ptr)) return;
41887         void* this_ptr_ptr = untag_ptr(this_ptr);
41888         CHECK_ACCESS(this_ptr_ptr);
41889         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41890         FREE(untag_ptr(this_ptr));
41891         SocketDescriptor_free(this_ptr_conv);
41892 }
41893
41894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41895         LDKPeerHandleError this_obj_conv;
41896         this_obj_conv.inner = untag_ptr(this_obj);
41897         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41899         PeerHandleError_free(this_obj_conv);
41900 }
41901
41902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz) {
41903         LDKPeerHandleError ret_var = PeerHandleError_new();
41904         int64_t ret_ref = 0;
41905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41907         return ret_ref;
41908 }
41909
41910 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41911         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41912         int64_t ret_ref = 0;
41913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41915         return ret_ref;
41916 }
41917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41918         LDKPeerHandleError arg_conv;
41919         arg_conv.inner = untag_ptr(arg);
41920         arg_conv.is_owned = ptr_is_owned(arg);
41921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41922         arg_conv.is_owned = false;
41923         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41924         return ret_conv;
41925 }
41926
41927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41928         LDKPeerHandleError orig_conv;
41929         orig_conv.inner = untag_ptr(orig);
41930         orig_conv.is_owned = ptr_is_owned(orig);
41931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41932         orig_conv.is_owned = false;
41933         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41934         int64_t ret_ref = 0;
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41937         return ret_ref;
41938 }
41939
41940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41941         LDKPeerManager this_obj_conv;
41942         this_obj_conv.inner = untag_ptr(this_obj);
41943         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41945         PeerManager_free(this_obj_conv);
41946 }
41947
41948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int32_t current_time, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler, int64_t node_signer) {
41949         LDKMessageHandler message_handler_conv;
41950         message_handler_conv.inner = untag_ptr(message_handler);
41951         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41953         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41954         
41955         uint8_t ephemeral_random_data_arr[32];
41956         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41957         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41958         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41959         void* logger_ptr = untag_ptr(logger);
41960         CHECK_ACCESS(logger_ptr);
41961         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41962         if (logger_conv.free == LDKLogger_JCalls_free) {
41963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41964                 LDKLogger_JCalls_cloned(&logger_conv);
41965         }
41966         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41967         CHECK_ACCESS(custom_message_handler_ptr);
41968         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41969         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41971                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41972         }
41973         void* node_signer_ptr = untag_ptr(node_signer);
41974         CHECK_ACCESS(node_signer_ptr);
41975         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
41976         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
41977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41978                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
41979         }
41980         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv, node_signer_conv);
41981         int64_t ret_ref = 0;
41982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41984         return ret_ref;
41985 }
41986
41987 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41988         LDKPeerManager this_arg_conv;
41989         this_arg_conv.inner = untag_ptr(this_arg);
41990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41992         this_arg_conv.is_owned = false;
41993         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41994         int64_tArray ret_arr = NULL;
41995         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41996         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41997         for (size_t o = 0; o < ret_var.datalen; o++) {
41998                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
41999                 *ret_conv_40_conv = ret_var.data[o];
42000                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
42001         }
42002         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42003         FREE(ret_var.data);
42004         return ret_arr;
42005 }
42006
42007 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) {
42008         LDKPeerManager this_arg_conv;
42009         this_arg_conv.inner = untag_ptr(this_arg);
42010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42012         this_arg_conv.is_owned = false;
42013         LDKPublicKey their_node_id_ref;
42014         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
42015         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
42016         void* descriptor_ptr = untag_ptr(descriptor);
42017         CHECK_ACCESS(descriptor_ptr);
42018         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42019         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42021                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42022         }
42023         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42024         CHECK_ACCESS(remote_network_address_ptr);
42025         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42026         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
42027         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
42028         return tag_ptr(ret_conv, true);
42029 }
42030
42031 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) {
42032         LDKPeerManager this_arg_conv;
42033         this_arg_conv.inner = untag_ptr(this_arg);
42034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42036         this_arg_conv.is_owned = false;
42037         void* descriptor_ptr = untag_ptr(descriptor);
42038         CHECK_ACCESS(descriptor_ptr);
42039         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42040         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42042                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42043         }
42044         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42045         CHECK_ACCESS(remote_network_address_ptr);
42046         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42047         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42048         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
42049         return tag_ptr(ret_conv, true);
42050 }
42051
42052 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) {
42053         LDKPeerManager this_arg_conv;
42054         this_arg_conv.inner = untag_ptr(this_arg);
42055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42057         this_arg_conv.is_owned = false;
42058         void* descriptor_ptr = untag_ptr(descriptor);
42059         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42060         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42061         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42062         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
42063         return tag_ptr(ret_conv, true);
42064 }
42065
42066 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) {
42067         LDKPeerManager this_arg_conv;
42068         this_arg_conv.inner = untag_ptr(this_arg);
42069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42071         this_arg_conv.is_owned = false;
42072         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
42073         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
42074         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
42075         LDKu8slice data_ref;
42076         data_ref.datalen = (*env)->GetArrayLength(env, data);
42077         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
42078         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
42079         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
42080         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
42081         return tag_ptr(ret_conv, true);
42082 }
42083
42084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
42085         LDKPeerManager this_arg_conv;
42086         this_arg_conv.inner = untag_ptr(this_arg);
42087         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42089         this_arg_conv.is_owned = false;
42090         PeerManager_process_events(&this_arg_conv);
42091 }
42092
42093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
42094         LDKPeerManager this_arg_conv;
42095         this_arg_conv.inner = untag_ptr(this_arg);
42096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42098         this_arg_conv.is_owned = false;
42099         void* descriptor_ptr = untag_ptr(descriptor);
42100         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42101         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42102         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
42103 }
42104
42105 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) {
42106         LDKPeerManager this_arg_conv;
42107         this_arg_conv.inner = untag_ptr(this_arg);
42108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42110         this_arg_conv.is_owned = false;
42111         LDKPublicKey node_id_ref;
42112         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42113         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42114         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
42115 }
42116
42117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
42118         LDKPeerManager this_arg_conv;
42119         this_arg_conv.inner = untag_ptr(this_arg);
42120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42122         this_arg_conv.is_owned = false;
42123         PeerManager_disconnect_all_peers(&this_arg_conv);
42124 }
42125
42126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
42127         LDKPeerManager this_arg_conv;
42128         this_arg_conv.inner = untag_ptr(this_arg);
42129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42131         this_arg_conv.is_owned = false;
42132         PeerManager_timer_tick_occurred(&this_arg_conv);
42133 }
42134
42135 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) {
42136         LDKPeerManager this_arg_conv;
42137         this_arg_conv.inner = untag_ptr(this_arg);
42138         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42140         this_arg_conv.is_owned = false;
42141         LDKThreeBytes rgb_ref;
42142         CHECK((*env)->GetArrayLength(env, rgb) == 3);
42143         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
42144         LDKThirtyTwoBytes alias_ref;
42145         CHECK((*env)->GetArrayLength(env, alias) == 32);
42146         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
42147         LDKCVec_NetAddressZ addresses_constr;
42148         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
42149         if (addresses_constr.datalen > 0)
42150                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42151         else
42152                 addresses_constr.data = NULL;
42153         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
42154         for (size_t m = 0; m < addresses_constr.datalen; m++) {
42155                 int64_t addresses_conv_12 = addresses_vals[m];
42156                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
42157                 CHECK_ACCESS(addresses_conv_12_ptr);
42158                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
42159                 addresses_constr.data[m] = addresses_conv_12_conv;
42160         }
42161         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
42162         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
42163 }
42164
42165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42166         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
42167         return ret_conv;
42168 }
42169
42170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42171         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
42172         return ret_conv;
42173 }
42174
42175 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42176         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
42177         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
42178         return ret_conv;
42179 }
42180
42181 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
42182         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
42183         return ret_conv;
42184 }
42185
42186 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
42187         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
42188         return ret_conv;
42189 }
42190
42191 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
42192         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
42193         return ret_conv;
42194 }
42195
42196 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
42197         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
42198         return ret_conv;
42199 }
42200
42201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
42202         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
42203         return ret_conv;
42204 }
42205
42206 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42207         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
42208         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
42209         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
42210         return ret_conv;
42211 }
42212
42213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
42214         LDKWitness witness_ref;
42215         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
42216         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
42217         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
42218         witness_ref.data_is_owned = true;
42219         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
42220         *ret_copy = HTLCClaim_from_witness(witness_ref);
42221         int64_t ret_ref = tag_ptr(ret_copy, true);
42222         return ret_ref;
42223 }
42224
42225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
42226         uint8_t commitment_seed_arr[32];
42227         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
42228         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
42229         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
42230         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42231         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
42232         return ret_arr;
42233 }
42234
42235 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) {
42236         LDKCVec_u8Z to_holder_script_ref;
42237         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42238         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42239         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42240         LDKCVec_u8Z to_counterparty_script_ref;
42241         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42242         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42243         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42244         LDKOutPoint funding_outpoint_conv;
42245         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42246         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42247         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42248         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42249         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);
42250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42252         Transaction_free(ret_var);
42253         return ret_arr;
42254 }
42255
42256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42257         LDKCounterpartyCommitmentSecrets this_obj_conv;
42258         this_obj_conv.inner = untag_ptr(this_obj);
42259         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42261         CounterpartyCommitmentSecrets_free(this_obj_conv);
42262 }
42263
42264 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
42265         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
42266         int64_t ret_ref = 0;
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42269         return ret_ref;
42270 }
42271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42272         LDKCounterpartyCommitmentSecrets arg_conv;
42273         arg_conv.inner = untag_ptr(arg);
42274         arg_conv.is_owned = ptr_is_owned(arg);
42275         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42276         arg_conv.is_owned = false;
42277         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
42278         return ret_conv;
42279 }
42280
42281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42282         LDKCounterpartyCommitmentSecrets orig_conv;
42283         orig_conv.inner = untag_ptr(orig);
42284         orig_conv.is_owned = ptr_is_owned(orig);
42285         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42286         orig_conv.is_owned = false;
42287         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
42288         int64_t ret_ref = 0;
42289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42291         return ret_ref;
42292 }
42293
42294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
42295         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
42296         int64_t ret_ref = 0;
42297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42299         return ret_ref;
42300 }
42301
42302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42303         LDKCounterpartyCommitmentSecrets this_arg_conv;
42304         this_arg_conv.inner = untag_ptr(this_arg);
42305         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42307         this_arg_conv.is_owned = false;
42308         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
42309         return ret_conv;
42310 }
42311
42312 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) {
42313         LDKCounterpartyCommitmentSecrets this_arg_conv;
42314         this_arg_conv.inner = untag_ptr(this_arg);
42315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42317         this_arg_conv.is_owned = false;
42318         LDKThirtyTwoBytes secret_ref;
42319         CHECK((*env)->GetArrayLength(env, secret) == 32);
42320         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
42321         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
42322         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
42323         return tag_ptr(ret_conv, true);
42324 }
42325
42326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
42327         LDKCounterpartyCommitmentSecrets this_arg_conv;
42328         this_arg_conv.inner = untag_ptr(this_arg);
42329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42331         this_arg_conv.is_owned = false;
42332         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
42334         return ret_arr;
42335 }
42336
42337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
42338         LDKCounterpartyCommitmentSecrets obj_conv;
42339         obj_conv.inner = untag_ptr(obj);
42340         obj_conv.is_owned = ptr_is_owned(obj);
42341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42342         obj_conv.is_owned = false;
42343         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
42344         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42345         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42346         CVec_u8Z_free(ret_var);
42347         return ret_arr;
42348 }
42349
42350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42351         LDKu8slice ser_ref;
42352         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42353         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42354         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
42355         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
42356         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42357         return tag_ptr(ret_conv, true);
42358 }
42359
42360 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) {
42361         LDKPublicKey per_commitment_point_ref;
42362         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42363         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42364         uint8_t base_secret_arr[32];
42365         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
42366         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
42367         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
42368         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
42370         return ret_arr;
42371 }
42372
42373 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) {
42374         LDKPublicKey per_commitment_point_ref;
42375         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42376         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42377         LDKPublicKey base_point_ref;
42378         CHECK((*env)->GetArrayLength(env, base_point) == 33);
42379         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
42380         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
42382         return ret_arr;
42383 }
42384
42385 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) {
42386         uint8_t per_commitment_secret_arr[32];
42387         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
42388         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
42389         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
42390         uint8_t countersignatory_revocation_base_secret_arr[32];
42391         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
42392         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
42393         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
42394         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
42396         return ret_arr;
42397 }
42398
42399 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) {
42400         LDKPublicKey per_commitment_point_ref;
42401         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42402         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42403         LDKPublicKey countersignatory_revocation_base_point_ref;
42404         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
42405         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
42406         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42407         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
42408         return ret_arr;
42409 }
42410
42411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42412         LDKTxCreationKeys this_obj_conv;
42413         this_obj_conv.inner = untag_ptr(this_obj);
42414         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42416         TxCreationKeys_free(this_obj_conv);
42417 }
42418
42419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42420         LDKTxCreationKeys this_ptr_conv;
42421         this_ptr_conv.inner = untag_ptr(this_ptr);
42422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42424         this_ptr_conv.is_owned = false;
42425         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42426         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
42427         return ret_arr;
42428 }
42429
42430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42431         LDKTxCreationKeys this_ptr_conv;
42432         this_ptr_conv.inner = untag_ptr(this_ptr);
42433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42435         this_ptr_conv.is_owned = false;
42436         LDKPublicKey val_ref;
42437         CHECK((*env)->GetArrayLength(env, val) == 33);
42438         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42439         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
42440 }
42441
42442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42443         LDKTxCreationKeys this_ptr_conv;
42444         this_ptr_conv.inner = untag_ptr(this_ptr);
42445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42447         this_ptr_conv.is_owned = false;
42448         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
42450         return ret_arr;
42451 }
42452
42453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42454         LDKTxCreationKeys this_ptr_conv;
42455         this_ptr_conv.inner = untag_ptr(this_ptr);
42456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42458         this_ptr_conv.is_owned = false;
42459         LDKPublicKey val_ref;
42460         CHECK((*env)->GetArrayLength(env, val) == 33);
42461         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42462         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
42463 }
42464
42465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42466         LDKTxCreationKeys this_ptr_conv;
42467         this_ptr_conv.inner = untag_ptr(this_ptr);
42468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42470         this_ptr_conv.is_owned = false;
42471         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
42473         return ret_arr;
42474 }
42475
42476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42477         LDKTxCreationKeys this_ptr_conv;
42478         this_ptr_conv.inner = untag_ptr(this_ptr);
42479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42481         this_ptr_conv.is_owned = false;
42482         LDKPublicKey val_ref;
42483         CHECK((*env)->GetArrayLength(env, val) == 33);
42484         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42485         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
42486 }
42487
42488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42489         LDKTxCreationKeys this_ptr_conv;
42490         this_ptr_conv.inner = untag_ptr(this_ptr);
42491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42493         this_ptr_conv.is_owned = false;
42494         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
42496         return ret_arr;
42497 }
42498
42499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42500         LDKTxCreationKeys this_ptr_conv;
42501         this_ptr_conv.inner = untag_ptr(this_ptr);
42502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42504         this_ptr_conv.is_owned = false;
42505         LDKPublicKey val_ref;
42506         CHECK((*env)->GetArrayLength(env, val) == 33);
42507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42508         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
42509 }
42510
42511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42512         LDKTxCreationKeys this_ptr_conv;
42513         this_ptr_conv.inner = untag_ptr(this_ptr);
42514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42516         this_ptr_conv.is_owned = false;
42517         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
42519         return ret_arr;
42520 }
42521
42522 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) {
42523         LDKTxCreationKeys this_ptr_conv;
42524         this_ptr_conv.inner = untag_ptr(this_ptr);
42525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42527         this_ptr_conv.is_owned = false;
42528         LDKPublicKey val_ref;
42529         CHECK((*env)->GetArrayLength(env, val) == 33);
42530         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42531         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
42532 }
42533
42534 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) {
42535         LDKPublicKey per_commitment_point_arg_ref;
42536         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
42537         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
42538         LDKPublicKey revocation_key_arg_ref;
42539         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
42540         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
42541         LDKPublicKey broadcaster_htlc_key_arg_ref;
42542         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
42543         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
42544         LDKPublicKey countersignatory_htlc_key_arg_ref;
42545         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
42546         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
42547         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
42548         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
42549         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
42550         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);
42551         int64_t ret_ref = 0;
42552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42554         return ret_ref;
42555 }
42556
42557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42558         LDKTxCreationKeys a_conv;
42559         a_conv.inner = untag_ptr(a);
42560         a_conv.is_owned = ptr_is_owned(a);
42561         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42562         a_conv.is_owned = false;
42563         LDKTxCreationKeys b_conv;
42564         b_conv.inner = untag_ptr(b);
42565         b_conv.is_owned = ptr_is_owned(b);
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42567         b_conv.is_owned = false;
42568         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
42569         return ret_conv;
42570 }
42571
42572 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
42573         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
42574         int64_t ret_ref = 0;
42575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42577         return ret_ref;
42578 }
42579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42580         LDKTxCreationKeys arg_conv;
42581         arg_conv.inner = untag_ptr(arg);
42582         arg_conv.is_owned = ptr_is_owned(arg);
42583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42584         arg_conv.is_owned = false;
42585         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
42586         return ret_conv;
42587 }
42588
42589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42590         LDKTxCreationKeys orig_conv;
42591         orig_conv.inner = untag_ptr(orig);
42592         orig_conv.is_owned = ptr_is_owned(orig);
42593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42594         orig_conv.is_owned = false;
42595         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
42596         int64_t ret_ref = 0;
42597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42599         return ret_ref;
42600 }
42601
42602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42603         LDKTxCreationKeys obj_conv;
42604         obj_conv.inner = untag_ptr(obj);
42605         obj_conv.is_owned = ptr_is_owned(obj);
42606         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42607         obj_conv.is_owned = false;
42608         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
42609         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42610         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42611         CVec_u8Z_free(ret_var);
42612         return ret_arr;
42613 }
42614
42615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42616         LDKu8slice ser_ref;
42617         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42618         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42619         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
42620         *ret_conv = TxCreationKeys_read(ser_ref);
42621         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42622         return tag_ptr(ret_conv, true);
42623 }
42624
42625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42626         LDKChannelPublicKeys this_obj_conv;
42627         this_obj_conv.inner = untag_ptr(this_obj);
42628         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42630         ChannelPublicKeys_free(this_obj_conv);
42631 }
42632
42633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42634         LDKChannelPublicKeys this_ptr_conv;
42635         this_ptr_conv.inner = untag_ptr(this_ptr);
42636         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42638         this_ptr_conv.is_owned = false;
42639         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
42641         return ret_arr;
42642 }
42643
42644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42645         LDKChannelPublicKeys this_ptr_conv;
42646         this_ptr_conv.inner = untag_ptr(this_ptr);
42647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42649         this_ptr_conv.is_owned = false;
42650         LDKPublicKey val_ref;
42651         CHECK((*env)->GetArrayLength(env, val) == 33);
42652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42653         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
42654 }
42655
42656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42657         LDKChannelPublicKeys this_ptr_conv;
42658         this_ptr_conv.inner = untag_ptr(this_ptr);
42659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42661         this_ptr_conv.is_owned = false;
42662         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
42664         return ret_arr;
42665 }
42666
42667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42668         LDKChannelPublicKeys this_ptr_conv;
42669         this_ptr_conv.inner = untag_ptr(this_ptr);
42670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42672         this_ptr_conv.is_owned = false;
42673         LDKPublicKey val_ref;
42674         CHECK((*env)->GetArrayLength(env, val) == 33);
42675         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42676         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
42677 }
42678
42679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42680         LDKChannelPublicKeys this_ptr_conv;
42681         this_ptr_conv.inner = untag_ptr(this_ptr);
42682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42684         this_ptr_conv.is_owned = false;
42685         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
42687         return ret_arr;
42688 }
42689
42690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42691         LDKChannelPublicKeys this_ptr_conv;
42692         this_ptr_conv.inner = untag_ptr(this_ptr);
42693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42695         this_ptr_conv.is_owned = false;
42696         LDKPublicKey val_ref;
42697         CHECK((*env)->GetArrayLength(env, val) == 33);
42698         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42699         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
42700 }
42701
42702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42703         LDKChannelPublicKeys this_ptr_conv;
42704         this_ptr_conv.inner = untag_ptr(this_ptr);
42705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42707         this_ptr_conv.is_owned = false;
42708         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
42710         return ret_arr;
42711 }
42712
42713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42714         LDKChannelPublicKeys this_ptr_conv;
42715         this_ptr_conv.inner = untag_ptr(this_ptr);
42716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42718         this_ptr_conv.is_owned = false;
42719         LDKPublicKey val_ref;
42720         CHECK((*env)->GetArrayLength(env, val) == 33);
42721         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42722         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
42723 }
42724
42725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42726         LDKChannelPublicKeys this_ptr_conv;
42727         this_ptr_conv.inner = untag_ptr(this_ptr);
42728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42730         this_ptr_conv.is_owned = false;
42731         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42732         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
42733         return ret_arr;
42734 }
42735
42736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42737         LDKChannelPublicKeys this_ptr_conv;
42738         this_ptr_conv.inner = untag_ptr(this_ptr);
42739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42741         this_ptr_conv.is_owned = false;
42742         LDKPublicKey val_ref;
42743         CHECK((*env)->GetArrayLength(env, val) == 33);
42744         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42745         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
42746 }
42747
42748 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) {
42749         LDKPublicKey funding_pubkey_arg_ref;
42750         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
42751         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
42752         LDKPublicKey revocation_basepoint_arg_ref;
42753         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
42754         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
42755         LDKPublicKey payment_point_arg_ref;
42756         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
42757         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
42758         LDKPublicKey delayed_payment_basepoint_arg_ref;
42759         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
42760         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
42761         LDKPublicKey htlc_basepoint_arg_ref;
42762         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
42763         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
42764         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);
42765         int64_t ret_ref = 0;
42766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42768         return ret_ref;
42769 }
42770
42771 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
42772         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
42773         int64_t ret_ref = 0;
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42776         return ret_ref;
42777 }
42778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42779         LDKChannelPublicKeys arg_conv;
42780         arg_conv.inner = untag_ptr(arg);
42781         arg_conv.is_owned = ptr_is_owned(arg);
42782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42783         arg_conv.is_owned = false;
42784         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
42785         return ret_conv;
42786 }
42787
42788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42789         LDKChannelPublicKeys orig_conv;
42790         orig_conv.inner = untag_ptr(orig);
42791         orig_conv.is_owned = ptr_is_owned(orig);
42792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42793         orig_conv.is_owned = false;
42794         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
42795         int64_t ret_ref = 0;
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42798         return ret_ref;
42799 }
42800
42801 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42802         LDKChannelPublicKeys a_conv;
42803         a_conv.inner = untag_ptr(a);
42804         a_conv.is_owned = ptr_is_owned(a);
42805         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42806         a_conv.is_owned = false;
42807         LDKChannelPublicKeys b_conv;
42808         b_conv.inner = untag_ptr(b);
42809         b_conv.is_owned = ptr_is_owned(b);
42810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42811         b_conv.is_owned = false;
42812         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
42813         return ret_conv;
42814 }
42815
42816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42817         LDKChannelPublicKeys obj_conv;
42818         obj_conv.inner = untag_ptr(obj);
42819         obj_conv.is_owned = ptr_is_owned(obj);
42820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42821         obj_conv.is_owned = false;
42822         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
42823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42825         CVec_u8Z_free(ret_var);
42826         return ret_arr;
42827 }
42828
42829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42830         LDKu8slice ser_ref;
42831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42833         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
42834         *ret_conv = ChannelPublicKeys_read(ser_ref);
42835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42836         return tag_ptr(ret_conv, true);
42837 }
42838
42839 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) {
42840         LDKPublicKey per_commitment_point_ref;
42841         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42842         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42843         LDKPublicKey broadcaster_delayed_payment_base_ref;
42844         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42845         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42846         LDKPublicKey broadcaster_htlc_base_ref;
42847         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42848         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42849         LDKPublicKey countersignatory_revocation_base_ref;
42850         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42851         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42852         LDKPublicKey countersignatory_htlc_base_ref;
42853         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42854         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42855         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);
42856         int64_t ret_ref = 0;
42857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42859         return ret_ref;
42860 }
42861
42862 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) {
42863         LDKPublicKey per_commitment_point_ref;
42864         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42865         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42866         LDKChannelPublicKeys broadcaster_keys_conv;
42867         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42868         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42869         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42870         broadcaster_keys_conv.is_owned = false;
42871         LDKChannelPublicKeys countersignatory_keys_conv;
42872         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42873         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42874         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42875         countersignatory_keys_conv.is_owned = false;
42876         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42877         int64_t ret_ref = 0;
42878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42880         return ret_ref;
42881 }
42882
42883 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) {
42884         LDKPublicKey revocation_key_ref;
42885         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42886         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42887         LDKPublicKey broadcaster_delayed_payment_key_ref;
42888         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42889         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42890         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42893         CVec_u8Z_free(ret_var);
42894         return ret_arr;
42895 }
42896
42897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42898         LDKHTLCOutputInCommitment this_obj_conv;
42899         this_obj_conv.inner = untag_ptr(this_obj);
42900         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42902         HTLCOutputInCommitment_free(this_obj_conv);
42903 }
42904
42905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42906         LDKHTLCOutputInCommitment this_ptr_conv;
42907         this_ptr_conv.inner = untag_ptr(this_ptr);
42908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42910         this_ptr_conv.is_owned = false;
42911         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42912         return ret_conv;
42913 }
42914
42915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42916         LDKHTLCOutputInCommitment this_ptr_conv;
42917         this_ptr_conv.inner = untag_ptr(this_ptr);
42918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42920         this_ptr_conv.is_owned = false;
42921         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42922 }
42923
42924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42925         LDKHTLCOutputInCommitment this_ptr_conv;
42926         this_ptr_conv.inner = untag_ptr(this_ptr);
42927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42929         this_ptr_conv.is_owned = false;
42930         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42931         return ret_conv;
42932 }
42933
42934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42935         LDKHTLCOutputInCommitment this_ptr_conv;
42936         this_ptr_conv.inner = untag_ptr(this_ptr);
42937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42939         this_ptr_conv.is_owned = false;
42940         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42941 }
42942
42943 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42944         LDKHTLCOutputInCommitment this_ptr_conv;
42945         this_ptr_conv.inner = untag_ptr(this_ptr);
42946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42948         this_ptr_conv.is_owned = false;
42949         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42950         return ret_conv;
42951 }
42952
42953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42954         LDKHTLCOutputInCommitment this_ptr_conv;
42955         this_ptr_conv.inner = untag_ptr(this_ptr);
42956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42958         this_ptr_conv.is_owned = false;
42959         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42960 }
42961
42962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42963         LDKHTLCOutputInCommitment this_ptr_conv;
42964         this_ptr_conv.inner = untag_ptr(this_ptr);
42965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42967         this_ptr_conv.is_owned = false;
42968         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42969         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42970         return ret_arr;
42971 }
42972
42973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42974         LDKHTLCOutputInCommitment this_ptr_conv;
42975         this_ptr_conv.inner = untag_ptr(this_ptr);
42976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42978         this_ptr_conv.is_owned = false;
42979         LDKThirtyTwoBytes val_ref;
42980         CHECK((*env)->GetArrayLength(env, val) == 32);
42981         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42982         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42983 }
42984
42985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42986         LDKHTLCOutputInCommitment this_ptr_conv;
42987         this_ptr_conv.inner = untag_ptr(this_ptr);
42988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42990         this_ptr_conv.is_owned = false;
42991         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42992         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42993         int64_t ret_ref = tag_ptr(ret_copy, true);
42994         return ret_ref;
42995 }
42996
42997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42998         LDKHTLCOutputInCommitment this_ptr_conv;
42999         this_ptr_conv.inner = untag_ptr(this_ptr);
43000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43002         this_ptr_conv.is_owned = false;
43003         void* val_ptr = untag_ptr(val);
43004         CHECK_ACCESS(val_ptr);
43005         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
43006         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
43007         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
43008 }
43009
43010 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) {
43011         LDKThirtyTwoBytes payment_hash_arg_ref;
43012         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
43013         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
43014         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
43015         CHECK_ACCESS(transaction_output_index_arg_ptr);
43016         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
43017         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
43018         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
43019         int64_t ret_ref = 0;
43020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43022         return ret_ref;
43023 }
43024
43025 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
43026         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
43027         int64_t ret_ref = 0;
43028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43030         return ret_ref;
43031 }
43032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43033         LDKHTLCOutputInCommitment arg_conv;
43034         arg_conv.inner = untag_ptr(arg);
43035         arg_conv.is_owned = ptr_is_owned(arg);
43036         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43037         arg_conv.is_owned = false;
43038         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
43039         return ret_conv;
43040 }
43041
43042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43043         LDKHTLCOutputInCommitment orig_conv;
43044         orig_conv.inner = untag_ptr(orig);
43045         orig_conv.is_owned = ptr_is_owned(orig);
43046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43047         orig_conv.is_owned = false;
43048         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
43049         int64_t ret_ref = 0;
43050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43052         return ret_ref;
43053 }
43054
43055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43056         LDKHTLCOutputInCommitment a_conv;
43057         a_conv.inner = untag_ptr(a);
43058         a_conv.is_owned = ptr_is_owned(a);
43059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43060         a_conv.is_owned = false;
43061         LDKHTLCOutputInCommitment b_conv;
43062         b_conv.inner = untag_ptr(b);
43063         b_conv.is_owned = ptr_is_owned(b);
43064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43065         b_conv.is_owned = false;
43066         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
43067         return ret_conv;
43068 }
43069
43070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
43071         LDKHTLCOutputInCommitment obj_conv;
43072         obj_conv.inner = untag_ptr(obj);
43073         obj_conv.is_owned = ptr_is_owned(obj);
43074         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43075         obj_conv.is_owned = false;
43076         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
43077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43079         CVec_u8Z_free(ret_var);
43080         return ret_arr;
43081 }
43082
43083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43084         LDKu8slice ser_ref;
43085         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43086         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43087         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
43088         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
43089         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43090         return tag_ptr(ret_conv, true);
43091 }
43092
43093 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) {
43094         LDKHTLCOutputInCommitment htlc_conv;
43095         htlc_conv.inner = untag_ptr(htlc);
43096         htlc_conv.is_owned = ptr_is_owned(htlc);
43097         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43098         htlc_conv.is_owned = false;
43099         LDKTxCreationKeys keys_conv;
43100         keys_conv.inner = untag_ptr(keys);
43101         keys_conv.is_owned = ptr_is_owned(keys);
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
43103         keys_conv.is_owned = false;
43104         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
43105         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43106         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43107         CVec_u8Z_free(ret_var);
43108         return ret_arr;
43109 }
43110
43111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
43112         LDKPublicKey broadcaster_ref;
43113         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
43114         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
43115         LDKPublicKey countersignatory_ref;
43116         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
43117         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
43118         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
43119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43121         CVec_u8Z_free(ret_var);
43122         return ret_arr;
43123 }
43124
43125 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) {
43126         uint8_t commitment_txid_arr[32];
43127         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
43128         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
43129         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
43130         LDKHTLCOutputInCommitment htlc_conv;
43131         htlc_conv.inner = untag_ptr(htlc);
43132         htlc_conv.is_owned = ptr_is_owned(htlc);
43133         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43134         htlc_conv.is_owned = false;
43135         LDKPublicKey broadcaster_delayed_payment_key_ref;
43136         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
43137         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
43138         LDKPublicKey revocation_key_ref;
43139         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
43140         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
43141         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);
43142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43144         Transaction_free(ret_var);
43145         return ret_arr;
43146 }
43147
43148 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) {
43149         LDKSignature local_sig_ref;
43150         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
43151         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
43152         LDKSignature remote_sig_ref;
43153         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
43154         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
43155         LDKThirtyTwoBytes preimage_ref;
43156         CHECK((*env)->GetArrayLength(env, preimage) == 32);
43157         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
43158         LDKu8slice redeem_script_ref;
43159         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
43160         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
43161         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
43162         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43163         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43164         Witness_free(ret_var);
43165         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
43166         return ret_arr;
43167 }
43168
43169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
43170         LDKPublicKey payment_point_ref;
43171         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
43172         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
43173         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
43174         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43175         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43176         CVec_u8Z_free(ret_var);
43177         return ret_arr;
43178 }
43179
43180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
43181         LDKPublicKey funding_pubkey_ref;
43182         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
43183         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
43184         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
43185         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43186         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43187         CVec_u8Z_free(ret_var);
43188         return ret_arr;
43189 }
43190
43191 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) {
43192         LDKPublicKey funding_key_ref;
43193         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
43194         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
43195         LDKSignature funding_sig_ref;
43196         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
43197         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
43198         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
43199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43201         Witness_free(ret_var);
43202         return ret_arr;
43203 }
43204
43205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43206         LDKChannelTransactionParameters this_obj_conv;
43207         this_obj_conv.inner = untag_ptr(this_obj);
43208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43210         ChannelTransactionParameters_free(this_obj_conv);
43211 }
43212
43213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43214         LDKChannelTransactionParameters this_ptr_conv;
43215         this_ptr_conv.inner = untag_ptr(this_ptr);
43216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43218         this_ptr_conv.is_owned = false;
43219         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
43220         int64_t ret_ref = 0;
43221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43223         return ret_ref;
43224 }
43225
43226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43227         LDKChannelTransactionParameters this_ptr_conv;
43228         this_ptr_conv.inner = untag_ptr(this_ptr);
43229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43231         this_ptr_conv.is_owned = false;
43232         LDKChannelPublicKeys val_conv;
43233         val_conv.inner = untag_ptr(val);
43234         val_conv.is_owned = ptr_is_owned(val);
43235         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43236         val_conv = ChannelPublicKeys_clone(&val_conv);
43237         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
43238 }
43239
43240 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43241         LDKChannelTransactionParameters this_ptr_conv;
43242         this_ptr_conv.inner = untag_ptr(this_ptr);
43243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43245         this_ptr_conv.is_owned = false;
43246         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
43247         return ret_conv;
43248 }
43249
43250 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) {
43251         LDKChannelTransactionParameters this_ptr_conv;
43252         this_ptr_conv.inner = untag_ptr(this_ptr);
43253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43255         this_ptr_conv.is_owned = false;
43256         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
43257 }
43258
43259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
43260         LDKChannelTransactionParameters this_ptr_conv;
43261         this_ptr_conv.inner = untag_ptr(this_ptr);
43262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43264         this_ptr_conv.is_owned = false;
43265         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
43266         return ret_conv;
43267 }
43268
43269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43270         LDKChannelTransactionParameters this_ptr_conv;
43271         this_ptr_conv.inner = untag_ptr(this_ptr);
43272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43274         this_ptr_conv.is_owned = false;
43275         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
43276 }
43277
43278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
43279         LDKChannelTransactionParameters this_ptr_conv;
43280         this_ptr_conv.inner = untag_ptr(this_ptr);
43281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43283         this_ptr_conv.is_owned = false;
43284         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
43285         int64_t ret_ref = 0;
43286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43288         return ret_ref;
43289 }
43290
43291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43292         LDKChannelTransactionParameters this_ptr_conv;
43293         this_ptr_conv.inner = untag_ptr(this_ptr);
43294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43296         this_ptr_conv.is_owned = false;
43297         LDKCounterpartyChannelTransactionParameters val_conv;
43298         val_conv.inner = untag_ptr(val);
43299         val_conv.is_owned = ptr_is_owned(val);
43300         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43301         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
43302         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
43303 }
43304
43305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
43306         LDKChannelTransactionParameters this_ptr_conv;
43307         this_ptr_conv.inner = untag_ptr(this_ptr);
43308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43310         this_ptr_conv.is_owned = false;
43311         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
43312         int64_t ret_ref = 0;
43313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43315         return ret_ref;
43316 }
43317
43318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43319         LDKChannelTransactionParameters this_ptr_conv;
43320         this_ptr_conv.inner = untag_ptr(this_ptr);
43321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43323         this_ptr_conv.is_owned = false;
43324         LDKOutPoint val_conv;
43325         val_conv.inner = untag_ptr(val);
43326         val_conv.is_owned = ptr_is_owned(val);
43327         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43328         val_conv = OutPoint_clone(&val_conv);
43329         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
43330 }
43331
43332 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43333         LDKChannelTransactionParameters this_ptr_conv;
43334         this_ptr_conv.inner = untag_ptr(this_ptr);
43335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43337         this_ptr_conv.is_owned = false;
43338         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
43339         return ret_conv;
43340 }
43341
43342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
43343         LDKChannelTransactionParameters this_ptr_conv;
43344         this_ptr_conv.inner = untag_ptr(this_ptr);
43345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43347         this_ptr_conv.is_owned = false;
43348         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43349         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
43350 }
43351
43352 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43353         LDKChannelTransactionParameters this_ptr_conv;
43354         this_ptr_conv.inner = untag_ptr(this_ptr);
43355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43357         this_ptr_conv.is_owned = false;
43358         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_non_zero_fee_anchors(&this_ptr_conv));
43359         return ret_conv;
43360 }
43361
43362 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) {
43363         LDKChannelTransactionParameters this_ptr_conv;
43364         this_ptr_conv.inner = untag_ptr(this_ptr);
43365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43367         this_ptr_conv.is_owned = false;
43368         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43369         ChannelTransactionParameters_set_opt_non_zero_fee_anchors(&this_ptr_conv, val_conv);
43370 }
43371
43372 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) {
43373         LDKChannelPublicKeys holder_pubkeys_arg_conv;
43374         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
43375         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
43376         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
43377         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
43378         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
43379         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
43380         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
43381         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
43382         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
43383         LDKOutPoint funding_outpoint_arg_conv;
43384         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
43385         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
43386         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
43387         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
43388         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
43389         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
43390         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);
43391         int64_t ret_ref = 0;
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43394         return ret_ref;
43395 }
43396
43397 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
43398         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
43399         int64_t ret_ref = 0;
43400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43402         return ret_ref;
43403 }
43404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43405         LDKChannelTransactionParameters arg_conv;
43406         arg_conv.inner = untag_ptr(arg);
43407         arg_conv.is_owned = ptr_is_owned(arg);
43408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43409         arg_conv.is_owned = false;
43410         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
43411         return ret_conv;
43412 }
43413
43414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43415         LDKChannelTransactionParameters orig_conv;
43416         orig_conv.inner = untag_ptr(orig);
43417         orig_conv.is_owned = ptr_is_owned(orig);
43418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43419         orig_conv.is_owned = false;
43420         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
43421         int64_t ret_ref = 0;
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43424         return ret_ref;
43425 }
43426
43427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43428         LDKChannelTransactionParameters a_conv;
43429         a_conv.inner = untag_ptr(a);
43430         a_conv.is_owned = ptr_is_owned(a);
43431         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43432         a_conv.is_owned = false;
43433         LDKChannelTransactionParameters b_conv;
43434         b_conv.inner = untag_ptr(b);
43435         b_conv.is_owned = ptr_is_owned(b);
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43437         b_conv.is_owned = false;
43438         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
43439         return ret_conv;
43440 }
43441
43442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43443         LDKCounterpartyChannelTransactionParameters this_obj_conv;
43444         this_obj_conv.inner = untag_ptr(this_obj);
43445         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43447         CounterpartyChannelTransactionParameters_free(this_obj_conv);
43448 }
43449
43450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43451         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43452         this_ptr_conv.inner = untag_ptr(this_ptr);
43453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43455         this_ptr_conv.is_owned = false;
43456         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
43457         int64_t ret_ref = 0;
43458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43460         return ret_ref;
43461 }
43462
43463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43464         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43465         this_ptr_conv.inner = untag_ptr(this_ptr);
43466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43468         this_ptr_conv.is_owned = false;
43469         LDKChannelPublicKeys val_conv;
43470         val_conv.inner = untag_ptr(val);
43471         val_conv.is_owned = ptr_is_owned(val);
43472         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43473         val_conv = ChannelPublicKeys_clone(&val_conv);
43474         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
43475 }
43476
43477 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43478         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43479         this_ptr_conv.inner = untag_ptr(this_ptr);
43480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43482         this_ptr_conv.is_owned = false;
43483         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
43484         return ret_conv;
43485 }
43486
43487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43488         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43489         this_ptr_conv.inner = untag_ptr(this_ptr);
43490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43492         this_ptr_conv.is_owned = false;
43493         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
43494 }
43495
43496 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) {
43497         LDKChannelPublicKeys pubkeys_arg_conv;
43498         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
43499         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
43500         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
43501         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
43502         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
43503         int64_t ret_ref = 0;
43504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43506         return ret_ref;
43507 }
43508
43509 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
43510         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
43511         int64_t ret_ref = 0;
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43513         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43514         return ret_ref;
43515 }
43516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43517         LDKCounterpartyChannelTransactionParameters arg_conv;
43518         arg_conv.inner = untag_ptr(arg);
43519         arg_conv.is_owned = ptr_is_owned(arg);
43520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43521         arg_conv.is_owned = false;
43522         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
43523         return ret_conv;
43524 }
43525
43526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43527         LDKCounterpartyChannelTransactionParameters orig_conv;
43528         orig_conv.inner = untag_ptr(orig);
43529         orig_conv.is_owned = ptr_is_owned(orig);
43530         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43531         orig_conv.is_owned = false;
43532         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
43533         int64_t ret_ref = 0;
43534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43536         return ret_ref;
43537 }
43538
43539 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43540         LDKCounterpartyChannelTransactionParameters a_conv;
43541         a_conv.inner = untag_ptr(a);
43542         a_conv.is_owned = ptr_is_owned(a);
43543         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43544         a_conv.is_owned = false;
43545         LDKCounterpartyChannelTransactionParameters b_conv;
43546         b_conv.inner = untag_ptr(b);
43547         b_conv.is_owned = ptr_is_owned(b);
43548         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43549         b_conv.is_owned = false;
43550         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
43551         return ret_conv;
43552 }
43553
43554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
43555         LDKChannelTransactionParameters this_arg_conv;
43556         this_arg_conv.inner = untag_ptr(this_arg);
43557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43559         this_arg_conv.is_owned = false;
43560         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
43561         return ret_conv;
43562 }
43563
43564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43565         LDKChannelTransactionParameters this_arg_conv;
43566         this_arg_conv.inner = untag_ptr(this_arg);
43567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43569         this_arg_conv.is_owned = false;
43570         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
43571         int64_t ret_ref = 0;
43572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43574         return ret_ref;
43575 }
43576
43577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43578         LDKChannelTransactionParameters this_arg_conv;
43579         this_arg_conv.inner = untag_ptr(this_arg);
43580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43582         this_arg_conv.is_owned = false;
43583         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
43584         int64_t ret_ref = 0;
43585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43587         return ret_ref;
43588 }
43589
43590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43591         LDKCounterpartyChannelTransactionParameters obj_conv;
43592         obj_conv.inner = untag_ptr(obj);
43593         obj_conv.is_owned = ptr_is_owned(obj);
43594         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43595         obj_conv.is_owned = false;
43596         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
43597         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43598         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43599         CVec_u8Z_free(ret_var);
43600         return ret_arr;
43601 }
43602
43603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43604         LDKu8slice ser_ref;
43605         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43606         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43607         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
43608         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
43609         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43610         return tag_ptr(ret_conv, true);
43611 }
43612
43613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43614         LDKChannelTransactionParameters obj_conv;
43615         obj_conv.inner = untag_ptr(obj);
43616         obj_conv.is_owned = ptr_is_owned(obj);
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43618         obj_conv.is_owned = false;
43619         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
43620         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43621         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43622         CVec_u8Z_free(ret_var);
43623         return ret_arr;
43624 }
43625
43626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43627         LDKu8slice ser_ref;
43628         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43629         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43630         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
43631         *ret_conv = ChannelTransactionParameters_read(ser_ref);
43632         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43633         return tag_ptr(ret_conv, true);
43634 }
43635
43636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43637         LDKDirectedChannelTransactionParameters this_obj_conv;
43638         this_obj_conv.inner = untag_ptr(this_obj);
43639         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43641         DirectedChannelTransactionParameters_free(this_obj_conv);
43642 }
43643
43644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43645         LDKDirectedChannelTransactionParameters this_arg_conv;
43646         this_arg_conv.inner = untag_ptr(this_arg);
43647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43649         this_arg_conv.is_owned = false;
43650         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
43651         int64_t ret_ref = 0;
43652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43654         return ret_ref;
43655 }
43656
43657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43658         LDKDirectedChannelTransactionParameters this_arg_conv;
43659         this_arg_conv.inner = untag_ptr(this_arg);
43660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43662         this_arg_conv.is_owned = false;
43663         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
43664         int64_t ret_ref = 0;
43665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43667         return ret_ref;
43668 }
43669
43670 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
43671         LDKDirectedChannelTransactionParameters this_arg_conv;
43672         this_arg_conv.inner = untag_ptr(this_arg);
43673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43675         this_arg_conv.is_owned = false;
43676         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
43677         return ret_conv;
43678 }
43679
43680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
43681         LDKDirectedChannelTransactionParameters this_arg_conv;
43682         this_arg_conv.inner = untag_ptr(this_arg);
43683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43685         this_arg_conv.is_owned = false;
43686         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
43687         return ret_conv;
43688 }
43689
43690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
43691         LDKDirectedChannelTransactionParameters this_arg_conv;
43692         this_arg_conv.inner = untag_ptr(this_arg);
43693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43695         this_arg_conv.is_owned = false;
43696         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
43697         int64_t ret_ref = 0;
43698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43700         return ret_ref;
43701 }
43702
43703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43704         LDKDirectedChannelTransactionParameters this_arg_conv;
43705         this_arg_conv.inner = untag_ptr(this_arg);
43706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43708         this_arg_conv.is_owned = false;
43709         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
43710         return ret_conv;
43711 }
43712
43713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43714         LDKHolderCommitmentTransaction this_obj_conv;
43715         this_obj_conv.inner = untag_ptr(this_obj);
43716         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43718         HolderCommitmentTransaction_free(this_obj_conv);
43719 }
43720
43721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
43722         LDKHolderCommitmentTransaction this_ptr_conv;
43723         this_ptr_conv.inner = untag_ptr(this_ptr);
43724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43726         this_ptr_conv.is_owned = false;
43727         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
43729         return ret_arr;
43730 }
43731
43732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43733         LDKHolderCommitmentTransaction this_ptr_conv;
43734         this_ptr_conv.inner = untag_ptr(this_ptr);
43735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43737         this_ptr_conv.is_owned = false;
43738         LDKSignature val_ref;
43739         CHECK((*env)->GetArrayLength(env, val) == 64);
43740         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
43741         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
43742 }
43743
43744 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
43745         LDKHolderCommitmentTransaction this_ptr_conv;
43746         this_ptr_conv.inner = untag_ptr(this_ptr);
43747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43749         this_ptr_conv.is_owned = false;
43750         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
43751         jobjectArray ret_arr = NULL;
43752         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
43753         ;
43754         for (size_t i = 0; i < ret_var.datalen; i++) {
43755                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
43756                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
43757                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
43758         }
43759         
43760         FREE(ret_var.data);
43761         return ret_arr;
43762 }
43763
43764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
43765         LDKHolderCommitmentTransaction this_ptr_conv;
43766         this_ptr_conv.inner = untag_ptr(this_ptr);
43767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43769         this_ptr_conv.is_owned = false;
43770         LDKCVec_SignatureZ val_constr;
43771         val_constr.datalen = (*env)->GetArrayLength(env, val);
43772         if (val_constr.datalen > 0)
43773                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43774         else
43775                 val_constr.data = NULL;
43776         for (size_t i = 0; i < val_constr.datalen; i++) {
43777                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
43778                 LDKSignature val_conv_8_ref;
43779                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
43780                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
43781                 val_constr.data[i] = val_conv_8_ref;
43782         }
43783         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
43784 }
43785
43786 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
43787         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
43788         int64_t ret_ref = 0;
43789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43791         return ret_ref;
43792 }
43793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43794         LDKHolderCommitmentTransaction arg_conv;
43795         arg_conv.inner = untag_ptr(arg);
43796         arg_conv.is_owned = ptr_is_owned(arg);
43797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43798         arg_conv.is_owned = false;
43799         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
43800         return ret_conv;
43801 }
43802
43803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43804         LDKHolderCommitmentTransaction orig_conv;
43805         orig_conv.inner = untag_ptr(orig);
43806         orig_conv.is_owned = ptr_is_owned(orig);
43807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43808         orig_conv.is_owned = false;
43809         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
43810         int64_t ret_ref = 0;
43811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43813         return ret_ref;
43814 }
43815
43816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43817         LDKHolderCommitmentTransaction obj_conv;
43818         obj_conv.inner = untag_ptr(obj);
43819         obj_conv.is_owned = ptr_is_owned(obj);
43820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43821         obj_conv.is_owned = false;
43822         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
43823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43825         CVec_u8Z_free(ret_var);
43826         return ret_arr;
43827 }
43828
43829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43830         LDKu8slice ser_ref;
43831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43833         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
43834         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
43835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43836         return tag_ptr(ret_conv, true);
43837 }
43838
43839 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) {
43840         LDKCommitmentTransaction commitment_tx_conv;
43841         commitment_tx_conv.inner = untag_ptr(commitment_tx);
43842         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
43843         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
43844         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
43845         LDKSignature counterparty_sig_ref;
43846         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
43847         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
43848         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
43849         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
43850         if (counterparty_htlc_sigs_constr.datalen > 0)
43851                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43852         else
43853                 counterparty_htlc_sigs_constr.data = NULL;
43854         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
43855                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
43856                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
43857                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
43858                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
43859                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
43860         }
43861         LDKPublicKey holder_funding_key_ref;
43862         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
43863         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
43864         LDKPublicKey counterparty_funding_key_ref;
43865         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43866         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43867         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43868         int64_t ret_ref = 0;
43869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43871         return ret_ref;
43872 }
43873
43874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43875         LDKBuiltCommitmentTransaction this_obj_conv;
43876         this_obj_conv.inner = untag_ptr(this_obj);
43877         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43879         BuiltCommitmentTransaction_free(this_obj_conv);
43880 }
43881
43882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43883         LDKBuiltCommitmentTransaction this_ptr_conv;
43884         this_ptr_conv.inner = untag_ptr(this_ptr);
43885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43887         this_ptr_conv.is_owned = false;
43888         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43891         Transaction_free(ret_var);
43892         return ret_arr;
43893 }
43894
43895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43896         LDKBuiltCommitmentTransaction this_ptr_conv;
43897         this_ptr_conv.inner = untag_ptr(this_ptr);
43898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43900         this_ptr_conv.is_owned = false;
43901         LDKTransaction val_ref;
43902         val_ref.datalen = (*env)->GetArrayLength(env, val);
43903         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43904         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43905         val_ref.data_is_owned = true;
43906         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43907 }
43908
43909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43910         LDKBuiltCommitmentTransaction this_ptr_conv;
43911         this_ptr_conv.inner = untag_ptr(this_ptr);
43912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43914         this_ptr_conv.is_owned = false;
43915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43917         return ret_arr;
43918 }
43919
43920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43921         LDKBuiltCommitmentTransaction this_ptr_conv;
43922         this_ptr_conv.inner = untag_ptr(this_ptr);
43923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43925         this_ptr_conv.is_owned = false;
43926         LDKThirtyTwoBytes val_ref;
43927         CHECK((*env)->GetArrayLength(env, val) == 32);
43928         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43929         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43930 }
43931
43932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43933         LDKTransaction transaction_arg_ref;
43934         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43935         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43936         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43937         transaction_arg_ref.data_is_owned = true;
43938         LDKThirtyTwoBytes txid_arg_ref;
43939         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43940         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43941         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43942         int64_t ret_ref = 0;
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43945         return ret_ref;
43946 }
43947
43948 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43949         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43950         int64_t ret_ref = 0;
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43953         return ret_ref;
43954 }
43955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43956         LDKBuiltCommitmentTransaction arg_conv;
43957         arg_conv.inner = untag_ptr(arg);
43958         arg_conv.is_owned = ptr_is_owned(arg);
43959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43960         arg_conv.is_owned = false;
43961         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43962         return ret_conv;
43963 }
43964
43965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43966         LDKBuiltCommitmentTransaction orig_conv;
43967         orig_conv.inner = untag_ptr(orig);
43968         orig_conv.is_owned = ptr_is_owned(orig);
43969         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43970         orig_conv.is_owned = false;
43971         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43972         int64_t ret_ref = 0;
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43975         return ret_ref;
43976 }
43977
43978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43979         LDKBuiltCommitmentTransaction obj_conv;
43980         obj_conv.inner = untag_ptr(obj);
43981         obj_conv.is_owned = ptr_is_owned(obj);
43982         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43983         obj_conv.is_owned = false;
43984         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43987         CVec_u8Z_free(ret_var);
43988         return ret_arr;
43989 }
43990
43991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43992         LDKu8slice ser_ref;
43993         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43994         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43995         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43996         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43997         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43998         return tag_ptr(ret_conv, true);
43999 }
44000
44001 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) {
44002         LDKBuiltCommitmentTransaction this_arg_conv;
44003         this_arg_conv.inner = untag_ptr(this_arg);
44004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44006         this_arg_conv.is_owned = false;
44007         LDKu8slice funding_redeemscript_ref;
44008         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44009         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44010         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44012         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44013         return ret_arr;
44014 }
44015
44016 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
44017         LDKBuiltCommitmentTransaction this_arg_conv;
44018         this_arg_conv.inner = untag_ptr(this_arg);
44019         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44021         this_arg_conv.is_owned = false;
44022         uint8_t funding_key_arr[32];
44023         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44024         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44025         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44026         LDKu8slice funding_redeemscript_ref;
44027         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44028         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44029         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44030         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign_counterparty_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44031         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44032         return ret_arr;
44033 }
44034
44035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis, int64_t entropy_source) {
44036         LDKBuiltCommitmentTransaction this_arg_conv;
44037         this_arg_conv.inner = untag_ptr(this_arg);
44038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44040         this_arg_conv.is_owned = false;
44041         uint8_t funding_key_arr[32];
44042         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44043         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44044         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44045         LDKu8slice funding_redeemscript_ref;
44046         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44047         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44048         void* entropy_source_ptr = untag_ptr(entropy_source);
44049         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44050         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44051         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign_holder_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis, entropy_source_conv).compact_form);
44053         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44054         return ret_arr;
44055 }
44056
44057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44058         LDKClosingTransaction this_obj_conv;
44059         this_obj_conv.inner = untag_ptr(this_obj);
44060         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44062         ClosingTransaction_free(this_obj_conv);
44063 }
44064
44065 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
44066         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
44067         int64_t ret_ref = 0;
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44070         return ret_ref;
44071 }
44072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44073         LDKClosingTransaction arg_conv;
44074         arg_conv.inner = untag_ptr(arg);
44075         arg_conv.is_owned = ptr_is_owned(arg);
44076         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44077         arg_conv.is_owned = false;
44078         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
44079         return ret_conv;
44080 }
44081
44082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44083         LDKClosingTransaction orig_conv;
44084         orig_conv.inner = untag_ptr(orig);
44085         orig_conv.is_owned = ptr_is_owned(orig);
44086         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44087         orig_conv.is_owned = false;
44088         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
44089         int64_t ret_ref = 0;
44090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44092         return ret_ref;
44093 }
44094
44095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
44096         LDKClosingTransaction o_conv;
44097         o_conv.inner = untag_ptr(o);
44098         o_conv.is_owned = ptr_is_owned(o);
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44100         o_conv.is_owned = false;
44101         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
44102         return ret_conv;
44103 }
44104
44105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44106         LDKClosingTransaction a_conv;
44107         a_conv.inner = untag_ptr(a);
44108         a_conv.is_owned = ptr_is_owned(a);
44109         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44110         a_conv.is_owned = false;
44111         LDKClosingTransaction b_conv;
44112         b_conv.inner = untag_ptr(b);
44113         b_conv.is_owned = ptr_is_owned(b);
44114         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44115         b_conv.is_owned = false;
44116         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
44117         return ret_conv;
44118 }
44119
44120 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) {
44121         LDKCVec_u8Z to_holder_script_ref;
44122         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
44123         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
44124         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
44125         LDKCVec_u8Z to_counterparty_script_ref;
44126         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
44127         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
44128         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
44129         LDKOutPoint funding_outpoint_conv;
44130         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44131         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44132         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44133         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44134         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
44135         int64_t ret_ref = 0;
44136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44138         return ret_ref;
44139 }
44140
44141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44142         LDKClosingTransaction this_arg_conv;
44143         this_arg_conv.inner = untag_ptr(this_arg);
44144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44146         this_arg_conv.is_owned = false;
44147         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
44148         int64_t ret_ref = 0;
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44151         return ret_ref;
44152 }
44153
44154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
44155         LDKClosingTransaction this_arg_conv;
44156         this_arg_conv.inner = untag_ptr(this_arg);
44157         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44159         this_arg_conv.is_owned = false;
44160         LDKOutPoint funding_outpoint_conv;
44161         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44162         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44164         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44165         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
44166         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
44167         return tag_ptr(ret_conv, true);
44168 }
44169
44170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44171         LDKClosingTransaction this_arg_conv;
44172         this_arg_conv.inner = untag_ptr(this_arg);
44173         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44175         this_arg_conv.is_owned = false;
44176         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
44177         return ret_conv;
44178 }
44179
44180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44181         LDKClosingTransaction this_arg_conv;
44182         this_arg_conv.inner = untag_ptr(this_arg);
44183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44185         this_arg_conv.is_owned = false;
44186         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
44187         return ret_conv;
44188 }
44189
44190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44191         LDKClosingTransaction this_arg_conv;
44192         this_arg_conv.inner = untag_ptr(this_arg);
44193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44195         this_arg_conv.is_owned = false;
44196         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
44197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44199         return ret_arr;
44200 }
44201
44202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44203         LDKClosingTransaction this_arg_conv;
44204         this_arg_conv.inner = untag_ptr(this_arg);
44205         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44207         this_arg_conv.is_owned = false;
44208         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
44209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44211         return ret_arr;
44212 }
44213
44214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44215         LDKTrustedClosingTransaction this_obj_conv;
44216         this_obj_conv.inner = untag_ptr(this_obj);
44217         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44219         TrustedClosingTransaction_free(this_obj_conv);
44220 }
44221
44222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44223         LDKTrustedClosingTransaction this_arg_conv;
44224         this_arg_conv.inner = untag_ptr(this_arg);
44225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44227         this_arg_conv.is_owned = false;
44228         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
44229         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44230         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44231         Transaction_free(ret_var);
44232         return ret_arr;
44233 }
44234
44235 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) {
44236         LDKTrustedClosingTransaction this_arg_conv;
44237         this_arg_conv.inner = untag_ptr(this_arg);
44238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44240         this_arg_conv.is_owned = false;
44241         LDKu8slice funding_redeemscript_ref;
44242         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44243         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44244         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44245         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44246         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44247         return ret_arr;
44248 }
44249
44250 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) {
44251         LDKTrustedClosingTransaction this_arg_conv;
44252         this_arg_conv.inner = untag_ptr(this_arg);
44253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44255         this_arg_conv.is_owned = false;
44256         uint8_t funding_key_arr[32];
44257         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44258         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44259         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44260         LDKu8slice funding_redeemscript_ref;
44261         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44262         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44263         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44264         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44265         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44266         return ret_arr;
44267 }
44268
44269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44270         LDKCommitmentTransaction this_obj_conv;
44271         this_obj_conv.inner = untag_ptr(this_obj);
44272         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44274         CommitmentTransaction_free(this_obj_conv);
44275 }
44276
44277 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
44278         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
44279         int64_t ret_ref = 0;
44280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44282         return ret_ref;
44283 }
44284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44285         LDKCommitmentTransaction arg_conv;
44286         arg_conv.inner = untag_ptr(arg);
44287         arg_conv.is_owned = ptr_is_owned(arg);
44288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44289         arg_conv.is_owned = false;
44290         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
44291         return ret_conv;
44292 }
44293
44294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44295         LDKCommitmentTransaction orig_conv;
44296         orig_conv.inner = untag_ptr(orig);
44297         orig_conv.is_owned = ptr_is_owned(orig);
44298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44299         orig_conv.is_owned = false;
44300         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
44301         int64_t ret_ref = 0;
44302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44304         return ret_ref;
44305 }
44306
44307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
44308         LDKCommitmentTransaction obj_conv;
44309         obj_conv.inner = untag_ptr(obj);
44310         obj_conv.is_owned = ptr_is_owned(obj);
44311         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44312         obj_conv.is_owned = false;
44313         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
44314         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44315         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44316         CVec_u8Z_free(ret_var);
44317         return ret_arr;
44318 }
44319
44320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44321         LDKu8slice ser_ref;
44322         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44323         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44324         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
44325         *ret_conv = CommitmentTransaction_read(ser_ref);
44326         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44327         return tag_ptr(ret_conv, true);
44328 }
44329
44330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
44331         LDKCommitmentTransaction 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         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
44337         return ret_conv;
44338 }
44339
44340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44341         LDKCommitmentTransaction 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         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
44347         return ret_conv;
44348 }
44349
44350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44351         LDKCommitmentTransaction this_arg_conv;
44352         this_arg_conv.inner = untag_ptr(this_arg);
44353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44355         this_arg_conv.is_owned = false;
44356         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
44357         return ret_conv;
44358 }
44359
44360 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
44361         LDKCommitmentTransaction this_arg_conv;
44362         this_arg_conv.inner = untag_ptr(this_arg);
44363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44365         this_arg_conv.is_owned = false;
44366         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
44367         return ret_conv;
44368 }
44369
44370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44371         LDKCommitmentTransaction this_arg_conv;
44372         this_arg_conv.inner = untag_ptr(this_arg);
44373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44375         this_arg_conv.is_owned = false;
44376         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
44377         int64_t ret_ref = 0;
44378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44380         return ret_ref;
44381 }
44382
44383 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) {
44384         LDKCommitmentTransaction this_arg_conv;
44385         this_arg_conv.inner = untag_ptr(this_arg);
44386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44388         this_arg_conv.is_owned = false;
44389         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44390         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44391         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44392         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44393         channel_parameters_conv.is_owned = false;
44394         LDKChannelPublicKeys broadcaster_keys_conv;
44395         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
44396         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
44397         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
44398         broadcaster_keys_conv.is_owned = false;
44399         LDKChannelPublicKeys countersignatory_keys_conv;
44400         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
44401         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
44402         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
44403         countersignatory_keys_conv.is_owned = false;
44404         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
44405         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
44406         return tag_ptr(ret_conv, true);
44407 }
44408
44409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44410         LDKTrustedCommitmentTransaction this_obj_conv;
44411         this_obj_conv.inner = untag_ptr(this_obj);
44412         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44414         TrustedCommitmentTransaction_free(this_obj_conv);
44415 }
44416
44417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
44418         LDKTrustedCommitmentTransaction this_arg_conv;
44419         this_arg_conv.inner = untag_ptr(this_arg);
44420         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44422         this_arg_conv.is_owned = false;
44423         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
44425         return ret_arr;
44426 }
44427
44428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44429         LDKTrustedCommitmentTransaction this_arg_conv;
44430         this_arg_conv.inner = untag_ptr(this_arg);
44431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44433         this_arg_conv.is_owned = false;
44434         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
44435         int64_t ret_ref = 0;
44436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44438         return ret_ref;
44439 }
44440
44441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
44442         LDKTrustedCommitmentTransaction this_arg_conv;
44443         this_arg_conv.inner = untag_ptr(this_arg);
44444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44446         this_arg_conv.is_owned = false;
44447         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
44448         int64_t ret_ref = 0;
44449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44451         return ret_ref;
44452 }
44453
44454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
44455         LDKTrustedCommitmentTransaction this_arg_conv;
44456         this_arg_conv.inner = untag_ptr(this_arg);
44457         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44459         this_arg_conv.is_owned = false;
44460         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
44461         return ret_conv;
44462 }
44463
44464 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, int64_t entropy_source) {
44465         LDKTrustedCommitmentTransaction this_arg_conv;
44466         this_arg_conv.inner = untag_ptr(this_arg);
44467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44469         this_arg_conv.is_owned = false;
44470         uint8_t htlc_base_key_arr[32];
44471         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
44472         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
44473         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
44474         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44475         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44476         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44477         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44478         channel_parameters_conv.is_owned = false;
44479         void* entropy_source_ptr = untag_ptr(entropy_source);
44480         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44481         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44482         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
44483         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
44484         return tag_ptr(ret_conv, true);
44485 }
44486
44487 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) {
44488         LDKPublicKey broadcaster_payment_basepoint_ref;
44489         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
44490         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
44491         LDKPublicKey countersignatory_payment_basepoint_ref;
44492         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
44493         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
44494         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
44495         return ret_conv;
44496 }
44497
44498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44499         LDKInitFeatures a_conv;
44500         a_conv.inner = untag_ptr(a);
44501         a_conv.is_owned = ptr_is_owned(a);
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44503         a_conv.is_owned = false;
44504         LDKInitFeatures b_conv;
44505         b_conv.inner = untag_ptr(b);
44506         b_conv.is_owned = ptr_is_owned(b);
44507         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44508         b_conv.is_owned = false;
44509         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
44510         return ret_conv;
44511 }
44512
44513 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44514         LDKNodeFeatures a_conv;
44515         a_conv.inner = untag_ptr(a);
44516         a_conv.is_owned = ptr_is_owned(a);
44517         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44518         a_conv.is_owned = false;
44519         LDKNodeFeatures b_conv;
44520         b_conv.inner = untag_ptr(b);
44521         b_conv.is_owned = ptr_is_owned(b);
44522         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44523         b_conv.is_owned = false;
44524         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
44525         return ret_conv;
44526 }
44527
44528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44529         LDKChannelFeatures a_conv;
44530         a_conv.inner = untag_ptr(a);
44531         a_conv.is_owned = ptr_is_owned(a);
44532         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44533         a_conv.is_owned = false;
44534         LDKChannelFeatures b_conv;
44535         b_conv.inner = untag_ptr(b);
44536         b_conv.is_owned = ptr_is_owned(b);
44537         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44538         b_conv.is_owned = false;
44539         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
44540         return ret_conv;
44541 }
44542
44543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44544         LDKInvoiceFeatures a_conv;
44545         a_conv.inner = untag_ptr(a);
44546         a_conv.is_owned = ptr_is_owned(a);
44547         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44548         a_conv.is_owned = false;
44549         LDKInvoiceFeatures b_conv;
44550         b_conv.inner = untag_ptr(b);
44551         b_conv.is_owned = ptr_is_owned(b);
44552         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44553         b_conv.is_owned = false;
44554         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
44555         return ret_conv;
44556 }
44557
44558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44559         LDKOfferFeatures a_conv;
44560         a_conv.inner = untag_ptr(a);
44561         a_conv.is_owned = ptr_is_owned(a);
44562         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44563         a_conv.is_owned = false;
44564         LDKOfferFeatures b_conv;
44565         b_conv.inner = untag_ptr(b);
44566         b_conv.is_owned = ptr_is_owned(b);
44567         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44568         b_conv.is_owned = false;
44569         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
44570         return ret_conv;
44571 }
44572
44573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44574         LDKInvoiceRequestFeatures a_conv;
44575         a_conv.inner = untag_ptr(a);
44576         a_conv.is_owned = ptr_is_owned(a);
44577         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44578         a_conv.is_owned = false;
44579         LDKInvoiceRequestFeatures b_conv;
44580         b_conv.inner = untag_ptr(b);
44581         b_conv.is_owned = ptr_is_owned(b);
44582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44583         b_conv.is_owned = false;
44584         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
44585         return ret_conv;
44586 }
44587
44588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44589         LDKBolt12InvoiceFeatures a_conv;
44590         a_conv.inner = untag_ptr(a);
44591         a_conv.is_owned = ptr_is_owned(a);
44592         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44593         a_conv.is_owned = false;
44594         LDKBolt12InvoiceFeatures b_conv;
44595         b_conv.inner = untag_ptr(b);
44596         b_conv.is_owned = ptr_is_owned(b);
44597         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44598         b_conv.is_owned = false;
44599         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
44600         return ret_conv;
44601 }
44602
44603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44604         LDKBlindedHopFeatures a_conv;
44605         a_conv.inner = untag_ptr(a);
44606         a_conv.is_owned = ptr_is_owned(a);
44607         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44608         a_conv.is_owned = false;
44609         LDKBlindedHopFeatures b_conv;
44610         b_conv.inner = untag_ptr(b);
44611         b_conv.is_owned = ptr_is_owned(b);
44612         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44613         b_conv.is_owned = false;
44614         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
44615         return ret_conv;
44616 }
44617
44618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44619         LDKChannelTypeFeatures a_conv;
44620         a_conv.inner = untag_ptr(a);
44621         a_conv.is_owned = ptr_is_owned(a);
44622         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44623         a_conv.is_owned = false;
44624         LDKChannelTypeFeatures b_conv;
44625         b_conv.inner = untag_ptr(b);
44626         b_conv.is_owned = ptr_is_owned(b);
44627         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44628         b_conv.is_owned = false;
44629         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
44630         return ret_conv;
44631 }
44632
44633 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
44634         LDKInitFeatures ret_var = InitFeatures_clone(arg);
44635         int64_t ret_ref = 0;
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44638         return ret_ref;
44639 }
44640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44641         LDKInitFeatures arg_conv;
44642         arg_conv.inner = untag_ptr(arg);
44643         arg_conv.is_owned = ptr_is_owned(arg);
44644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44645         arg_conv.is_owned = false;
44646         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
44647         return ret_conv;
44648 }
44649
44650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44651         LDKInitFeatures orig_conv;
44652         orig_conv.inner = untag_ptr(orig);
44653         orig_conv.is_owned = ptr_is_owned(orig);
44654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44655         orig_conv.is_owned = false;
44656         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
44657         int64_t ret_ref = 0;
44658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44660         return ret_ref;
44661 }
44662
44663 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
44664         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
44665         int64_t ret_ref = 0;
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44668         return ret_ref;
44669 }
44670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44671         LDKNodeFeatures arg_conv;
44672         arg_conv.inner = untag_ptr(arg);
44673         arg_conv.is_owned = ptr_is_owned(arg);
44674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44675         arg_conv.is_owned = false;
44676         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
44677         return ret_conv;
44678 }
44679
44680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44681         LDKNodeFeatures orig_conv;
44682         orig_conv.inner = untag_ptr(orig);
44683         orig_conv.is_owned = ptr_is_owned(orig);
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44685         orig_conv.is_owned = false;
44686         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
44687         int64_t ret_ref = 0;
44688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44690         return ret_ref;
44691 }
44692
44693 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
44694         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
44695         int64_t ret_ref = 0;
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44698         return ret_ref;
44699 }
44700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44701         LDKChannelFeatures arg_conv;
44702         arg_conv.inner = untag_ptr(arg);
44703         arg_conv.is_owned = ptr_is_owned(arg);
44704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44705         arg_conv.is_owned = false;
44706         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
44707         return ret_conv;
44708 }
44709
44710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44711         LDKChannelFeatures orig_conv;
44712         orig_conv.inner = untag_ptr(orig);
44713         orig_conv.is_owned = ptr_is_owned(orig);
44714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44715         orig_conv.is_owned = false;
44716         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
44717         int64_t ret_ref = 0;
44718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44720         return ret_ref;
44721 }
44722
44723 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
44724         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
44725         int64_t ret_ref = 0;
44726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44728         return ret_ref;
44729 }
44730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44731         LDKInvoiceFeatures arg_conv;
44732         arg_conv.inner = untag_ptr(arg);
44733         arg_conv.is_owned = ptr_is_owned(arg);
44734         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44735         arg_conv.is_owned = false;
44736         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
44737         return ret_conv;
44738 }
44739
44740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44741         LDKInvoiceFeatures orig_conv;
44742         orig_conv.inner = untag_ptr(orig);
44743         orig_conv.is_owned = ptr_is_owned(orig);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44745         orig_conv.is_owned = false;
44746         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
44747         int64_t ret_ref = 0;
44748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44750         return ret_ref;
44751 }
44752
44753 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
44754         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
44755         int64_t ret_ref = 0;
44756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44758         return ret_ref;
44759 }
44760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44761         LDKOfferFeatures arg_conv;
44762         arg_conv.inner = untag_ptr(arg);
44763         arg_conv.is_owned = ptr_is_owned(arg);
44764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44765         arg_conv.is_owned = false;
44766         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
44767         return ret_conv;
44768 }
44769
44770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44771         LDKOfferFeatures orig_conv;
44772         orig_conv.inner = untag_ptr(orig);
44773         orig_conv.is_owned = ptr_is_owned(orig);
44774         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44775         orig_conv.is_owned = false;
44776         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
44777         int64_t ret_ref = 0;
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44779         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44780         return ret_ref;
44781 }
44782
44783 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
44784         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
44785         int64_t ret_ref = 0;
44786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44788         return ret_ref;
44789 }
44790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44791         LDKInvoiceRequestFeatures arg_conv;
44792         arg_conv.inner = untag_ptr(arg);
44793         arg_conv.is_owned = ptr_is_owned(arg);
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44795         arg_conv.is_owned = false;
44796         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
44797         return ret_conv;
44798 }
44799
44800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44801         LDKInvoiceRequestFeatures orig_conv;
44802         orig_conv.inner = untag_ptr(orig);
44803         orig_conv.is_owned = ptr_is_owned(orig);
44804         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44805         orig_conv.is_owned = false;
44806         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
44807         int64_t ret_ref = 0;
44808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44810         return ret_ref;
44811 }
44812
44813 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
44814         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
44815         int64_t ret_ref = 0;
44816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44818         return ret_ref;
44819 }
44820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44821         LDKBolt12InvoiceFeatures arg_conv;
44822         arg_conv.inner = untag_ptr(arg);
44823         arg_conv.is_owned = ptr_is_owned(arg);
44824         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44825         arg_conv.is_owned = false;
44826         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
44827         return ret_conv;
44828 }
44829
44830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44831         LDKBolt12InvoiceFeatures orig_conv;
44832         orig_conv.inner = untag_ptr(orig);
44833         orig_conv.is_owned = ptr_is_owned(orig);
44834         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44835         orig_conv.is_owned = false;
44836         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
44837         int64_t ret_ref = 0;
44838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44840         return ret_ref;
44841 }
44842
44843 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
44844         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
44845         int64_t ret_ref = 0;
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44848         return ret_ref;
44849 }
44850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44851         LDKBlindedHopFeatures arg_conv;
44852         arg_conv.inner = untag_ptr(arg);
44853         arg_conv.is_owned = ptr_is_owned(arg);
44854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44855         arg_conv.is_owned = false;
44856         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
44857         return ret_conv;
44858 }
44859
44860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44861         LDKBlindedHopFeatures orig_conv;
44862         orig_conv.inner = untag_ptr(orig);
44863         orig_conv.is_owned = ptr_is_owned(orig);
44864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44865         orig_conv.is_owned = false;
44866         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
44867         int64_t ret_ref = 0;
44868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44870         return ret_ref;
44871 }
44872
44873 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
44874         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
44875         int64_t ret_ref = 0;
44876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44878         return ret_ref;
44879 }
44880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44881         LDKChannelTypeFeatures arg_conv;
44882         arg_conv.inner = untag_ptr(arg);
44883         arg_conv.is_owned = ptr_is_owned(arg);
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44885         arg_conv.is_owned = false;
44886         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
44887         return ret_conv;
44888 }
44889
44890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44891         LDKChannelTypeFeatures orig_conv;
44892         orig_conv.inner = untag_ptr(orig);
44893         orig_conv.is_owned = ptr_is_owned(orig);
44894         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44895         orig_conv.is_owned = false;
44896         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
44897         int64_t ret_ref = 0;
44898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44900         return ret_ref;
44901 }
44902
44903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44904         LDKInitFeatures this_obj_conv;
44905         this_obj_conv.inner = untag_ptr(this_obj);
44906         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44908         InitFeatures_free(this_obj_conv);
44909 }
44910
44911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44912         LDKNodeFeatures this_obj_conv;
44913         this_obj_conv.inner = untag_ptr(this_obj);
44914         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44916         NodeFeatures_free(this_obj_conv);
44917 }
44918
44919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44920         LDKChannelFeatures this_obj_conv;
44921         this_obj_conv.inner = untag_ptr(this_obj);
44922         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44924         ChannelFeatures_free(this_obj_conv);
44925 }
44926
44927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44928         LDKInvoiceFeatures this_obj_conv;
44929         this_obj_conv.inner = untag_ptr(this_obj);
44930         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44932         InvoiceFeatures_free(this_obj_conv);
44933 }
44934
44935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44936         LDKOfferFeatures this_obj_conv;
44937         this_obj_conv.inner = untag_ptr(this_obj);
44938         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44940         OfferFeatures_free(this_obj_conv);
44941 }
44942
44943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44944         LDKInvoiceRequestFeatures this_obj_conv;
44945         this_obj_conv.inner = untag_ptr(this_obj);
44946         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44948         InvoiceRequestFeatures_free(this_obj_conv);
44949 }
44950
44951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44952         LDKBolt12InvoiceFeatures this_obj_conv;
44953         this_obj_conv.inner = untag_ptr(this_obj);
44954         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44956         Bolt12InvoiceFeatures_free(this_obj_conv);
44957 }
44958
44959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44960         LDKBlindedHopFeatures this_obj_conv;
44961         this_obj_conv.inner = untag_ptr(this_obj);
44962         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44964         BlindedHopFeatures_free(this_obj_conv);
44965 }
44966
44967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44968         LDKChannelTypeFeatures this_obj_conv;
44969         this_obj_conv.inner = untag_ptr(this_obj);
44970         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44972         ChannelTypeFeatures_free(this_obj_conv);
44973 }
44974
44975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
44976         LDKInitFeatures ret_var = InitFeatures_empty();
44977         int64_t ret_ref = 0;
44978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44980         return ret_ref;
44981 }
44982
44983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44984         LDKInitFeatures this_arg_conv;
44985         this_arg_conv.inner = untag_ptr(this_arg);
44986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44988         this_arg_conv.is_owned = false;
44989         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
44990         return ret_conv;
44991 }
44992
44993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
44994         LDKNodeFeatures ret_var = NodeFeatures_empty();
44995         int64_t ret_ref = 0;
44996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44997         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44998         return ret_ref;
44999 }
45000
45001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45002         LDKNodeFeatures this_arg_conv;
45003         this_arg_conv.inner = untag_ptr(this_arg);
45004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45006         this_arg_conv.is_owned = false;
45007         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
45008         return ret_conv;
45009 }
45010
45011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
45012         LDKChannelFeatures ret_var = ChannelFeatures_empty();
45013         int64_t ret_ref = 0;
45014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45016         return ret_ref;
45017 }
45018
45019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45020         LDKChannelFeatures this_arg_conv;
45021         this_arg_conv.inner = untag_ptr(this_arg);
45022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45024         this_arg_conv.is_owned = false;
45025         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
45026         return ret_conv;
45027 }
45028
45029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45030         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
45031         int64_t ret_ref = 0;
45032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45033         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45034         return ret_ref;
45035 }
45036
45037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45038         LDKInvoiceFeatures this_arg_conv;
45039         this_arg_conv.inner = untag_ptr(this_arg);
45040         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45042         this_arg_conv.is_owned = false;
45043         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45044         return ret_conv;
45045 }
45046
45047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
45048         LDKOfferFeatures ret_var = OfferFeatures_empty();
45049         int64_t ret_ref = 0;
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45052         return ret_ref;
45053 }
45054
45055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45056         LDKOfferFeatures this_arg_conv;
45057         this_arg_conv.inner = untag_ptr(this_arg);
45058         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45060         this_arg_conv.is_owned = false;
45061         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
45062         return ret_conv;
45063 }
45064
45065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
45066         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
45067         int64_t ret_ref = 0;
45068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45070         return ret_ref;
45071 }
45072
45073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45074         LDKInvoiceRequestFeatures this_arg_conv;
45075         this_arg_conv.inner = untag_ptr(this_arg);
45076         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45078         this_arg_conv.is_owned = false;
45079         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
45080         return ret_conv;
45081 }
45082
45083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45084         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
45085         int64_t ret_ref = 0;
45086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45088         return ret_ref;
45089 }
45090
45091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45092         LDKBolt12InvoiceFeatures this_arg_conv;
45093         this_arg_conv.inner = untag_ptr(this_arg);
45094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45096         this_arg_conv.is_owned = false;
45097         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45098         return ret_conv;
45099 }
45100
45101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1empty(JNIEnv *env, jclass clz) {
45102         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
45103         int64_t ret_ref = 0;
45104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45106         return ret_ref;
45107 }
45108
45109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45110         LDKBlindedHopFeatures this_arg_conv;
45111         this_arg_conv.inner = untag_ptr(this_arg);
45112         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45114         this_arg_conv.is_owned = false;
45115         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
45116         return ret_conv;
45117 }
45118
45119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
45120         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
45121         int64_t ret_ref = 0;
45122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45124         return ret_ref;
45125 }
45126
45127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45128         LDKChannelTypeFeatures this_arg_conv;
45129         this_arg_conv.inner = untag_ptr(this_arg);
45130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45132         this_arg_conv.is_owned = false;
45133         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
45134         return ret_conv;
45135 }
45136
45137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45138         LDKInitFeatures obj_conv;
45139         obj_conv.inner = untag_ptr(obj);
45140         obj_conv.is_owned = ptr_is_owned(obj);
45141         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45142         obj_conv.is_owned = false;
45143         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
45144         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45145         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45146         CVec_u8Z_free(ret_var);
45147         return ret_arr;
45148 }
45149
45150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45151         LDKu8slice ser_ref;
45152         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45153         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45154         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
45155         *ret_conv = InitFeatures_read(ser_ref);
45156         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45157         return tag_ptr(ret_conv, true);
45158 }
45159
45160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45161         LDKChannelFeatures obj_conv;
45162         obj_conv.inner = untag_ptr(obj);
45163         obj_conv.is_owned = ptr_is_owned(obj);
45164         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45165         obj_conv.is_owned = false;
45166         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
45167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45169         CVec_u8Z_free(ret_var);
45170         return ret_arr;
45171 }
45172
45173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45174         LDKu8slice ser_ref;
45175         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45176         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45177         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
45178         *ret_conv = ChannelFeatures_read(ser_ref);
45179         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45180         return tag_ptr(ret_conv, true);
45181 }
45182
45183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45184         LDKNodeFeatures obj_conv;
45185         obj_conv.inner = untag_ptr(obj);
45186         obj_conv.is_owned = ptr_is_owned(obj);
45187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45188         obj_conv.is_owned = false;
45189         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
45190         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45191         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45192         CVec_u8Z_free(ret_var);
45193         return ret_arr;
45194 }
45195
45196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45197         LDKu8slice ser_ref;
45198         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45199         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45200         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
45201         *ret_conv = NodeFeatures_read(ser_ref);
45202         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45203         return tag_ptr(ret_conv, true);
45204 }
45205
45206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45207         LDKInvoiceFeatures obj_conv;
45208         obj_conv.inner = untag_ptr(obj);
45209         obj_conv.is_owned = ptr_is_owned(obj);
45210         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45211         obj_conv.is_owned = false;
45212         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
45213         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45214         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45215         CVec_u8Z_free(ret_var);
45216         return ret_arr;
45217 }
45218
45219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45220         LDKu8slice ser_ref;
45221         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45222         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45223         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
45224         *ret_conv = InvoiceFeatures_read(ser_ref);
45225         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45226         return tag_ptr(ret_conv, true);
45227 }
45228
45229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45230         LDKBlindedHopFeatures obj_conv;
45231         obj_conv.inner = untag_ptr(obj);
45232         obj_conv.is_owned = ptr_is_owned(obj);
45233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45234         obj_conv.is_owned = false;
45235         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
45236         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45237         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45238         CVec_u8Z_free(ret_var);
45239         return ret_arr;
45240 }
45241
45242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45243         LDKu8slice ser_ref;
45244         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45245         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45246         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
45247         *ret_conv = BlindedHopFeatures_read(ser_ref);
45248         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45249         return tag_ptr(ret_conv, true);
45250 }
45251
45252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45253         LDKChannelTypeFeatures obj_conv;
45254         obj_conv.inner = untag_ptr(obj);
45255         obj_conv.is_owned = ptr_is_owned(obj);
45256         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45257         obj_conv.is_owned = false;
45258         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
45259         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45260         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45261         CVec_u8Z_free(ret_var);
45262         return ret_arr;
45263 }
45264
45265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45266         LDKu8slice ser_ref;
45267         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45268         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45269         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
45270         *ret_conv = ChannelTypeFeatures_read(ser_ref);
45271         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45272         return tag_ptr(ret_conv, true);
45273 }
45274
45275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45276         LDKInitFeatures this_arg_conv;
45277         this_arg_conv.inner = untag_ptr(this_arg);
45278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45280         this_arg_conv.is_owned = false;
45281         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
45282 }
45283
45284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45285         LDKInitFeatures this_arg_conv;
45286         this_arg_conv.inner = untag_ptr(this_arg);
45287         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45289         this_arg_conv.is_owned = false;
45290         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
45291 }
45292
45293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45294         LDKInitFeatures this_arg_conv;
45295         this_arg_conv.inner = untag_ptr(this_arg);
45296         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45298         this_arg_conv.is_owned = false;
45299         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
45300         return ret_conv;
45301 }
45302
45303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45304         LDKNodeFeatures this_arg_conv;
45305         this_arg_conv.inner = untag_ptr(this_arg);
45306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45308         this_arg_conv.is_owned = false;
45309         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
45310 }
45311
45312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45313         LDKNodeFeatures this_arg_conv;
45314         this_arg_conv.inner = untag_ptr(this_arg);
45315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45317         this_arg_conv.is_owned = false;
45318         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
45319 }
45320
45321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45322         LDKNodeFeatures this_arg_conv;
45323         this_arg_conv.inner = untag_ptr(this_arg);
45324         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45326         this_arg_conv.is_owned = false;
45327         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
45328         return ret_conv;
45329 }
45330
45331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45332         LDKInitFeatures this_arg_conv;
45333         this_arg_conv.inner = untag_ptr(this_arg);
45334         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45336         this_arg_conv.is_owned = false;
45337         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
45338         return ret_conv;
45339 }
45340
45341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45342         LDKNodeFeatures this_arg_conv;
45343         this_arg_conv.inner = untag_ptr(this_arg);
45344         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45346         this_arg_conv.is_owned = false;
45347         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
45348         return ret_conv;
45349 }
45350
45351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45352         LDKInitFeatures this_arg_conv;
45353         this_arg_conv.inner = untag_ptr(this_arg);
45354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45356         this_arg_conv.is_owned = false;
45357         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
45358 }
45359
45360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45361         LDKInitFeatures this_arg_conv;
45362         this_arg_conv.inner = untag_ptr(this_arg);
45363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45365         this_arg_conv.is_owned = false;
45366         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
45367 }
45368
45369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
45370         LDKInitFeatures this_arg_conv;
45371         this_arg_conv.inner = untag_ptr(this_arg);
45372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45374         this_arg_conv.is_owned = false;
45375         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
45376         return ret_conv;
45377 }
45378
45379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45380         LDKInitFeatures this_arg_conv;
45381         this_arg_conv.inner = untag_ptr(this_arg);
45382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45384         this_arg_conv.is_owned = false;
45385         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45386 }
45387
45388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45389         LDKInitFeatures this_arg_conv;
45390         this_arg_conv.inner = untag_ptr(this_arg);
45391         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45393         this_arg_conv.is_owned = false;
45394         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45395 }
45396
45397 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45398         LDKInitFeatures this_arg_conv;
45399         this_arg_conv.inner = untag_ptr(this_arg);
45400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45402         this_arg_conv.is_owned = false;
45403         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45404         return ret_conv;
45405 }
45406
45407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45408         LDKNodeFeatures this_arg_conv;
45409         this_arg_conv.inner = untag_ptr(this_arg);
45410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45412         this_arg_conv.is_owned = false;
45413         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45414 }
45415
45416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45417         LDKNodeFeatures this_arg_conv;
45418         this_arg_conv.inner = untag_ptr(this_arg);
45419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45421         this_arg_conv.is_owned = false;
45422         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45423 }
45424
45425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45426         LDKNodeFeatures this_arg_conv;
45427         this_arg_conv.inner = untag_ptr(this_arg);
45428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45430         this_arg_conv.is_owned = false;
45431         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45432         return ret_conv;
45433 }
45434
45435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45436         LDKInitFeatures this_arg_conv;
45437         this_arg_conv.inner = untag_ptr(this_arg);
45438         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45440         this_arg_conv.is_owned = false;
45441         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45442         return ret_conv;
45443 }
45444
45445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45446         LDKNodeFeatures this_arg_conv;
45447         this_arg_conv.inner = untag_ptr(this_arg);
45448         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45450         this_arg_conv.is_owned = false;
45451         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45452         return ret_conv;
45453 }
45454
45455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45456         LDKInitFeatures this_arg_conv;
45457         this_arg_conv.inner = untag_ptr(this_arg);
45458         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45460         this_arg_conv.is_owned = false;
45461         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
45462 }
45463
45464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45465         LDKInitFeatures this_arg_conv;
45466         this_arg_conv.inner = untag_ptr(this_arg);
45467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45469         this_arg_conv.is_owned = false;
45470         InitFeatures_set_gossip_queries_required(&this_arg_conv);
45471 }
45472
45473 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45474         LDKInitFeatures this_arg_conv;
45475         this_arg_conv.inner = untag_ptr(this_arg);
45476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45478         this_arg_conv.is_owned = false;
45479         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
45480         return ret_conv;
45481 }
45482
45483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45484         LDKNodeFeatures this_arg_conv;
45485         this_arg_conv.inner = untag_ptr(this_arg);
45486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45488         this_arg_conv.is_owned = false;
45489         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
45490 }
45491
45492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45493         LDKNodeFeatures this_arg_conv;
45494         this_arg_conv.inner = untag_ptr(this_arg);
45495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45497         this_arg_conv.is_owned = false;
45498         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
45499 }
45500
45501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45502         LDKNodeFeatures this_arg_conv;
45503         this_arg_conv.inner = untag_ptr(this_arg);
45504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45506         this_arg_conv.is_owned = false;
45507         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
45508         return ret_conv;
45509 }
45510
45511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45512         LDKInitFeatures this_arg_conv;
45513         this_arg_conv.inner = untag_ptr(this_arg);
45514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45516         this_arg_conv.is_owned = false;
45517         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
45518         return ret_conv;
45519 }
45520
45521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45522         LDKNodeFeatures this_arg_conv;
45523         this_arg_conv.inner = untag_ptr(this_arg);
45524         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45526         this_arg_conv.is_owned = false;
45527         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
45528         return ret_conv;
45529 }
45530
45531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45532         LDKInitFeatures this_arg_conv;
45533         this_arg_conv.inner = untag_ptr(this_arg);
45534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45536         this_arg_conv.is_owned = false;
45537         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
45538 }
45539
45540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45541         LDKInitFeatures this_arg_conv;
45542         this_arg_conv.inner = untag_ptr(this_arg);
45543         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45545         this_arg_conv.is_owned = false;
45546         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
45547 }
45548
45549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45550         LDKInitFeatures this_arg_conv;
45551         this_arg_conv.inner = untag_ptr(this_arg);
45552         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45554         this_arg_conv.is_owned = false;
45555         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
45556         return ret_conv;
45557 }
45558
45559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45560         LDKNodeFeatures this_arg_conv;
45561         this_arg_conv.inner = untag_ptr(this_arg);
45562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45564         this_arg_conv.is_owned = false;
45565         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
45566 }
45567
45568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45569         LDKNodeFeatures this_arg_conv;
45570         this_arg_conv.inner = untag_ptr(this_arg);
45571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45573         this_arg_conv.is_owned = false;
45574         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
45575 }
45576
45577 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45578         LDKNodeFeatures this_arg_conv;
45579         this_arg_conv.inner = untag_ptr(this_arg);
45580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45582         this_arg_conv.is_owned = false;
45583         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
45584         return ret_conv;
45585 }
45586
45587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45588         LDKInvoiceFeatures this_arg_conv;
45589         this_arg_conv.inner = untag_ptr(this_arg);
45590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45592         this_arg_conv.is_owned = false;
45593         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
45594 }
45595
45596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45597         LDKInvoiceFeatures this_arg_conv;
45598         this_arg_conv.inner = untag_ptr(this_arg);
45599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45601         this_arg_conv.is_owned = false;
45602         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
45603 }
45604
45605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45606         LDKInvoiceFeatures this_arg_conv;
45607         this_arg_conv.inner = untag_ptr(this_arg);
45608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45610         this_arg_conv.is_owned = false;
45611         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
45612         return ret_conv;
45613 }
45614
45615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45616         LDKInitFeatures this_arg_conv;
45617         this_arg_conv.inner = untag_ptr(this_arg);
45618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45620         this_arg_conv.is_owned = false;
45621         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
45622         return ret_conv;
45623 }
45624
45625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45626         LDKNodeFeatures this_arg_conv;
45627         this_arg_conv.inner = untag_ptr(this_arg);
45628         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45630         this_arg_conv.is_owned = false;
45631         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
45632         return ret_conv;
45633 }
45634
45635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45636         LDKInvoiceFeatures this_arg_conv;
45637         this_arg_conv.inner = untag_ptr(this_arg);
45638         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45640         this_arg_conv.is_owned = false;
45641         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
45642         return ret_conv;
45643 }
45644
45645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45646         LDKInitFeatures this_arg_conv;
45647         this_arg_conv.inner = untag_ptr(this_arg);
45648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45650         this_arg_conv.is_owned = false;
45651         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
45652 }
45653
45654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45655         LDKInitFeatures this_arg_conv;
45656         this_arg_conv.inner = untag_ptr(this_arg);
45657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45659         this_arg_conv.is_owned = false;
45660         InitFeatures_set_static_remote_key_required(&this_arg_conv);
45661 }
45662
45663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45664         LDKInitFeatures this_arg_conv;
45665         this_arg_conv.inner = untag_ptr(this_arg);
45666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45668         this_arg_conv.is_owned = false;
45669         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
45670         return ret_conv;
45671 }
45672
45673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45674         LDKNodeFeatures this_arg_conv;
45675         this_arg_conv.inner = untag_ptr(this_arg);
45676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45678         this_arg_conv.is_owned = false;
45679         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
45680 }
45681
45682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45683         LDKNodeFeatures this_arg_conv;
45684         this_arg_conv.inner = untag_ptr(this_arg);
45685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45687         this_arg_conv.is_owned = false;
45688         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
45689 }
45690
45691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45692         LDKNodeFeatures this_arg_conv;
45693         this_arg_conv.inner = untag_ptr(this_arg);
45694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45696         this_arg_conv.is_owned = false;
45697         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
45698         return ret_conv;
45699 }
45700
45701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45702         LDKChannelTypeFeatures this_arg_conv;
45703         this_arg_conv.inner = untag_ptr(this_arg);
45704         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45706         this_arg_conv.is_owned = false;
45707         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
45708 }
45709
45710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45711         LDKChannelTypeFeatures this_arg_conv;
45712         this_arg_conv.inner = untag_ptr(this_arg);
45713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45715         this_arg_conv.is_owned = false;
45716         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
45717 }
45718
45719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45720         LDKChannelTypeFeatures this_arg_conv;
45721         this_arg_conv.inner = untag_ptr(this_arg);
45722         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45724         this_arg_conv.is_owned = false;
45725         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
45726         return ret_conv;
45727 }
45728
45729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45730         LDKInitFeatures this_arg_conv;
45731         this_arg_conv.inner = untag_ptr(this_arg);
45732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45734         this_arg_conv.is_owned = false;
45735         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
45736         return ret_conv;
45737 }
45738
45739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45740         LDKNodeFeatures this_arg_conv;
45741         this_arg_conv.inner = untag_ptr(this_arg);
45742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45744         this_arg_conv.is_owned = false;
45745         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
45746         return ret_conv;
45747 }
45748
45749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45750         LDKChannelTypeFeatures this_arg_conv;
45751         this_arg_conv.inner = untag_ptr(this_arg);
45752         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45754         this_arg_conv.is_owned = false;
45755         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
45756         return ret_conv;
45757 }
45758
45759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45760         LDKInitFeatures this_arg_conv;
45761         this_arg_conv.inner = untag_ptr(this_arg);
45762         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45764         this_arg_conv.is_owned = false;
45765         InitFeatures_set_payment_secret_optional(&this_arg_conv);
45766 }
45767
45768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45769         LDKInitFeatures this_arg_conv;
45770         this_arg_conv.inner = untag_ptr(this_arg);
45771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45773         this_arg_conv.is_owned = false;
45774         InitFeatures_set_payment_secret_required(&this_arg_conv);
45775 }
45776
45777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45778         LDKInitFeatures this_arg_conv;
45779         this_arg_conv.inner = untag_ptr(this_arg);
45780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45782         this_arg_conv.is_owned = false;
45783         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
45784         return ret_conv;
45785 }
45786
45787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45788         LDKNodeFeatures this_arg_conv;
45789         this_arg_conv.inner = untag_ptr(this_arg);
45790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45792         this_arg_conv.is_owned = false;
45793         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
45794 }
45795
45796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45797         LDKNodeFeatures this_arg_conv;
45798         this_arg_conv.inner = untag_ptr(this_arg);
45799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45801         this_arg_conv.is_owned = false;
45802         NodeFeatures_set_payment_secret_required(&this_arg_conv);
45803 }
45804
45805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45806         LDKNodeFeatures this_arg_conv;
45807         this_arg_conv.inner = untag_ptr(this_arg);
45808         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45810         this_arg_conv.is_owned = false;
45811         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
45812         return ret_conv;
45813 }
45814
45815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45816         LDKInvoiceFeatures this_arg_conv;
45817         this_arg_conv.inner = untag_ptr(this_arg);
45818         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45820         this_arg_conv.is_owned = false;
45821         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
45822 }
45823
45824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45825         LDKInvoiceFeatures this_arg_conv;
45826         this_arg_conv.inner = untag_ptr(this_arg);
45827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45829         this_arg_conv.is_owned = false;
45830         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
45831 }
45832
45833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45834         LDKInvoiceFeatures this_arg_conv;
45835         this_arg_conv.inner = untag_ptr(this_arg);
45836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45838         this_arg_conv.is_owned = false;
45839         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
45840         return ret_conv;
45841 }
45842
45843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45844         LDKInitFeatures this_arg_conv;
45845         this_arg_conv.inner = untag_ptr(this_arg);
45846         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45848         this_arg_conv.is_owned = false;
45849         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
45850         return ret_conv;
45851 }
45852
45853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45854         LDKNodeFeatures this_arg_conv;
45855         this_arg_conv.inner = untag_ptr(this_arg);
45856         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45858         this_arg_conv.is_owned = false;
45859         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
45860         return ret_conv;
45861 }
45862
45863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45864         LDKInvoiceFeatures this_arg_conv;
45865         this_arg_conv.inner = untag_ptr(this_arg);
45866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45868         this_arg_conv.is_owned = false;
45869         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
45870         return ret_conv;
45871 }
45872
45873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45874         LDKInitFeatures this_arg_conv;
45875         this_arg_conv.inner = untag_ptr(this_arg);
45876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45878         this_arg_conv.is_owned = false;
45879         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
45880 }
45881
45882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45883         LDKInitFeatures this_arg_conv;
45884         this_arg_conv.inner = untag_ptr(this_arg);
45885         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45887         this_arg_conv.is_owned = false;
45888         InitFeatures_set_basic_mpp_required(&this_arg_conv);
45889 }
45890
45891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45892         LDKInitFeatures this_arg_conv;
45893         this_arg_conv.inner = untag_ptr(this_arg);
45894         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45896         this_arg_conv.is_owned = false;
45897         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
45898         return ret_conv;
45899 }
45900
45901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45902         LDKNodeFeatures this_arg_conv;
45903         this_arg_conv.inner = untag_ptr(this_arg);
45904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45906         this_arg_conv.is_owned = false;
45907         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
45908 }
45909
45910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45911         LDKNodeFeatures this_arg_conv;
45912         this_arg_conv.inner = untag_ptr(this_arg);
45913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45915         this_arg_conv.is_owned = false;
45916         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
45917 }
45918
45919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45920         LDKNodeFeatures this_arg_conv;
45921         this_arg_conv.inner = untag_ptr(this_arg);
45922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45924         this_arg_conv.is_owned = false;
45925         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
45926         return ret_conv;
45927 }
45928
45929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45930         LDKInvoiceFeatures this_arg_conv;
45931         this_arg_conv.inner = untag_ptr(this_arg);
45932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45934         this_arg_conv.is_owned = false;
45935         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45936 }
45937
45938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45939         LDKInvoiceFeatures this_arg_conv;
45940         this_arg_conv.inner = untag_ptr(this_arg);
45941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45943         this_arg_conv.is_owned = false;
45944         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45945 }
45946
45947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45948         LDKInvoiceFeatures this_arg_conv;
45949         this_arg_conv.inner = untag_ptr(this_arg);
45950         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45952         this_arg_conv.is_owned = false;
45953         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45954         return ret_conv;
45955 }
45956
45957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45958         LDKBolt12InvoiceFeatures this_arg_conv;
45959         this_arg_conv.inner = untag_ptr(this_arg);
45960         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45962         this_arg_conv.is_owned = false;
45963         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45964 }
45965
45966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45967         LDKBolt12InvoiceFeatures this_arg_conv;
45968         this_arg_conv.inner = untag_ptr(this_arg);
45969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45971         this_arg_conv.is_owned = false;
45972         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45973 }
45974
45975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45976         LDKBolt12InvoiceFeatures this_arg_conv;
45977         this_arg_conv.inner = untag_ptr(this_arg);
45978         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45980         this_arg_conv.is_owned = false;
45981         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45982         return ret_conv;
45983 }
45984
45985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45986         LDKInitFeatures this_arg_conv;
45987         this_arg_conv.inner = untag_ptr(this_arg);
45988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45990         this_arg_conv.is_owned = false;
45991         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
45992         return ret_conv;
45993 }
45994
45995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45996         LDKNodeFeatures this_arg_conv;
45997         this_arg_conv.inner = untag_ptr(this_arg);
45998         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46000         this_arg_conv.is_owned = false;
46001         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
46002         return ret_conv;
46003 }
46004
46005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
46006         LDKInvoiceFeatures this_arg_conv;
46007         this_arg_conv.inner = untag_ptr(this_arg);
46008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46010         this_arg_conv.is_owned = false;
46011         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46012         return ret_conv;
46013 }
46014
46015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
46016         LDKBolt12InvoiceFeatures this_arg_conv;
46017         this_arg_conv.inner = untag_ptr(this_arg);
46018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46020         this_arg_conv.is_owned = false;
46021         jboolean ret_conv = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46022         return ret_conv;
46023 }
46024
46025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46026         LDKInitFeatures this_arg_conv;
46027         this_arg_conv.inner = untag_ptr(this_arg);
46028         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46030         this_arg_conv.is_owned = false;
46031         InitFeatures_set_wumbo_optional(&this_arg_conv);
46032 }
46033
46034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46035         LDKInitFeatures this_arg_conv;
46036         this_arg_conv.inner = untag_ptr(this_arg);
46037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46039         this_arg_conv.is_owned = false;
46040         InitFeatures_set_wumbo_required(&this_arg_conv);
46041 }
46042
46043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46044         LDKInitFeatures this_arg_conv;
46045         this_arg_conv.inner = untag_ptr(this_arg);
46046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46048         this_arg_conv.is_owned = false;
46049         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
46050         return ret_conv;
46051 }
46052
46053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46054         LDKNodeFeatures this_arg_conv;
46055         this_arg_conv.inner = untag_ptr(this_arg);
46056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46058         this_arg_conv.is_owned = false;
46059         NodeFeatures_set_wumbo_optional(&this_arg_conv);
46060 }
46061
46062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46063         LDKNodeFeatures this_arg_conv;
46064         this_arg_conv.inner = untag_ptr(this_arg);
46065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46067         this_arg_conv.is_owned = false;
46068         NodeFeatures_set_wumbo_required(&this_arg_conv);
46069 }
46070
46071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46072         LDKNodeFeatures this_arg_conv;
46073         this_arg_conv.inner = untag_ptr(this_arg);
46074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46076         this_arg_conv.is_owned = false;
46077         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
46078         return ret_conv;
46079 }
46080
46081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46082         LDKInitFeatures this_arg_conv;
46083         this_arg_conv.inner = untag_ptr(this_arg);
46084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46086         this_arg_conv.is_owned = false;
46087         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
46088         return ret_conv;
46089 }
46090
46091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46092         LDKNodeFeatures this_arg_conv;
46093         this_arg_conv.inner = untag_ptr(this_arg);
46094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46096         this_arg_conv.is_owned = false;
46097         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
46098         return ret_conv;
46099 }
46100
46101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46102         LDKInitFeatures this_arg_conv;
46103         this_arg_conv.inner = untag_ptr(this_arg);
46104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46106         this_arg_conv.is_owned = false;
46107         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46108 }
46109
46110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46111         LDKInitFeatures this_arg_conv;
46112         this_arg_conv.inner = untag_ptr(this_arg);
46113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46115         this_arg_conv.is_owned = false;
46116         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46117 }
46118
46119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46120         LDKInitFeatures this_arg_conv;
46121         this_arg_conv.inner = untag_ptr(this_arg);
46122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46124         this_arg_conv.is_owned = false;
46125         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46126         return ret_conv;
46127 }
46128
46129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46130         LDKNodeFeatures this_arg_conv;
46131         this_arg_conv.inner = untag_ptr(this_arg);
46132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46134         this_arg_conv.is_owned = false;
46135         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46136 }
46137
46138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46139         LDKNodeFeatures this_arg_conv;
46140         this_arg_conv.inner = untag_ptr(this_arg);
46141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46143         this_arg_conv.is_owned = false;
46144         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46145 }
46146
46147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46148         LDKNodeFeatures this_arg_conv;
46149         this_arg_conv.inner = untag_ptr(this_arg);
46150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46152         this_arg_conv.is_owned = false;
46153         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46154         return ret_conv;
46155 }
46156
46157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46158         LDKChannelTypeFeatures this_arg_conv;
46159         this_arg_conv.inner = untag_ptr(this_arg);
46160         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46162         this_arg_conv.is_owned = false;
46163         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46164 }
46165
46166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46167         LDKChannelTypeFeatures this_arg_conv;
46168         this_arg_conv.inner = untag_ptr(this_arg);
46169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46171         this_arg_conv.is_owned = false;
46172         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46173 }
46174
46175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46176         LDKChannelTypeFeatures this_arg_conv;
46177         this_arg_conv.inner = untag_ptr(this_arg);
46178         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46180         this_arg_conv.is_owned = false;
46181         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46182         return ret_conv;
46183 }
46184
46185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46186         LDKInitFeatures this_arg_conv;
46187         this_arg_conv.inner = untag_ptr(this_arg);
46188         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46190         this_arg_conv.is_owned = false;
46191         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46192         return ret_conv;
46193 }
46194
46195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46196         LDKNodeFeatures this_arg_conv;
46197         this_arg_conv.inner = untag_ptr(this_arg);
46198         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46200         this_arg_conv.is_owned = false;
46201         jboolean ret_conv = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46202         return ret_conv;
46203 }
46204
46205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46206         LDKChannelTypeFeatures this_arg_conv;
46207         this_arg_conv.inner = untag_ptr(this_arg);
46208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46210         this_arg_conv.is_owned = false;
46211         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46212         return ret_conv;
46213 }
46214
46215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46216         LDKInitFeatures this_arg_conv;
46217         this_arg_conv.inner = untag_ptr(this_arg);
46218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46220         this_arg_conv.is_owned = false;
46221         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46222 }
46223
46224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46225         LDKInitFeatures this_arg_conv;
46226         this_arg_conv.inner = untag_ptr(this_arg);
46227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46229         this_arg_conv.is_owned = false;
46230         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46231 }
46232
46233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46234         LDKInitFeatures this_arg_conv;
46235         this_arg_conv.inner = untag_ptr(this_arg);
46236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46238         this_arg_conv.is_owned = false;
46239         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46240         return ret_conv;
46241 }
46242
46243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46244         LDKNodeFeatures this_arg_conv;
46245         this_arg_conv.inner = untag_ptr(this_arg);
46246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46248         this_arg_conv.is_owned = false;
46249         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46250 }
46251
46252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46253         LDKNodeFeatures this_arg_conv;
46254         this_arg_conv.inner = untag_ptr(this_arg);
46255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46257         this_arg_conv.is_owned = false;
46258         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46259 }
46260
46261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46262         LDKNodeFeatures this_arg_conv;
46263         this_arg_conv.inner = untag_ptr(this_arg);
46264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46266         this_arg_conv.is_owned = false;
46267         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46268         return ret_conv;
46269 }
46270
46271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46272         LDKInitFeatures this_arg_conv;
46273         this_arg_conv.inner = untag_ptr(this_arg);
46274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46276         this_arg_conv.is_owned = false;
46277         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46278         return ret_conv;
46279 }
46280
46281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46282         LDKNodeFeatures this_arg_conv;
46283         this_arg_conv.inner = untag_ptr(this_arg);
46284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46286         this_arg_conv.is_owned = false;
46287         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46288         return ret_conv;
46289 }
46290
46291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46292         LDKInitFeatures this_arg_conv;
46293         this_arg_conv.inner = untag_ptr(this_arg);
46294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46296         this_arg_conv.is_owned = false;
46297         InitFeatures_set_onion_messages_optional(&this_arg_conv);
46298 }
46299
46300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46301         LDKInitFeatures this_arg_conv;
46302         this_arg_conv.inner = untag_ptr(this_arg);
46303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46305         this_arg_conv.is_owned = false;
46306         InitFeatures_set_onion_messages_required(&this_arg_conv);
46307 }
46308
46309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46310         LDKInitFeatures this_arg_conv;
46311         this_arg_conv.inner = untag_ptr(this_arg);
46312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46314         this_arg_conv.is_owned = false;
46315         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
46316         return ret_conv;
46317 }
46318
46319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46320         LDKNodeFeatures this_arg_conv;
46321         this_arg_conv.inner = untag_ptr(this_arg);
46322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46324         this_arg_conv.is_owned = false;
46325         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
46326 }
46327
46328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46329         LDKNodeFeatures this_arg_conv;
46330         this_arg_conv.inner = untag_ptr(this_arg);
46331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46333         this_arg_conv.is_owned = false;
46334         NodeFeatures_set_onion_messages_required(&this_arg_conv);
46335 }
46336
46337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46338         LDKNodeFeatures this_arg_conv;
46339         this_arg_conv.inner = untag_ptr(this_arg);
46340         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46342         this_arg_conv.is_owned = false;
46343         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
46344         return ret_conv;
46345 }
46346
46347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46348         LDKInitFeatures this_arg_conv;
46349         this_arg_conv.inner = untag_ptr(this_arg);
46350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46352         this_arg_conv.is_owned = false;
46353         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
46354         return ret_conv;
46355 }
46356
46357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46358         LDKNodeFeatures this_arg_conv;
46359         this_arg_conv.inner = untag_ptr(this_arg);
46360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46362         this_arg_conv.is_owned = false;
46363         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
46364         return ret_conv;
46365 }
46366
46367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46368         LDKInitFeatures this_arg_conv;
46369         this_arg_conv.inner = untag_ptr(this_arg);
46370         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46372         this_arg_conv.is_owned = false;
46373         InitFeatures_set_channel_type_optional(&this_arg_conv);
46374 }
46375
46376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46377         LDKInitFeatures this_arg_conv;
46378         this_arg_conv.inner = untag_ptr(this_arg);
46379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46381         this_arg_conv.is_owned = false;
46382         InitFeatures_set_channel_type_required(&this_arg_conv);
46383 }
46384
46385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46386         LDKInitFeatures this_arg_conv;
46387         this_arg_conv.inner = untag_ptr(this_arg);
46388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46390         this_arg_conv.is_owned = false;
46391         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
46392         return ret_conv;
46393 }
46394
46395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46396         LDKNodeFeatures this_arg_conv;
46397         this_arg_conv.inner = untag_ptr(this_arg);
46398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46400         this_arg_conv.is_owned = false;
46401         NodeFeatures_set_channel_type_optional(&this_arg_conv);
46402 }
46403
46404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46405         LDKNodeFeatures this_arg_conv;
46406         this_arg_conv.inner = untag_ptr(this_arg);
46407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46409         this_arg_conv.is_owned = false;
46410         NodeFeatures_set_channel_type_required(&this_arg_conv);
46411 }
46412
46413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46414         LDKNodeFeatures this_arg_conv;
46415         this_arg_conv.inner = untag_ptr(this_arg);
46416         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46418         this_arg_conv.is_owned = false;
46419         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
46420         return ret_conv;
46421 }
46422
46423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46424         LDKInitFeatures this_arg_conv;
46425         this_arg_conv.inner = untag_ptr(this_arg);
46426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46428         this_arg_conv.is_owned = false;
46429         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
46430         return ret_conv;
46431 }
46432
46433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46434         LDKNodeFeatures this_arg_conv;
46435         this_arg_conv.inner = untag_ptr(this_arg);
46436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46438         this_arg_conv.is_owned = false;
46439         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
46440         return ret_conv;
46441 }
46442
46443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46444         LDKInitFeatures this_arg_conv;
46445         this_arg_conv.inner = untag_ptr(this_arg);
46446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46448         this_arg_conv.is_owned = false;
46449         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
46450 }
46451
46452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46453         LDKInitFeatures this_arg_conv;
46454         this_arg_conv.inner = untag_ptr(this_arg);
46455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46457         this_arg_conv.is_owned = false;
46458         InitFeatures_set_scid_privacy_required(&this_arg_conv);
46459 }
46460
46461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46462         LDKInitFeatures this_arg_conv;
46463         this_arg_conv.inner = untag_ptr(this_arg);
46464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46466         this_arg_conv.is_owned = false;
46467         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
46468         return ret_conv;
46469 }
46470
46471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46472         LDKNodeFeatures this_arg_conv;
46473         this_arg_conv.inner = untag_ptr(this_arg);
46474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46476         this_arg_conv.is_owned = false;
46477         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
46478 }
46479
46480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46481         LDKNodeFeatures this_arg_conv;
46482         this_arg_conv.inner = untag_ptr(this_arg);
46483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46485         this_arg_conv.is_owned = false;
46486         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
46487 }
46488
46489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46490         LDKNodeFeatures this_arg_conv;
46491         this_arg_conv.inner = untag_ptr(this_arg);
46492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46494         this_arg_conv.is_owned = false;
46495         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
46496         return ret_conv;
46497 }
46498
46499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46500         LDKChannelTypeFeatures this_arg_conv;
46501         this_arg_conv.inner = untag_ptr(this_arg);
46502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46504         this_arg_conv.is_owned = false;
46505         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
46506 }
46507
46508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46509         LDKChannelTypeFeatures this_arg_conv;
46510         this_arg_conv.inner = untag_ptr(this_arg);
46511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46513         this_arg_conv.is_owned = false;
46514         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
46515 }
46516
46517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46518         LDKChannelTypeFeatures this_arg_conv;
46519         this_arg_conv.inner = untag_ptr(this_arg);
46520         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46522         this_arg_conv.is_owned = false;
46523         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
46524         return ret_conv;
46525 }
46526
46527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46528         LDKInitFeatures this_arg_conv;
46529         this_arg_conv.inner = untag_ptr(this_arg);
46530         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46532         this_arg_conv.is_owned = false;
46533         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
46534         return ret_conv;
46535 }
46536
46537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46538         LDKNodeFeatures this_arg_conv;
46539         this_arg_conv.inner = untag_ptr(this_arg);
46540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46542         this_arg_conv.is_owned = false;
46543         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
46544         return ret_conv;
46545 }
46546
46547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46548         LDKChannelTypeFeatures this_arg_conv;
46549         this_arg_conv.inner = untag_ptr(this_arg);
46550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46552         this_arg_conv.is_owned = false;
46553         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
46554         return ret_conv;
46555 }
46556
46557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46558         LDKInvoiceFeatures this_arg_conv;
46559         this_arg_conv.inner = untag_ptr(this_arg);
46560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46562         this_arg_conv.is_owned = false;
46563         InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
46564 }
46565
46566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46567         LDKInvoiceFeatures this_arg_conv;
46568         this_arg_conv.inner = untag_ptr(this_arg);
46569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46571         this_arg_conv.is_owned = false;
46572         InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
46573 }
46574
46575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46576         LDKInvoiceFeatures this_arg_conv;
46577         this_arg_conv.inner = untag_ptr(this_arg);
46578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46580         this_arg_conv.is_owned = false;
46581         jboolean ret_conv = InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
46582         return ret_conv;
46583 }
46584
46585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46586         LDKInvoiceFeatures this_arg_conv;
46587         this_arg_conv.inner = untag_ptr(this_arg);
46588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46590         this_arg_conv.is_owned = false;
46591         jboolean ret_conv = InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
46592         return ret_conv;
46593 }
46594
46595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46596         LDKInitFeatures this_arg_conv;
46597         this_arg_conv.inner = untag_ptr(this_arg);
46598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46600         this_arg_conv.is_owned = false;
46601         InitFeatures_set_zero_conf_optional(&this_arg_conv);
46602 }
46603
46604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46605         LDKInitFeatures this_arg_conv;
46606         this_arg_conv.inner = untag_ptr(this_arg);
46607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46609         this_arg_conv.is_owned = false;
46610         InitFeatures_set_zero_conf_required(&this_arg_conv);
46611 }
46612
46613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46614         LDKInitFeatures this_arg_conv;
46615         this_arg_conv.inner = untag_ptr(this_arg);
46616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46618         this_arg_conv.is_owned = false;
46619         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
46620         return ret_conv;
46621 }
46622
46623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46624         LDKNodeFeatures this_arg_conv;
46625         this_arg_conv.inner = untag_ptr(this_arg);
46626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46628         this_arg_conv.is_owned = false;
46629         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
46630 }
46631
46632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46633         LDKNodeFeatures this_arg_conv;
46634         this_arg_conv.inner = untag_ptr(this_arg);
46635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46637         this_arg_conv.is_owned = false;
46638         NodeFeatures_set_zero_conf_required(&this_arg_conv);
46639 }
46640
46641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46642         LDKNodeFeatures this_arg_conv;
46643         this_arg_conv.inner = untag_ptr(this_arg);
46644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46646         this_arg_conv.is_owned = false;
46647         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
46648         return ret_conv;
46649 }
46650
46651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46652         LDKChannelTypeFeatures this_arg_conv;
46653         this_arg_conv.inner = untag_ptr(this_arg);
46654         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46656         this_arg_conv.is_owned = false;
46657         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
46658 }
46659
46660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46661         LDKChannelTypeFeatures this_arg_conv;
46662         this_arg_conv.inner = untag_ptr(this_arg);
46663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46665         this_arg_conv.is_owned = false;
46666         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
46667 }
46668
46669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46670         LDKChannelTypeFeatures this_arg_conv;
46671         this_arg_conv.inner = untag_ptr(this_arg);
46672         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46674         this_arg_conv.is_owned = false;
46675         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
46676         return ret_conv;
46677 }
46678
46679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46680         LDKInitFeatures this_arg_conv;
46681         this_arg_conv.inner = untag_ptr(this_arg);
46682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46684         this_arg_conv.is_owned = false;
46685         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
46686         return ret_conv;
46687 }
46688
46689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46690         LDKNodeFeatures this_arg_conv;
46691         this_arg_conv.inner = untag_ptr(this_arg);
46692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46694         this_arg_conv.is_owned = false;
46695         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
46696         return ret_conv;
46697 }
46698
46699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46700         LDKChannelTypeFeatures this_arg_conv;
46701         this_arg_conv.inner = untag_ptr(this_arg);
46702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46704         this_arg_conv.is_owned = false;
46705         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
46706         return ret_conv;
46707 }
46708
46709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46710         LDKNodeFeatures this_arg_conv;
46711         this_arg_conv.inner = untag_ptr(this_arg);
46712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46714         this_arg_conv.is_owned = false;
46715         NodeFeatures_set_keysend_optional(&this_arg_conv);
46716 }
46717
46718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46719         LDKNodeFeatures this_arg_conv;
46720         this_arg_conv.inner = untag_ptr(this_arg);
46721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46723         this_arg_conv.is_owned = false;
46724         NodeFeatures_set_keysend_required(&this_arg_conv);
46725 }
46726
46727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46728         LDKNodeFeatures this_arg_conv;
46729         this_arg_conv.inner = untag_ptr(this_arg);
46730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46732         this_arg_conv.is_owned = false;
46733         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
46734         return ret_conv;
46735 }
46736
46737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46738         LDKNodeFeatures this_arg_conv;
46739         this_arg_conv.inner = untag_ptr(this_arg);
46740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46742         this_arg_conv.is_owned = false;
46743         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
46744         return ret_conv;
46745 }
46746
46747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46748         LDKShutdownScript this_obj_conv;
46749         this_obj_conv.inner = untag_ptr(this_obj);
46750         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46752         ShutdownScript_free(this_obj_conv);
46753 }
46754
46755 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
46756         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
46757         int64_t ret_ref = 0;
46758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46760         return ret_ref;
46761 }
46762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46763         LDKShutdownScript arg_conv;
46764         arg_conv.inner = untag_ptr(arg);
46765         arg_conv.is_owned = ptr_is_owned(arg);
46766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46767         arg_conv.is_owned = false;
46768         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
46769         return ret_conv;
46770 }
46771
46772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46773         LDKShutdownScript orig_conv;
46774         orig_conv.inner = untag_ptr(orig);
46775         orig_conv.is_owned = ptr_is_owned(orig);
46776         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46777         orig_conv.is_owned = false;
46778         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
46779         int64_t ret_ref = 0;
46780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46782         return ret_ref;
46783 }
46784
46785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46786         LDKShutdownScript a_conv;
46787         a_conv.inner = untag_ptr(a);
46788         a_conv.is_owned = ptr_is_owned(a);
46789         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46790         a_conv.is_owned = false;
46791         LDKShutdownScript b_conv;
46792         b_conv.inner = untag_ptr(b);
46793         b_conv.is_owned = ptr_is_owned(b);
46794         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46795         b_conv.is_owned = false;
46796         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
46797         return ret_conv;
46798 }
46799
46800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46801         LDKInvalidShutdownScript this_obj_conv;
46802         this_obj_conv.inner = untag_ptr(this_obj);
46803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46805         InvalidShutdownScript_free(this_obj_conv);
46806 }
46807
46808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
46809         LDKInvalidShutdownScript this_ptr_conv;
46810         this_ptr_conv.inner = untag_ptr(this_ptr);
46811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46813         this_ptr_conv.is_owned = false;
46814         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
46815         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46816         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46817         return ret_arr;
46818 }
46819
46820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46821         LDKInvalidShutdownScript this_ptr_conv;
46822         this_ptr_conv.inner = untag_ptr(this_ptr);
46823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46825         this_ptr_conv.is_owned = false;
46826         LDKCVec_u8Z val_ref;
46827         val_ref.datalen = (*env)->GetArrayLength(env, val);
46828         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
46829         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
46830         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
46831 }
46832
46833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
46834         LDKCVec_u8Z script_arg_ref;
46835         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
46836         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
46837         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
46838         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
46839         int64_t ret_ref = 0;
46840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46842         return ret_ref;
46843 }
46844
46845 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
46846         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
46847         int64_t ret_ref = 0;
46848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46850         return ret_ref;
46851 }
46852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46853         LDKInvalidShutdownScript arg_conv;
46854         arg_conv.inner = untag_ptr(arg);
46855         arg_conv.is_owned = ptr_is_owned(arg);
46856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46857         arg_conv.is_owned = false;
46858         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
46859         return ret_conv;
46860 }
46861
46862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46863         LDKInvalidShutdownScript orig_conv;
46864         orig_conv.inner = untag_ptr(orig);
46865         orig_conv.is_owned = ptr_is_owned(orig);
46866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46867         orig_conv.is_owned = false;
46868         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
46869         int64_t ret_ref = 0;
46870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46872         return ret_ref;
46873 }
46874
46875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
46876         LDKShutdownScript obj_conv;
46877         obj_conv.inner = untag_ptr(obj);
46878         obj_conv.is_owned = ptr_is_owned(obj);
46879         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46880         obj_conv.is_owned = false;
46881         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
46882         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46883         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46884         CVec_u8Z_free(ret_var);
46885         return ret_arr;
46886 }
46887
46888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46889         LDKu8slice ser_ref;
46890         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46891         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46892         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
46893         *ret_conv = ShutdownScript_read(ser_ref);
46894         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46895         return tag_ptr(ret_conv, true);
46896 }
46897
46898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
46899         uint8_t pubkey_hash_arr[20];
46900         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
46901         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
46902         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
46903         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
46904         int64_t ret_ref = 0;
46905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46907         return ret_ref;
46908 }
46909
46910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
46911         uint8_t script_hash_arr[32];
46912         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
46913         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
46914         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
46915         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
46916         int64_t ret_ref = 0;
46917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46918         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46919         return ret_ref;
46920 }
46921
46922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46923         
46924         LDKu8slice program_ref;
46925         program_ref.datalen = (*env)->GetArrayLength(env, program);
46926         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
46927         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
46928         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
46929         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
46930         return tag_ptr(ret_conv, true);
46931 }
46932
46933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
46934         LDKShutdownScript this_arg_conv;
46935         this_arg_conv.inner = untag_ptr(this_arg);
46936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46938         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
46939         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
46940         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46941         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46942         CVec_u8Z_free(ret_var);
46943         return ret_arr;
46944 }
46945
46946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
46947         LDKShutdownScript this_arg_conv;
46948         this_arg_conv.inner = untag_ptr(this_arg);
46949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46951         this_arg_conv.is_owned = false;
46952         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
46954         return ret_arr;
46955 }
46956
46957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
46958         LDKShutdownScript this_arg_conv;
46959         this_arg_conv.inner = untag_ptr(this_arg);
46960         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46962         this_arg_conv.is_owned = false;
46963         LDKInitFeatures features_conv;
46964         features_conv.inner = untag_ptr(features);
46965         features_conv.is_owned = ptr_is_owned(features);
46966         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46967         features_conv.is_owned = false;
46968         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
46969         return ret_conv;
46970 }
46971
46972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46973         if (!ptr_is_owned(this_ptr)) return;
46974         void* this_ptr_ptr = untag_ptr(this_ptr);
46975         CHECK_ACCESS(this_ptr_ptr);
46976         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
46977         FREE(untag_ptr(this_ptr));
46978         Retry_free(this_ptr_conv);
46979 }
46980
46981 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
46982         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46983         *ret_copy = Retry_clone(arg);
46984         int64_t ret_ref = tag_ptr(ret_copy, true);
46985         return ret_ref;
46986 }
46987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46988         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
46989         int64_t ret_conv = Retry_clone_ptr(arg_conv);
46990         return ret_conv;
46991 }
46992
46993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46994         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
46995         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46996         *ret_copy = Retry_clone(orig_conv);
46997         int64_t ret_ref = tag_ptr(ret_copy, true);
46998         return ret_ref;
46999 }
47000
47001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
47002         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47003         *ret_copy = Retry_attempts(a);
47004         int64_t ret_ref = tag_ptr(ret_copy, true);
47005         return ret_ref;
47006 }
47007
47008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
47009         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47010         *ret_copy = Retry_timeout(a);
47011         int64_t ret_ref = tag_ptr(ret_copy, true);
47012         return ret_ref;
47013 }
47014
47015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47016         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
47017         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
47018         jboolean ret_conv = Retry_eq(a_conv, b_conv);
47019         return ret_conv;
47020 }
47021
47022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47023         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
47024         int64_t ret_conv = Retry_hash(o_conv);
47025         return ret_conv;
47026 }
47027
47028 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47029         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
47030         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_clone(orig_conv));
47031         return ret_conv;
47032 }
47033
47034 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1payment_1expired(JNIEnv *env, jclass clz) {
47035         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_payment_expired());
47036         return ret_conv;
47037 }
47038
47039 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1route_1not_1found(JNIEnv *env, jclass clz) {
47040         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_route_not_found());
47041         return ret_conv;
47042 }
47043
47044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47045         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_duplicate_payment());
47046         return ret_conv;
47047 }
47048
47049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47050         if (!ptr_is_owned(this_ptr)) return;
47051         void* this_ptr_ptr = untag_ptr(this_ptr);
47052         CHECK_ACCESS(this_ptr_ptr);
47053         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
47054         FREE(untag_ptr(this_ptr));
47055         PaymentSendFailure_free(this_ptr_conv);
47056 }
47057
47058 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
47059         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47060         *ret_copy = PaymentSendFailure_clone(arg);
47061         int64_t ret_ref = tag_ptr(ret_copy, true);
47062         return ret_ref;
47063 }
47064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47065         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
47066         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
47067         return ret_conv;
47068 }
47069
47070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47071         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
47072         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47073         *ret_copy = PaymentSendFailure_clone(orig_conv);
47074         int64_t ret_ref = tag_ptr(ret_copy, true);
47075         return ret_ref;
47076 }
47077
47078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
47079         void* a_ptr = untag_ptr(a);
47080         CHECK_ACCESS(a_ptr);
47081         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
47082         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
47083         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47084         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
47085         int64_t ret_ref = tag_ptr(ret_copy, true);
47086         return ret_ref;
47087 }
47088
47089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
47090         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
47091         a_constr.datalen = (*env)->GetArrayLength(env, a);
47092         if (a_constr.datalen > 0)
47093                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47094         else
47095                 a_constr.data = NULL;
47096         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47097         for (size_t w = 0; w < a_constr.datalen; w++) {
47098                 int64_t a_conv_22 = a_vals[w];
47099                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
47100                 CHECK_ACCESS(a_conv_22_ptr);
47101                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
47102                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
47103                 a_constr.data[w] = a_conv_22_conv;
47104         }
47105         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47106         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47107         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
47108         int64_t ret_ref = tag_ptr(ret_copy, true);
47109         return ret_ref;
47110 }
47111
47112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
47113         LDKCVec_APIErrorZ a_constr;
47114         a_constr.datalen = (*env)->GetArrayLength(env, a);
47115         if (a_constr.datalen > 0)
47116                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
47117         else
47118                 a_constr.data = NULL;
47119         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47120         for (size_t k = 0; k < a_constr.datalen; k++) {
47121                 int64_t a_conv_10 = a_vals[k];
47122                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
47123                 CHECK_ACCESS(a_conv_10_ptr);
47124                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
47125                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
47126                 a_constr.data[k] = a_conv_10_conv;
47127         }
47128         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47129         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47130         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
47131         int64_t ret_ref = tag_ptr(ret_copy, true);
47132         return ret_ref;
47133 }
47134
47135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47136         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47137         *ret_copy = PaymentSendFailure_duplicate_payment();
47138         int64_t ret_ref = tag_ptr(ret_copy, true);
47139         return ret_ref;
47140 }
47141
47142 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) {
47143         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
47144         results_constr.datalen = (*env)->GetArrayLength(env, results);
47145         if (results_constr.datalen > 0)
47146                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47147         else
47148                 results_constr.data = NULL;
47149         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
47150         for (size_t w = 0; w < results_constr.datalen; w++) {
47151                 int64_t results_conv_22 = results_vals[w];
47152                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
47153                 CHECK_ACCESS(results_conv_22_ptr);
47154                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
47155                 results_constr.data[w] = results_conv_22_conv;
47156         }
47157         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
47158         LDKRouteParameters failed_paths_retry_conv;
47159         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
47160         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
47161         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
47162         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
47163         LDKThirtyTwoBytes payment_id_ref;
47164         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
47165         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
47166         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47167         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
47168         int64_t ret_ref = tag_ptr(ret_copy, true);
47169         return ret_ref;
47170 }
47171
47172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47173         LDKRecipientOnionFields this_obj_conv;
47174         this_obj_conv.inner = untag_ptr(this_obj);
47175         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47177         RecipientOnionFields_free(this_obj_conv);
47178 }
47179
47180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
47181         LDKRecipientOnionFields this_ptr_conv;
47182         this_ptr_conv.inner = untag_ptr(this_ptr);
47183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47185         this_ptr_conv.is_owned = false;
47186         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RecipientOnionFields_get_payment_secret(&this_ptr_conv).data);
47188         return ret_arr;
47189 }
47190
47191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47192         LDKRecipientOnionFields this_ptr_conv;
47193         this_ptr_conv.inner = untag_ptr(this_ptr);
47194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47196         this_ptr_conv.is_owned = false;
47197         LDKThirtyTwoBytes val_ref;
47198         CHECK((*env)->GetArrayLength(env, val) == 32);
47199         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47200         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_ref);
47201 }
47202
47203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr) {
47204         LDKRecipientOnionFields this_ptr_conv;
47205         this_ptr_conv.inner = untag_ptr(this_ptr);
47206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47208         this_ptr_conv.is_owned = false;
47209         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47210         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
47211         int64_t ret_ref = tag_ptr(ret_copy, true);
47212         return ret_ref;
47213 }
47214
47215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47216         LDKRecipientOnionFields this_ptr_conv;
47217         this_ptr_conv.inner = untag_ptr(this_ptr);
47218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47220         this_ptr_conv.is_owned = false;
47221         void* val_ptr = untag_ptr(val);
47222         CHECK_ACCESS(val_ptr);
47223         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
47224         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
47225         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
47226 }
47227
47228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1new(JNIEnv *env, jclass clz, int8_tArray payment_secret_arg, int64_t payment_metadata_arg) {
47229         LDKThirtyTwoBytes payment_secret_arg_ref;
47230         CHECK((*env)->GetArrayLength(env, payment_secret_arg) == 32);
47231         (*env)->GetByteArrayRegion(env, payment_secret_arg, 0, 32, payment_secret_arg_ref.data);
47232         void* payment_metadata_arg_ptr = untag_ptr(payment_metadata_arg);
47233         CHECK_ACCESS(payment_metadata_arg_ptr);
47234         LDKCOption_CVec_u8ZZ payment_metadata_arg_conv = *(LDKCOption_CVec_u8ZZ*)(payment_metadata_arg_ptr);
47235         payment_metadata_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(payment_metadata_arg));
47236         LDKRecipientOnionFields ret_var = RecipientOnionFields_new(payment_secret_arg_ref, payment_metadata_arg_conv);
47237         int64_t ret_ref = 0;
47238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47240         return ret_ref;
47241 }
47242
47243 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
47244         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
47245         int64_t ret_ref = 0;
47246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47248         return ret_ref;
47249 }
47250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47251         LDKRecipientOnionFields arg_conv;
47252         arg_conv.inner = untag_ptr(arg);
47253         arg_conv.is_owned = ptr_is_owned(arg);
47254         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47255         arg_conv.is_owned = false;
47256         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
47257         return ret_conv;
47258 }
47259
47260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47261         LDKRecipientOnionFields orig_conv;
47262         orig_conv.inner = untag_ptr(orig);
47263         orig_conv.is_owned = ptr_is_owned(orig);
47264         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47265         orig_conv.is_owned = false;
47266         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
47267         int64_t ret_ref = 0;
47268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47270         return ret_ref;
47271 }
47272
47273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47274         LDKRecipientOnionFields a_conv;
47275         a_conv.inner = untag_ptr(a);
47276         a_conv.is_owned = ptr_is_owned(a);
47277         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47278         a_conv.is_owned = false;
47279         LDKRecipientOnionFields b_conv;
47280         b_conv.inner = untag_ptr(b);
47281         b_conv.is_owned = ptr_is_owned(b);
47282         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47283         b_conv.is_owned = false;
47284         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
47285         return ret_conv;
47286 }
47287
47288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1write(JNIEnv *env, jclass clz, int64_t obj) {
47289         LDKRecipientOnionFields obj_conv;
47290         obj_conv.inner = untag_ptr(obj);
47291         obj_conv.is_owned = ptr_is_owned(obj);
47292         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47293         obj_conv.is_owned = false;
47294         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
47295         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47296         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47297         CVec_u8Z_free(ret_var);
47298         return ret_arr;
47299 }
47300
47301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47302         LDKu8slice ser_ref;
47303         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47304         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47305         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
47306         *ret_conv = RecipientOnionFields_read(ser_ref);
47307         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47308         return tag_ptr(ret_conv, true);
47309 }
47310
47311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1secret_1only(JNIEnv *env, jclass clz, int8_tArray payment_secret) {
47312         LDKThirtyTwoBytes payment_secret_ref;
47313         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
47314         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
47315         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
47316         int64_t ret_ref = 0;
47317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47319         return ret_ref;
47320 }
47321
47322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1spontaneous_1empty(JNIEnv *env, jclass clz) {
47323         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
47324         int64_t ret_ref = 0;
47325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47327         return ret_ref;
47328 }
47329
47330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47331         if (!ptr_is_owned(this_ptr)) return;
47332         void* this_ptr_ptr = untag_ptr(this_ptr);
47333         CHECK_ACCESS(this_ptr_ptr);
47334         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
47335         FREE(untag_ptr(this_ptr));
47336         CustomMessageReader_free(this_ptr_conv);
47337 }
47338
47339 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
47340         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47341         *ret_ret = Type_clone(arg);
47342         return tag_ptr(ret_ret, true);
47343 }
47344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47345         void* arg_ptr = untag_ptr(arg);
47346         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47347         LDKType* arg_conv = (LDKType*)arg_ptr;
47348         int64_t ret_conv = Type_clone_ptr(arg_conv);
47349         return ret_conv;
47350 }
47351
47352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47353         void* orig_ptr = untag_ptr(orig);
47354         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47355         LDKType* orig_conv = (LDKType*)orig_ptr;
47356         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47357         *ret_ret = Type_clone(orig_conv);
47358         return tag_ptr(ret_ret, true);
47359 }
47360
47361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47362         if (!ptr_is_owned(this_ptr)) return;
47363         void* this_ptr_ptr = untag_ptr(this_ptr);
47364         CHECK_ACCESS(this_ptr_ptr);
47365         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
47366         FREE(untag_ptr(this_ptr));
47367         Type_free(this_ptr_conv);
47368 }
47369
47370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47371         LDKUnsignedInvoice this_obj_conv;
47372         this_obj_conv.inner = untag_ptr(this_obj);
47373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47375         UnsignedInvoice_free(this_obj_conv);
47376 }
47377
47378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47379         LDKUnsignedInvoice this_arg_conv;
47380         this_arg_conv.inner = untag_ptr(this_arg);
47381         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47383         this_arg_conv.is_owned = false;
47384         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47385         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedInvoice_signing_pubkey(&this_arg_conv).compressed_form);
47386         return ret_arr;
47387 }
47388
47389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47390         LDKBlindedPayInfo this_obj_conv;
47391         this_obj_conv.inner = untag_ptr(this_obj);
47392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47394         BlindedPayInfo_free(this_obj_conv);
47395 }
47396
47397 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47398         LDKBlindedPayInfo this_ptr_conv;
47399         this_ptr_conv.inner = untag_ptr(this_ptr);
47400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47402         this_ptr_conv.is_owned = false;
47403         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
47404         return ret_conv;
47405 }
47406
47407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47408         LDKBlindedPayInfo this_ptr_conv;
47409         this_ptr_conv.inner = untag_ptr(this_ptr);
47410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47412         this_ptr_conv.is_owned = false;
47413         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
47414 }
47415
47416 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
47417         LDKBlindedPayInfo this_ptr_conv;
47418         this_ptr_conv.inner = untag_ptr(this_ptr);
47419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47421         this_ptr_conv.is_owned = false;
47422         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
47423         return ret_conv;
47424 }
47425
47426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47427         LDKBlindedPayInfo this_ptr_conv;
47428         this_ptr_conv.inner = untag_ptr(this_ptr);
47429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47431         this_ptr_conv.is_owned = false;
47432         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
47433 }
47434
47435 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47436         LDKBlindedPayInfo this_ptr_conv;
47437         this_ptr_conv.inner = untag_ptr(this_ptr);
47438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47440         this_ptr_conv.is_owned = false;
47441         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
47442         return ret_conv;
47443 }
47444
47445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47446         LDKBlindedPayInfo this_ptr_conv;
47447         this_ptr_conv.inner = untag_ptr(this_ptr);
47448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47450         this_ptr_conv.is_owned = false;
47451         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
47452 }
47453
47454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47455         LDKBlindedPayInfo this_ptr_conv;
47456         this_ptr_conv.inner = untag_ptr(this_ptr);
47457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47459         this_ptr_conv.is_owned = false;
47460         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
47461         return ret_conv;
47462 }
47463
47464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47465         LDKBlindedPayInfo this_ptr_conv;
47466         this_ptr_conv.inner = untag_ptr(this_ptr);
47467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47469         this_ptr_conv.is_owned = false;
47470         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
47471 }
47472
47473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47474         LDKBlindedPayInfo this_ptr_conv;
47475         this_ptr_conv.inner = untag_ptr(this_ptr);
47476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47478         this_ptr_conv.is_owned = false;
47479         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
47480         return ret_conv;
47481 }
47482
47483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47484         LDKBlindedPayInfo this_ptr_conv;
47485         this_ptr_conv.inner = untag_ptr(this_ptr);
47486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47488         this_ptr_conv.is_owned = false;
47489         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
47490 }
47491
47492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47493         LDKBlindedPayInfo this_ptr_conv;
47494         this_ptr_conv.inner = untag_ptr(this_ptr);
47495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47497         this_ptr_conv.is_owned = false;
47498         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
47499         int64_t ret_ref = 0;
47500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47502         return ret_ref;
47503 }
47504
47505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47506         LDKBlindedPayInfo this_ptr_conv;
47507         this_ptr_conv.inner = untag_ptr(this_ptr);
47508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47510         this_ptr_conv.is_owned = false;
47511         LDKBlindedHopFeatures val_conv;
47512         val_conv.inner = untag_ptr(val);
47513         val_conv.is_owned = ptr_is_owned(val);
47514         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47515         val_conv = BlindedHopFeatures_clone(&val_conv);
47516         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
47517 }
47518
47519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t features_arg) {
47520         LDKBlindedHopFeatures features_arg_conv;
47521         features_arg_conv.inner = untag_ptr(features_arg);
47522         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47523         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47524         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
47525         LDKBlindedPayInfo ret_var = BlindedPayInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, features_arg_conv);
47526         int64_t ret_ref = 0;
47527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47529         return ret_ref;
47530 }
47531
47532 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
47533         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
47534         int64_t ret_ref = 0;
47535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47537         return ret_ref;
47538 }
47539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47540         LDKBlindedPayInfo arg_conv;
47541         arg_conv.inner = untag_ptr(arg);
47542         arg_conv.is_owned = ptr_is_owned(arg);
47543         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47544         arg_conv.is_owned = false;
47545         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
47546         return ret_conv;
47547 }
47548
47549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47550         LDKBlindedPayInfo orig_conv;
47551         orig_conv.inner = untag_ptr(orig);
47552         orig_conv.is_owned = ptr_is_owned(orig);
47553         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47554         orig_conv.is_owned = false;
47555         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
47556         int64_t ret_ref = 0;
47557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47559         return ret_ref;
47560 }
47561
47562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1hash(JNIEnv *env, jclass clz, int64_t o) {
47563         LDKBlindedPayInfo o_conv;
47564         o_conv.inner = untag_ptr(o);
47565         o_conv.is_owned = ptr_is_owned(o);
47566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47567         o_conv.is_owned = false;
47568         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
47569         return ret_conv;
47570 }
47571
47572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47573         LDKBlindedPayInfo a_conv;
47574         a_conv.inner = untag_ptr(a);
47575         a_conv.is_owned = ptr_is_owned(a);
47576         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47577         a_conv.is_owned = false;
47578         LDKBlindedPayInfo b_conv;
47579         b_conv.inner = untag_ptr(b);
47580         b_conv.is_owned = ptr_is_owned(b);
47581         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47582         b_conv.is_owned = false;
47583         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
47584         return ret_conv;
47585 }
47586
47587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47588         LDKBlindedPayInfo obj_conv;
47589         obj_conv.inner = untag_ptr(obj);
47590         obj_conv.is_owned = ptr_is_owned(obj);
47591         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47592         obj_conv.is_owned = false;
47593         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
47594         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47595         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47596         CVec_u8Z_free(ret_var);
47597         return ret_arr;
47598 }
47599
47600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47601         LDKu8slice ser_ref;
47602         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47603         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47604         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
47605         *ret_conv = BlindedPayInfo_read(ser_ref);
47606         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47607         return tag_ptr(ret_conv, true);
47608 }
47609
47610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47611         LDKUnsignedInvoiceRequest this_obj_conv;
47612         this_obj_conv.inner = untag_ptr(this_obj);
47613         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47615         UnsignedInvoiceRequest_free(this_obj_conv);
47616 }
47617
47618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47619         LDKInvoiceRequest this_obj_conv;
47620         this_obj_conv.inner = untag_ptr(this_obj);
47621         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47623         InvoiceRequest_free(this_obj_conv);
47624 }
47625
47626 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
47627         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
47628         int64_t ret_ref = 0;
47629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47631         return ret_ref;
47632 }
47633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47634         LDKInvoiceRequest arg_conv;
47635         arg_conv.inner = untag_ptr(arg);
47636         arg_conv.is_owned = ptr_is_owned(arg);
47637         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47638         arg_conv.is_owned = false;
47639         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
47640         return ret_conv;
47641 }
47642
47643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47644         LDKInvoiceRequest orig_conv;
47645         orig_conv.inner = untag_ptr(orig);
47646         orig_conv.is_owned = ptr_is_owned(orig);
47647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47648         orig_conv.is_owned = false;
47649         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
47650         int64_t ret_ref = 0;
47651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47653         return ret_ref;
47654 }
47655
47656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47657         LDKInvoiceRequest this_arg_conv;
47658         this_arg_conv.inner = untag_ptr(this_arg);
47659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47661         this_arg_conv.is_owned = false;
47662         LDKu8slice ret_var = InvoiceRequest_metadata(&this_arg_conv);
47663         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47664         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47665         return ret_arr;
47666 }
47667
47668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
47669         LDKInvoiceRequest this_arg_conv;
47670         this_arg_conv.inner = untag_ptr(this_arg);
47671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47673         this_arg_conv.is_owned = false;
47674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, InvoiceRequest_chain(&this_arg_conv).data);
47676         return ret_arr;
47677 }
47678
47679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
47680         LDKInvoiceRequest this_arg_conv;
47681         this_arg_conv.inner = untag_ptr(this_arg);
47682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47684         this_arg_conv.is_owned = false;
47685         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47686         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
47687         int64_t ret_ref = tag_ptr(ret_copy, true);
47688         return ret_ref;
47689 }
47690
47691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47692         LDKInvoiceRequest this_arg_conv;
47693         this_arg_conv.inner = untag_ptr(this_arg);
47694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47696         this_arg_conv.is_owned = false;
47697         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_features(&this_arg_conv);
47698         int64_t ret_ref = 0;
47699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47701         return ret_ref;
47702 }
47703
47704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47705         LDKInvoiceRequest this_arg_conv;
47706         this_arg_conv.inner = untag_ptr(this_arg);
47707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47709         this_arg_conv.is_owned = false;
47710         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47711         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
47712         int64_t ret_ref = tag_ptr(ret_copy, true);
47713         return ret_ref;
47714 }
47715
47716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
47717         LDKInvoiceRequest this_arg_conv;
47718         this_arg_conv.inner = untag_ptr(this_arg);
47719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47721         this_arg_conv.is_owned = false;
47722         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47723         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, InvoiceRequest_payer_id(&this_arg_conv).compressed_form);
47724         return ret_arr;
47725 }
47726
47727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
47728         LDKInvoiceRequest this_arg_conv;
47729         this_arg_conv.inner = untag_ptr(this_arg);
47730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47732         this_arg_conv.is_owned = false;
47733         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
47734         int64_t ret_ref = 0;
47735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47736         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47737         return ret_ref;
47738 }
47739
47740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1write(JNIEnv *env, jclass clz, int64_t obj) {
47741         LDKInvoiceRequest obj_conv;
47742         obj_conv.inner = untag_ptr(obj);
47743         obj_conv.is_owned = ptr_is_owned(obj);
47744         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47745         obj_conv.is_owned = false;
47746         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
47747         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47748         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47749         CVec_u8Z_free(ret_var);
47750         return ret_arr;
47751 }
47752
47753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Offer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47754         LDKOffer this_obj_conv;
47755         this_obj_conv.inner = untag_ptr(this_obj);
47756         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47758         Offer_free(this_obj_conv);
47759 }
47760
47761 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
47762         LDKOffer ret_var = Offer_clone(arg);
47763         int64_t ret_ref = 0;
47764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47766         return ret_ref;
47767 }
47768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47769         LDKOffer arg_conv;
47770         arg_conv.inner = untag_ptr(arg);
47771         arg_conv.is_owned = ptr_is_owned(arg);
47772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47773         arg_conv.is_owned = false;
47774         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
47775         return ret_conv;
47776 }
47777
47778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47779         LDKOffer orig_conv;
47780         orig_conv.inner = untag_ptr(orig);
47781         orig_conv.is_owned = ptr_is_owned(orig);
47782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47783         orig_conv.is_owned = false;
47784         LDKOffer ret_var = Offer_clone(&orig_conv);
47785         int64_t ret_ref = 0;
47786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47788         return ret_ref;
47789 }
47790
47791 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Offer_1chains(JNIEnv *env, jclass clz, int64_t this_arg) {
47792         LDKOffer this_arg_conv;
47793         this_arg_conv.inner = untag_ptr(this_arg);
47794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47796         this_arg_conv.is_owned = false;
47797         LDKCVec_ChainHashZ ret_var = Offer_chains(&this_arg_conv);
47798         jobjectArray ret_arr = NULL;
47799         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
47800         ;
47801         for (size_t i = 0; i < ret_var.datalen; i++) {
47802                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
47803                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
47804                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
47805         }
47806         
47807         FREE(ret_var.data);
47808         return ret_arr;
47809 }
47810
47811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1supports_1chain(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray chain) {
47812         LDKOffer this_arg_conv;
47813         this_arg_conv.inner = untag_ptr(this_arg);
47814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47816         this_arg_conv.is_owned = false;
47817         LDKThirtyTwoBytes chain_ref;
47818         CHECK((*env)->GetArrayLength(env, chain) == 32);
47819         (*env)->GetByteArrayRegion(env, chain, 0, 32, chain_ref.data);
47820         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
47821         return ret_conv;
47822 }
47823
47824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47825         LDKOffer this_arg_conv;
47826         this_arg_conv.inner = untag_ptr(this_arg);
47827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47829         this_arg_conv.is_owned = false;
47830         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47831         *ret_copy = Offer_metadata(&this_arg_conv);
47832         int64_t ret_ref = tag_ptr(ret_copy, true);
47833         return ret_ref;
47834 }
47835
47836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
47837         LDKOffer this_arg_conv;
47838         this_arg_conv.inner = untag_ptr(this_arg);
47839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47841         this_arg_conv.is_owned = false;
47842         LDKAmount ret_var = Offer_amount(&this_arg_conv);
47843         int64_t ret_ref = 0;
47844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47846         return ret_ref;
47847 }
47848
47849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47850         LDKOffer this_arg_conv;
47851         this_arg_conv.inner = untag_ptr(this_arg);
47852         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47854         this_arg_conv.is_owned = false;
47855         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
47856         int64_t ret_ref = 0;
47857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47859         return ret_ref;
47860 }
47861
47862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47863         LDKOffer this_arg_conv;
47864         this_arg_conv.inner = untag_ptr(this_arg);
47865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47867         this_arg_conv.is_owned = false;
47868         LDKOfferFeatures ret_var = Offer_features(&this_arg_conv);
47869         int64_t ret_ref = 0;
47870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47872         return ret_ref;
47873 }
47874
47875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47876         LDKOffer this_arg_conv;
47877         this_arg_conv.inner = untag_ptr(this_arg);
47878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47880         this_arg_conv.is_owned = false;
47881         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
47882         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
47883         int64_t ret_ref = tag_ptr(ret_copy, true);
47884         return ret_ref;
47885 }
47886
47887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47888         LDKOffer this_arg_conv;
47889         this_arg_conv.inner = untag_ptr(this_arg);
47890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47892         this_arg_conv.is_owned = false;
47893         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
47894         return ret_conv;
47895 }
47896
47897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
47898         LDKOffer this_arg_conv;
47899         this_arg_conv.inner = untag_ptr(this_arg);
47900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47902         this_arg_conv.is_owned = false;
47903         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
47904         int64_t ret_ref = 0;
47905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47907         return ret_ref;
47908 }
47909
47910 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
47911         LDKOffer this_arg_conv;
47912         this_arg_conv.inner = untag_ptr(this_arg);
47913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47915         this_arg_conv.is_owned = false;
47916         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
47917         int64_tArray ret_arr = NULL;
47918         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47919         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47920         for (size_t n = 0; n < ret_var.datalen; n++) {
47921                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
47922                 int64_t ret_conv_13_ref = 0;
47923                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
47924                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
47925                 ret_arr_ptr[n] = ret_conv_13_ref;
47926         }
47927         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47928         FREE(ret_var.data);
47929         return ret_arr;
47930 }
47931
47932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1supported_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47933         LDKOffer this_arg_conv;
47934         this_arg_conv.inner = untag_ptr(this_arg);
47935         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47937         this_arg_conv.is_owned = false;
47938         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
47939         int64_t ret_ref = 0;
47940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47942         return ret_ref;
47943 }
47944
47945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1valid_1quantity(JNIEnv *env, jclass clz, int64_t this_arg, int64_t quantity) {
47946         LDKOffer this_arg_conv;
47947         this_arg_conv.inner = untag_ptr(this_arg);
47948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47950         this_arg_conv.is_owned = false;
47951         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
47952         return ret_conv;
47953 }
47954
47955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1expects_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47956         LDKOffer this_arg_conv;
47957         this_arg_conv.inner = untag_ptr(this_arg);
47958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47960         this_arg_conv.is_owned = false;
47961         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
47962         return ret_conv;
47963 }
47964
47965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47966         LDKOffer this_arg_conv;
47967         this_arg_conv.inner = untag_ptr(this_arg);
47968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47970         this_arg_conv.is_owned = false;
47971         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47972         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Offer_signing_pubkey(&this_arg_conv).compressed_form);
47973         return ret_arr;
47974 }
47975
47976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47977         LDKOffer obj_conv;
47978         obj_conv.inner = untag_ptr(obj);
47979         obj_conv.is_owned = ptr_is_owned(obj);
47980         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47981         obj_conv.is_owned = false;
47982         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
47983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47985         CVec_u8Z_free(ret_var);
47986         return ret_arr;
47987 }
47988
47989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Amount_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47990         LDKAmount this_obj_conv;
47991         this_obj_conv.inner = untag_ptr(this_obj);
47992         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47994         Amount_free(this_obj_conv);
47995 }
47996
47997 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
47998         LDKAmount ret_var = Amount_clone(arg);
47999         int64_t ret_ref = 0;
48000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48002         return ret_ref;
48003 }
48004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48005         LDKAmount arg_conv;
48006         arg_conv.inner = untag_ptr(arg);
48007         arg_conv.is_owned = ptr_is_owned(arg);
48008         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48009         arg_conv.is_owned = false;
48010         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
48011         return ret_conv;
48012 }
48013
48014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48015         LDKAmount orig_conv;
48016         orig_conv.inner = untag_ptr(orig);
48017         orig_conv.is_owned = ptr_is_owned(orig);
48018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48019         orig_conv.is_owned = false;
48020         LDKAmount ret_var = Amount_clone(&orig_conv);
48021         int64_t ret_ref = 0;
48022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48024         return ret_ref;
48025 }
48026
48027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Quantity_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48028         LDKQuantity this_obj_conv;
48029         this_obj_conv.inner = untag_ptr(this_obj);
48030         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48032         Quantity_free(this_obj_conv);
48033 }
48034
48035 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
48036         LDKQuantity ret_var = Quantity_clone(arg);
48037         int64_t ret_ref = 0;
48038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48040         return ret_ref;
48041 }
48042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48043         LDKQuantity arg_conv;
48044         arg_conv.inner = untag_ptr(arg);
48045         arg_conv.is_owned = ptr_is_owned(arg);
48046         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48047         arg_conv.is_owned = false;
48048         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
48049         return ret_conv;
48050 }
48051
48052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48053         LDKQuantity orig_conv;
48054         orig_conv.inner = untag_ptr(orig);
48055         orig_conv.is_owned = ptr_is_owned(orig);
48056         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48057         orig_conv.is_owned = false;
48058         LDKQuantity ret_var = Quantity_clone(&orig_conv);
48059         int64_t ret_ref = 0;
48060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48061         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48062         return ret_ref;
48063 }
48064
48065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Refund_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48066         LDKRefund this_obj_conv;
48067         this_obj_conv.inner = untag_ptr(this_obj);
48068         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48070         Refund_free(this_obj_conv);
48071 }
48072
48073 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
48074         LDKRefund ret_var = Refund_clone(arg);
48075         int64_t ret_ref = 0;
48076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48078         return ret_ref;
48079 }
48080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48081         LDKRefund arg_conv;
48082         arg_conv.inner = untag_ptr(arg);
48083         arg_conv.is_owned = ptr_is_owned(arg);
48084         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48085         arg_conv.is_owned = false;
48086         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
48087         return ret_conv;
48088 }
48089
48090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48091         LDKRefund orig_conv;
48092         orig_conv.inner = untag_ptr(orig);
48093         orig_conv.is_owned = ptr_is_owned(orig);
48094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48095         orig_conv.is_owned = false;
48096         LDKRefund ret_var = Refund_clone(&orig_conv);
48097         int64_t ret_ref = 0;
48098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48100         return ret_ref;
48101 }
48102
48103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48104         LDKRefund this_arg_conv;
48105         this_arg_conv.inner = untag_ptr(this_arg);
48106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48108         this_arg_conv.is_owned = false;
48109         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
48110         int64_t ret_ref = 0;
48111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48113         return ret_ref;
48114 }
48115
48116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48117         LDKRefund this_arg_conv;
48118         this_arg_conv.inner = untag_ptr(this_arg);
48119         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48121         this_arg_conv.is_owned = false;
48122         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
48123         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
48124         int64_t ret_ref = tag_ptr(ret_copy, true);
48125         return ret_ref;
48126 }
48127
48128 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Refund_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48129         LDKRefund this_arg_conv;
48130         this_arg_conv.inner = untag_ptr(this_arg);
48131         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48133         this_arg_conv.is_owned = false;
48134         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
48135         return ret_conv;
48136 }
48137
48138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
48139         LDKRefund this_arg_conv;
48140         this_arg_conv.inner = untag_ptr(this_arg);
48141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48143         this_arg_conv.is_owned = false;
48144         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
48145         int64_t ret_ref = 0;
48146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48148         return ret_ref;
48149 }
48150
48151 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
48152         LDKRefund this_arg_conv;
48153         this_arg_conv.inner = untag_ptr(this_arg);
48154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48156         this_arg_conv.is_owned = false;
48157         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
48158         int64_tArray ret_arr = NULL;
48159         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48160         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48161         for (size_t n = 0; n < ret_var.datalen; n++) {
48162                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
48163                 int64_t ret_conv_13_ref = 0;
48164                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
48165                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
48166                 ret_arr_ptr[n] = ret_conv_13_ref;
48167         }
48168         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48169         FREE(ret_var.data);
48170         return ret_arr;
48171 }
48172
48173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
48174         LDKRefund this_arg_conv;
48175         this_arg_conv.inner = untag_ptr(this_arg);
48176         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48178         this_arg_conv.is_owned = false;
48179         LDKu8slice ret_var = Refund_metadata(&this_arg_conv);
48180         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48181         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48182         return ret_arr;
48183 }
48184
48185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
48186         LDKRefund this_arg_conv;
48187         this_arg_conv.inner = untag_ptr(this_arg);
48188         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48190         this_arg_conv.is_owned = false;
48191         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Refund_chain(&this_arg_conv).data);
48193         return ret_arr;
48194 }
48195
48196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
48197         LDKRefund this_arg_conv;
48198         this_arg_conv.inner = untag_ptr(this_arg);
48199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48201         this_arg_conv.is_owned = false;
48202         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
48203         return ret_conv;
48204 }
48205
48206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48207         LDKRefund this_arg_conv;
48208         this_arg_conv.inner = untag_ptr(this_arg);
48209         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48211         this_arg_conv.is_owned = false;
48212         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
48213         int64_t ret_ref = 0;
48214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48216         return ret_ref;
48217 }
48218
48219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
48220         LDKRefund this_arg_conv;
48221         this_arg_conv.inner = untag_ptr(this_arg);
48222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48224         this_arg_conv.is_owned = false;
48225         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48226         *ret_copy = Refund_quantity(&this_arg_conv);
48227         int64_t ret_ref = tag_ptr(ret_copy, true);
48228         return ret_ref;
48229 }
48230
48231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
48232         LDKRefund this_arg_conv;
48233         this_arg_conv.inner = untag_ptr(this_arg);
48234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48236         this_arg_conv.is_owned = false;
48237         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48238         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Refund_payer_id(&this_arg_conv).compressed_form);
48239         return ret_arr;
48240 }
48241
48242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
48243         LDKRefund this_arg_conv;
48244         this_arg_conv.inner = untag_ptr(this_arg);
48245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48247         this_arg_conv.is_owned = false;
48248         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
48249         int64_t ret_ref = 0;
48250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48251         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48252         return ret_ref;
48253 }
48254
48255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1write(JNIEnv *env, jclass clz, int64_t obj) {
48256         LDKRefund obj_conv;
48257         obj_conv.inner = untag_ptr(obj);
48258         obj_conv.is_owned = ptr_is_owned(obj);
48259         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48260         obj_conv.is_owned = false;
48261         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
48262         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48263         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48264         CVec_u8Z_free(ret_var);
48265         return ret_arr;
48266 }
48267
48268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48269         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
48270         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_clone(orig_conv));
48271         return ret_conv;
48272 }
48273
48274 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1chain(JNIEnv *env, jclass clz) {
48275         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_chain());
48276         return ret_conv;
48277 }
48278
48279 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1tx(JNIEnv *env, jclass clz) {
48280         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_tx());
48281         return ret_conv;
48282 }
48283
48284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoResult_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48285         if (!ptr_is_owned(this_ptr)) return;
48286         void* this_ptr_ptr = untag_ptr(this_ptr);
48287         CHECK_ACCESS(this_ptr_ptr);
48288         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
48289         FREE(untag_ptr(this_ptr));
48290         UtxoResult_free(this_ptr_conv);
48291 }
48292
48293 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
48294         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48295         *ret_copy = UtxoResult_clone(arg);
48296         int64_t ret_ref = tag_ptr(ret_copy, true);
48297         return ret_ref;
48298 }
48299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48300         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
48301         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
48302         return ret_conv;
48303 }
48304
48305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48306         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
48307         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48308         *ret_copy = UtxoResult_clone(orig_conv);
48309         int64_t ret_ref = tag_ptr(ret_copy, true);
48310         return ret_ref;
48311 }
48312
48313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1sync(JNIEnv *env, jclass clz, int64_t a) {
48314         void* a_ptr = untag_ptr(a);
48315         CHECK_ACCESS(a_ptr);
48316         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
48317         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
48318         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48319         *ret_copy = UtxoResult_sync(a_conv);
48320         int64_t ret_ref = tag_ptr(ret_copy, true);
48321         return ret_ref;
48322 }
48323
48324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1async(JNIEnv *env, jclass clz, int64_t a) {
48325         LDKUtxoFuture a_conv;
48326         a_conv.inner = untag_ptr(a);
48327         a_conv.is_owned = ptr_is_owned(a);
48328         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48329         a_conv = UtxoFuture_clone(&a_conv);
48330         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48331         *ret_copy = UtxoResult_async(a_conv);
48332         int64_t ret_ref = tag_ptr(ret_copy, true);
48333         return ret_ref;
48334 }
48335
48336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48337         if (!ptr_is_owned(this_ptr)) return;
48338         void* this_ptr_ptr = untag_ptr(this_ptr);
48339         CHECK_ACCESS(this_ptr_ptr);
48340         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
48341         FREE(untag_ptr(this_ptr));
48342         UtxoLookup_free(this_ptr_conv);
48343 }
48344
48345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48346         LDKUtxoFuture this_obj_conv;
48347         this_obj_conv.inner = untag_ptr(this_obj);
48348         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48350         UtxoFuture_free(this_obj_conv);
48351 }
48352
48353 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
48354         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
48355         int64_t ret_ref = 0;
48356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48358         return ret_ref;
48359 }
48360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48361         LDKUtxoFuture arg_conv;
48362         arg_conv.inner = untag_ptr(arg);
48363         arg_conv.is_owned = ptr_is_owned(arg);
48364         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48365         arg_conv.is_owned = false;
48366         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
48367         return ret_conv;
48368 }
48369
48370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48371         LDKUtxoFuture orig_conv;
48372         orig_conv.inner = untag_ptr(orig);
48373         orig_conv.is_owned = ptr_is_owned(orig);
48374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48375         orig_conv.is_owned = false;
48376         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
48377         int64_t ret_ref = 0;
48378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48380         return ret_ref;
48381 }
48382
48383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1new(JNIEnv *env, jclass clz) {
48384         LDKUtxoFuture ret_var = UtxoFuture_new();
48385         int64_t ret_ref = 0;
48386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48388         return ret_ref;
48389 }
48390
48391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1resolve_1without_1forwarding(JNIEnv *env, jclass clz, int64_t this_arg, int64_t graph, int64_t result) {
48392         LDKUtxoFuture this_arg_conv;
48393         this_arg_conv.inner = untag_ptr(this_arg);
48394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48396         this_arg_conv.is_owned = false;
48397         LDKNetworkGraph graph_conv;
48398         graph_conv.inner = untag_ptr(graph);
48399         graph_conv.is_owned = ptr_is_owned(graph);
48400         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48401         graph_conv.is_owned = false;
48402         void* result_ptr = untag_ptr(result);
48403         CHECK_ACCESS(result_ptr);
48404         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48405         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
48406 }
48407
48408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1resolve(JNIEnv *env, jclass clz, int64_t this_arg, int64_t graph, int64_t gossip, int64_t result) {
48409         LDKUtxoFuture this_arg_conv;
48410         this_arg_conv.inner = untag_ptr(this_arg);
48411         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48413         this_arg_conv.is_owned = false;
48414         LDKNetworkGraph graph_conv;
48415         graph_conv.inner = untag_ptr(graph);
48416         graph_conv.is_owned = ptr_is_owned(graph);
48417         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48418         graph_conv.is_owned = false;
48419         LDKP2PGossipSync gossip_conv;
48420         gossip_conv.inner = untag_ptr(gossip);
48421         gossip_conv.is_owned = ptr_is_owned(gossip);
48422         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
48423         gossip_conv.is_owned = false;
48424         void* result_ptr = untag_ptr(result);
48425         CHECK_ACCESS(result_ptr);
48426         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48427         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
48428 }
48429
48430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48431         LDKNodeId this_obj_conv;
48432         this_obj_conv.inner = untag_ptr(this_obj);
48433         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48435         NodeId_free(this_obj_conv);
48436 }
48437
48438 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
48439         LDKNodeId ret_var = NodeId_clone(arg);
48440         int64_t ret_ref = 0;
48441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48443         return ret_ref;
48444 }
48445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48446         LDKNodeId arg_conv;
48447         arg_conv.inner = untag_ptr(arg);
48448         arg_conv.is_owned = ptr_is_owned(arg);
48449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48450         arg_conv.is_owned = false;
48451         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
48452         return ret_conv;
48453 }
48454
48455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48456         LDKNodeId orig_conv;
48457         orig_conv.inner = untag_ptr(orig);
48458         orig_conv.is_owned = ptr_is_owned(orig);
48459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48460         orig_conv.is_owned = false;
48461         LDKNodeId ret_var = NodeId_clone(&orig_conv);
48462         int64_t ret_ref = 0;
48463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48465         return ret_ref;
48466 }
48467
48468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
48469         LDKPublicKey pubkey_ref;
48470         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48471         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48472         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
48473         int64_t ret_ref = 0;
48474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48476         return ret_ref;
48477 }
48478
48479 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
48480         LDKNodeId this_arg_conv;
48481         this_arg_conv.inner = untag_ptr(this_arg);
48482         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48484         this_arg_conv.is_owned = false;
48485         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
48486         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48487         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48488         return ret_arr;
48489 }
48490
48491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
48492         LDKNodeId this_arg_conv;
48493         this_arg_conv.inner = untag_ptr(this_arg);
48494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48496         this_arg_conv.is_owned = false;
48497         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
48498         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
48499         return tag_ptr(ret_conv, true);
48500 }
48501
48502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
48503         LDKNodeId o_conv;
48504         o_conv.inner = untag_ptr(o);
48505         o_conv.is_owned = ptr_is_owned(o);
48506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48507         o_conv.is_owned = false;
48508         int64_t ret_conv = NodeId_hash(&o_conv);
48509         return ret_conv;
48510 }
48511
48512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
48513         LDKNodeId obj_conv;
48514         obj_conv.inner = untag_ptr(obj);
48515         obj_conv.is_owned = ptr_is_owned(obj);
48516         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48517         obj_conv.is_owned = false;
48518         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
48519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48521         CVec_u8Z_free(ret_var);
48522         return ret_arr;
48523 }
48524
48525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48526         LDKu8slice ser_ref;
48527         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48528         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48529         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
48530         *ret_conv = NodeId_read(ser_ref);
48531         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48532         return tag_ptr(ret_conv, true);
48533 }
48534
48535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48536         LDKNetworkGraph this_obj_conv;
48537         this_obj_conv.inner = untag_ptr(this_obj);
48538         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48540         NetworkGraph_free(this_obj_conv);
48541 }
48542
48543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48544         LDKReadOnlyNetworkGraph this_obj_conv;
48545         this_obj_conv.inner = untag_ptr(this_obj);
48546         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48548         ReadOnlyNetworkGraph_free(this_obj_conv);
48549 }
48550
48551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48552         if (!ptr_is_owned(this_ptr)) return;
48553         void* this_ptr_ptr = untag_ptr(this_ptr);
48554         CHECK_ACCESS(this_ptr_ptr);
48555         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
48556         FREE(untag_ptr(this_ptr));
48557         NetworkUpdate_free(this_ptr_conv);
48558 }
48559
48560 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
48561         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48562         *ret_copy = NetworkUpdate_clone(arg);
48563         int64_t ret_ref = tag_ptr(ret_copy, true);
48564         return ret_ref;
48565 }
48566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48567         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
48568         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
48569         return ret_conv;
48570 }
48571
48572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48573         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
48574         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48575         *ret_copy = NetworkUpdate_clone(orig_conv);
48576         int64_t ret_ref = tag_ptr(ret_copy, true);
48577         return ret_ref;
48578 }
48579
48580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
48581         LDKChannelUpdate msg_conv;
48582         msg_conv.inner = untag_ptr(msg);
48583         msg_conv.is_owned = ptr_is_owned(msg);
48584         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48585         msg_conv = ChannelUpdate_clone(&msg_conv);
48586         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48587         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
48588         int64_t ret_ref = tag_ptr(ret_copy, true);
48589         return ret_ref;
48590 }
48591
48592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
48593         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48594         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
48595         int64_t ret_ref = tag_ptr(ret_copy, true);
48596         return ret_ref;
48597 }
48598
48599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
48600         LDKPublicKey node_id_ref;
48601         CHECK((*env)->GetArrayLength(env, node_id) == 33);
48602         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
48603         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48604         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
48605         int64_t ret_ref = tag_ptr(ret_copy, true);
48606         return ret_ref;
48607 }
48608
48609 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48610         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
48611         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
48612         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
48613         return ret_conv;
48614 }
48615
48616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
48617         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
48618         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
48619         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48620         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48621         CVec_u8Z_free(ret_var);
48622         return ret_arr;
48623 }
48624
48625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48626         LDKu8slice ser_ref;
48627         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48628         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48629         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
48630         *ret_conv = NetworkUpdate_read(ser_ref);
48631         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48632         return tag_ptr(ret_conv, true);
48633 }
48634
48635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48636         LDKP2PGossipSync this_obj_conv;
48637         this_obj_conv.inner = untag_ptr(this_obj);
48638         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48640         P2PGossipSync_free(this_obj_conv);
48641 }
48642
48643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t utxo_lookup, int64_t logger) {
48644         LDKNetworkGraph network_graph_conv;
48645         network_graph_conv.inner = untag_ptr(network_graph);
48646         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48647         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48648         network_graph_conv.is_owned = false;
48649         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48650         CHECK_ACCESS(utxo_lookup_ptr);
48651         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48652         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48653         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48654                 // Manually implement clone for Java trait instances
48655                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48656                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48657                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48658                 }
48659         }
48660         void* logger_ptr = untag_ptr(logger);
48661         CHECK_ACCESS(logger_ptr);
48662         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48663         if (logger_conv.free == LDKLogger_JCalls_free) {
48664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48665                 LDKLogger_JCalls_cloned(&logger_conv);
48666         }
48667         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
48668         int64_t ret_ref = 0;
48669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48671         return ret_ref;
48672 }
48673
48674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1utxo_1lookup(JNIEnv *env, jclass clz, int64_t this_arg, int64_t utxo_lookup) {
48675         LDKP2PGossipSync this_arg_conv;
48676         this_arg_conv.inner = untag_ptr(this_arg);
48677         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48679         this_arg_conv.is_owned = false;
48680         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48681         CHECK_ACCESS(utxo_lookup_ptr);
48682         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48683         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48684         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48685                 // Manually implement clone for Java trait instances
48686                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48687                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48688                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48689                 }
48690         }
48691         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
48692 }
48693
48694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
48695         LDKNetworkGraph this_arg_conv;
48696         this_arg_conv.inner = untag_ptr(this_arg);
48697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48699         this_arg_conv.is_owned = false;
48700         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
48701         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
48702 }
48703
48704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48705         LDKP2PGossipSync this_arg_conv;
48706         this_arg_conv.inner = untag_ptr(this_arg);
48707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48709         this_arg_conv.is_owned = false;
48710         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
48711         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
48712         return tag_ptr(ret_ret, true);
48713 }
48714
48715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
48716         LDKP2PGossipSync this_arg_conv;
48717         this_arg_conv.inner = untag_ptr(this_arg);
48718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48720         this_arg_conv.is_owned = false;
48721         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
48722         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
48723         return tag_ptr(ret_ret, true);
48724 }
48725
48726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48727         LDKChannelUpdateInfo this_obj_conv;
48728         this_obj_conv.inner = untag_ptr(this_obj);
48729         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48731         ChannelUpdateInfo_free(this_obj_conv);
48732 }
48733
48734 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
48735         LDKChannelUpdateInfo this_ptr_conv;
48736         this_ptr_conv.inner = untag_ptr(this_ptr);
48737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48739         this_ptr_conv.is_owned = false;
48740         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
48741         return ret_conv;
48742 }
48743
48744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48745         LDKChannelUpdateInfo this_ptr_conv;
48746         this_ptr_conv.inner = untag_ptr(this_ptr);
48747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48749         this_ptr_conv.is_owned = false;
48750         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
48751 }
48752
48753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
48754         LDKChannelUpdateInfo this_ptr_conv;
48755         this_ptr_conv.inner = untag_ptr(this_ptr);
48756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48758         this_ptr_conv.is_owned = false;
48759         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
48760         return ret_conv;
48761 }
48762
48763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
48764         LDKChannelUpdateInfo this_ptr_conv;
48765         this_ptr_conv.inner = untag_ptr(this_ptr);
48766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48768         this_ptr_conv.is_owned = false;
48769         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
48770 }
48771
48772 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48773         LDKChannelUpdateInfo this_ptr_conv;
48774         this_ptr_conv.inner = untag_ptr(this_ptr);
48775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48777         this_ptr_conv.is_owned = false;
48778         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
48779         return ret_conv;
48780 }
48781
48782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
48783         LDKChannelUpdateInfo this_ptr_conv;
48784         this_ptr_conv.inner = untag_ptr(this_ptr);
48785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48787         this_ptr_conv.is_owned = false;
48788         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
48789 }
48790
48791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48792         LDKChannelUpdateInfo this_ptr_conv;
48793         this_ptr_conv.inner = untag_ptr(this_ptr);
48794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48796         this_ptr_conv.is_owned = false;
48797         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
48798         return ret_conv;
48799 }
48800
48801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48802         LDKChannelUpdateInfo this_ptr_conv;
48803         this_ptr_conv.inner = untag_ptr(this_ptr);
48804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48806         this_ptr_conv.is_owned = false;
48807         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
48808 }
48809
48810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48811         LDKChannelUpdateInfo this_ptr_conv;
48812         this_ptr_conv.inner = untag_ptr(this_ptr);
48813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48815         this_ptr_conv.is_owned = false;
48816         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
48817         return ret_conv;
48818 }
48819
48820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48821         LDKChannelUpdateInfo this_ptr_conv;
48822         this_ptr_conv.inner = untag_ptr(this_ptr);
48823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48825         this_ptr_conv.is_owned = false;
48826         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
48827 }
48828
48829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
48830         LDKChannelUpdateInfo this_ptr_conv;
48831         this_ptr_conv.inner = untag_ptr(this_ptr);
48832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48834         this_ptr_conv.is_owned = false;
48835         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
48836         int64_t ret_ref = 0;
48837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48839         return ret_ref;
48840 }
48841
48842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48843         LDKChannelUpdateInfo this_ptr_conv;
48844         this_ptr_conv.inner = untag_ptr(this_ptr);
48845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48847         this_ptr_conv.is_owned = false;
48848         LDKRoutingFees val_conv;
48849         val_conv.inner = untag_ptr(val);
48850         val_conv.is_owned = ptr_is_owned(val);
48851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48852         val_conv = RoutingFees_clone(&val_conv);
48853         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
48854 }
48855
48856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
48857         LDKChannelUpdateInfo this_ptr_conv;
48858         this_ptr_conv.inner = untag_ptr(this_ptr);
48859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48861         this_ptr_conv.is_owned = false;
48862         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
48863         int64_t ret_ref = 0;
48864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48866         return ret_ref;
48867 }
48868
48869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48870         LDKChannelUpdateInfo this_ptr_conv;
48871         this_ptr_conv.inner = untag_ptr(this_ptr);
48872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48874         this_ptr_conv.is_owned = false;
48875         LDKChannelUpdate val_conv;
48876         val_conv.inner = untag_ptr(val);
48877         val_conv.is_owned = ptr_is_owned(val);
48878         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48879         val_conv = ChannelUpdate_clone(&val_conv);
48880         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
48881 }
48882
48883 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) {
48884         LDKRoutingFees fees_arg_conv;
48885         fees_arg_conv.inner = untag_ptr(fees_arg);
48886         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
48887         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
48888         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
48889         LDKChannelUpdate last_update_message_arg_conv;
48890         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
48891         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
48892         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
48893         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
48894         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);
48895         int64_t ret_ref = 0;
48896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48898         return ret_ref;
48899 }
48900
48901 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
48902         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
48903         int64_t ret_ref = 0;
48904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48906         return ret_ref;
48907 }
48908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48909         LDKChannelUpdateInfo arg_conv;
48910         arg_conv.inner = untag_ptr(arg);
48911         arg_conv.is_owned = ptr_is_owned(arg);
48912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48913         arg_conv.is_owned = false;
48914         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
48915         return ret_conv;
48916 }
48917
48918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48919         LDKChannelUpdateInfo orig_conv;
48920         orig_conv.inner = untag_ptr(orig);
48921         orig_conv.is_owned = ptr_is_owned(orig);
48922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48923         orig_conv.is_owned = false;
48924         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
48925         int64_t ret_ref = 0;
48926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48928         return ret_ref;
48929 }
48930
48931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48932         LDKChannelUpdateInfo a_conv;
48933         a_conv.inner = untag_ptr(a);
48934         a_conv.is_owned = ptr_is_owned(a);
48935         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48936         a_conv.is_owned = false;
48937         LDKChannelUpdateInfo b_conv;
48938         b_conv.inner = untag_ptr(b);
48939         b_conv.is_owned = ptr_is_owned(b);
48940         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48941         b_conv.is_owned = false;
48942         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
48943         return ret_conv;
48944 }
48945
48946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48947         LDKChannelUpdateInfo obj_conv;
48948         obj_conv.inner = untag_ptr(obj);
48949         obj_conv.is_owned = ptr_is_owned(obj);
48950         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48951         obj_conv.is_owned = false;
48952         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
48953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48955         CVec_u8Z_free(ret_var);
48956         return ret_arr;
48957 }
48958
48959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48960         LDKu8slice ser_ref;
48961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48963         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
48964         *ret_conv = ChannelUpdateInfo_read(ser_ref);
48965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48966         return tag_ptr(ret_conv, true);
48967 }
48968
48969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48970         LDKChannelInfo this_obj_conv;
48971         this_obj_conv.inner = untag_ptr(this_obj);
48972         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48974         ChannelInfo_free(this_obj_conv);
48975 }
48976
48977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48978         LDKChannelInfo this_ptr_conv;
48979         this_ptr_conv.inner = untag_ptr(this_ptr);
48980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48982         this_ptr_conv.is_owned = false;
48983         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
48984         int64_t ret_ref = 0;
48985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48987         return ret_ref;
48988 }
48989
48990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48991         LDKChannelInfo this_ptr_conv;
48992         this_ptr_conv.inner = untag_ptr(this_ptr);
48993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48995         this_ptr_conv.is_owned = false;
48996         LDKChannelFeatures val_conv;
48997         val_conv.inner = untag_ptr(val);
48998         val_conv.is_owned = ptr_is_owned(val);
48999         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49000         val_conv = ChannelFeatures_clone(&val_conv);
49001         ChannelInfo_set_features(&this_ptr_conv, val_conv);
49002 }
49003
49004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49005         LDKChannelInfo this_ptr_conv;
49006         this_ptr_conv.inner = untag_ptr(this_ptr);
49007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49009         this_ptr_conv.is_owned = false;
49010         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
49011         int64_t ret_ref = 0;
49012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49014         return ret_ref;
49015 }
49016
49017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49018         LDKChannelInfo this_ptr_conv;
49019         this_ptr_conv.inner = untag_ptr(this_ptr);
49020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49022         this_ptr_conv.is_owned = false;
49023         LDKNodeId val_conv;
49024         val_conv.inner = untag_ptr(val);
49025         val_conv.is_owned = ptr_is_owned(val);
49026         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49027         val_conv = NodeId_clone(&val_conv);
49028         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
49029 }
49030
49031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49032         LDKChannelInfo this_ptr_conv;
49033         this_ptr_conv.inner = untag_ptr(this_ptr);
49034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49036         this_ptr_conv.is_owned = false;
49037         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
49038         int64_t ret_ref = 0;
49039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49041         return ret_ref;
49042 }
49043
49044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49045         LDKChannelInfo this_ptr_conv;
49046         this_ptr_conv.inner = untag_ptr(this_ptr);
49047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49049         this_ptr_conv.is_owned = false;
49050         LDKChannelUpdateInfo val_conv;
49051         val_conv.inner = untag_ptr(val);
49052         val_conv.is_owned = ptr_is_owned(val);
49053         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49054         val_conv = ChannelUpdateInfo_clone(&val_conv);
49055         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
49056 }
49057
49058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49059         LDKChannelInfo this_ptr_conv;
49060         this_ptr_conv.inner = untag_ptr(this_ptr);
49061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49063         this_ptr_conv.is_owned = false;
49064         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
49065         int64_t ret_ref = 0;
49066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49068         return ret_ref;
49069 }
49070
49071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49072         LDKChannelInfo this_ptr_conv;
49073         this_ptr_conv.inner = untag_ptr(this_ptr);
49074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49076         this_ptr_conv.is_owned = false;
49077         LDKNodeId val_conv;
49078         val_conv.inner = untag_ptr(val);
49079         val_conv.is_owned = ptr_is_owned(val);
49080         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49081         val_conv = NodeId_clone(&val_conv);
49082         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
49083 }
49084
49085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49086         LDKChannelInfo this_ptr_conv;
49087         this_ptr_conv.inner = untag_ptr(this_ptr);
49088         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49090         this_ptr_conv.is_owned = false;
49091         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
49092         int64_t ret_ref = 0;
49093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49095         return ret_ref;
49096 }
49097
49098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49099         LDKChannelInfo this_ptr_conv;
49100         this_ptr_conv.inner = untag_ptr(this_ptr);
49101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49103         this_ptr_conv.is_owned = false;
49104         LDKChannelUpdateInfo val_conv;
49105         val_conv.inner = untag_ptr(val);
49106         val_conv.is_owned = ptr_is_owned(val);
49107         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49108         val_conv = ChannelUpdateInfo_clone(&val_conv);
49109         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
49110 }
49111
49112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
49113         LDKChannelInfo this_ptr_conv;
49114         this_ptr_conv.inner = untag_ptr(this_ptr);
49115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49117         this_ptr_conv.is_owned = false;
49118         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49119         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
49120         int64_t ret_ref = tag_ptr(ret_copy, true);
49121         return ret_ref;
49122 }
49123
49124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49125         LDKChannelInfo this_ptr_conv;
49126         this_ptr_conv.inner = untag_ptr(this_ptr);
49127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49129         this_ptr_conv.is_owned = false;
49130         void* val_ptr = untag_ptr(val);
49131         CHECK_ACCESS(val_ptr);
49132         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49133         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49134         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
49135 }
49136
49137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49138         LDKChannelInfo this_ptr_conv;
49139         this_ptr_conv.inner = untag_ptr(this_ptr);
49140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49142         this_ptr_conv.is_owned = false;
49143         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
49144         int64_t ret_ref = 0;
49145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49147         return ret_ref;
49148 }
49149
49150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49151         LDKChannelInfo this_ptr_conv;
49152         this_ptr_conv.inner = untag_ptr(this_ptr);
49153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49155         this_ptr_conv.is_owned = false;
49156         LDKChannelAnnouncement val_conv;
49157         val_conv.inner = untag_ptr(val);
49158         val_conv.is_owned = ptr_is_owned(val);
49159         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49160         val_conv = ChannelAnnouncement_clone(&val_conv);
49161         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
49162 }
49163
49164 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
49165         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
49166         int64_t ret_ref = 0;
49167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49169         return ret_ref;
49170 }
49171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49172         LDKChannelInfo arg_conv;
49173         arg_conv.inner = untag_ptr(arg);
49174         arg_conv.is_owned = ptr_is_owned(arg);
49175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49176         arg_conv.is_owned = false;
49177         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
49178         return ret_conv;
49179 }
49180
49181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49182         LDKChannelInfo orig_conv;
49183         orig_conv.inner = untag_ptr(orig);
49184         orig_conv.is_owned = ptr_is_owned(orig);
49185         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49186         orig_conv.is_owned = false;
49187         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
49188         int64_t ret_ref = 0;
49189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49191         return ret_ref;
49192 }
49193
49194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49195         LDKChannelInfo a_conv;
49196         a_conv.inner = untag_ptr(a);
49197         a_conv.is_owned = ptr_is_owned(a);
49198         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49199         a_conv.is_owned = false;
49200         LDKChannelInfo b_conv;
49201         b_conv.inner = untag_ptr(b);
49202         b_conv.is_owned = ptr_is_owned(b);
49203         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49204         b_conv.is_owned = false;
49205         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
49206         return ret_conv;
49207 }
49208
49209 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) {
49210         LDKChannelInfo this_arg_conv;
49211         this_arg_conv.inner = untag_ptr(this_arg);
49212         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49214         this_arg_conv.is_owned = false;
49215         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
49216         int64_t ret_ref = 0;
49217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49219         return ret_ref;
49220 }
49221
49222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49223         LDKChannelInfo obj_conv;
49224         obj_conv.inner = untag_ptr(obj);
49225         obj_conv.is_owned = ptr_is_owned(obj);
49226         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49227         obj_conv.is_owned = false;
49228         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
49229         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49230         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49231         CVec_u8Z_free(ret_var);
49232         return ret_arr;
49233 }
49234
49235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49236         LDKu8slice ser_ref;
49237         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49238         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49239         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
49240         *ret_conv = ChannelInfo_read(ser_ref);
49241         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49242         return tag_ptr(ret_conv, true);
49243 }
49244
49245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49246         LDKDirectedChannelInfo this_obj_conv;
49247         this_obj_conv.inner = untag_ptr(this_obj);
49248         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49250         DirectedChannelInfo_free(this_obj_conv);
49251 }
49252
49253 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
49254         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
49255         int64_t ret_ref = 0;
49256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49258         return ret_ref;
49259 }
49260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49261         LDKDirectedChannelInfo arg_conv;
49262         arg_conv.inner = untag_ptr(arg);
49263         arg_conv.is_owned = ptr_is_owned(arg);
49264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49265         arg_conv.is_owned = false;
49266         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
49267         return ret_conv;
49268 }
49269
49270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49271         LDKDirectedChannelInfo orig_conv;
49272         orig_conv.inner = untag_ptr(orig);
49273         orig_conv.is_owned = ptr_is_owned(orig);
49274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49275         orig_conv.is_owned = false;
49276         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
49277         int64_t ret_ref = 0;
49278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49280         return ret_ref;
49281 }
49282
49283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
49284         LDKDirectedChannelInfo this_arg_conv;
49285         this_arg_conv.inner = untag_ptr(this_arg);
49286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49288         this_arg_conv.is_owned = false;
49289         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
49290         int64_t ret_ref = 0;
49291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49293         return ret_ref;
49294 }
49295
49296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49297         LDKDirectedChannelInfo this_arg_conv;
49298         this_arg_conv.inner = untag_ptr(this_arg);
49299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49301         this_arg_conv.is_owned = false;
49302         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
49303         return ret_conv;
49304 }
49305
49306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
49307         LDKDirectedChannelInfo this_arg_conv;
49308         this_arg_conv.inner = untag_ptr(this_arg);
49309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49311         this_arg_conv.is_owned = false;
49312         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49313         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
49314         int64_t ret_ref = tag_ptr(ret_copy, true);
49315         return ret_ref;
49316 }
49317
49318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49319         if (!ptr_is_owned(this_ptr)) return;
49320         void* this_ptr_ptr = untag_ptr(this_ptr);
49321         CHECK_ACCESS(this_ptr_ptr);
49322         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
49323         FREE(untag_ptr(this_ptr));
49324         EffectiveCapacity_free(this_ptr_conv);
49325 }
49326
49327 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
49328         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49329         *ret_copy = EffectiveCapacity_clone(arg);
49330         int64_t ret_ref = tag_ptr(ret_copy, true);
49331         return ret_ref;
49332 }
49333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49334         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
49335         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
49336         return ret_conv;
49337 }
49338
49339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49340         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
49341         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49342         *ret_copy = EffectiveCapacity_clone(orig_conv);
49343         int64_t ret_ref = tag_ptr(ret_copy, true);
49344         return ret_ref;
49345 }
49346
49347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
49348         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49349         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
49350         int64_t ret_ref = tag_ptr(ret_copy, true);
49351         return ret_ref;
49352 }
49353
49354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
49355         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49356         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
49357         int64_t ret_ref = tag_ptr(ret_copy, true);
49358         return ret_ref;
49359 }
49360
49361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
49362         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49363         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
49364         int64_t ret_ref = tag_ptr(ret_copy, true);
49365         return ret_ref;
49366 }
49367
49368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
49369         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49370         *ret_copy = EffectiveCapacity_infinite();
49371         int64_t ret_ref = tag_ptr(ret_copy, true);
49372         return ret_ref;
49373 }
49374
49375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
49376         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49377         *ret_copy = EffectiveCapacity_unknown();
49378         int64_t ret_ref = tag_ptr(ret_copy, true);
49379         return ret_ref;
49380 }
49381
49382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49383         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
49384         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
49385         return ret_conv;
49386 }
49387
49388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49389         LDKRoutingFees this_obj_conv;
49390         this_obj_conv.inner = untag_ptr(this_obj);
49391         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49393         RoutingFees_free(this_obj_conv);
49394 }
49395
49396 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49397         LDKRoutingFees this_ptr_conv;
49398         this_ptr_conv.inner = untag_ptr(this_ptr);
49399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49401         this_ptr_conv.is_owned = false;
49402         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
49403         return ret_conv;
49404 }
49405
49406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49407         LDKRoutingFees this_ptr_conv;
49408         this_ptr_conv.inner = untag_ptr(this_ptr);
49409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49411         this_ptr_conv.is_owned = false;
49412         RoutingFees_set_base_msat(&this_ptr_conv, val);
49413 }
49414
49415 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
49416         LDKRoutingFees this_ptr_conv;
49417         this_ptr_conv.inner = untag_ptr(this_ptr);
49418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49420         this_ptr_conv.is_owned = false;
49421         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
49422         return ret_conv;
49423 }
49424
49425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49426         LDKRoutingFees this_ptr_conv;
49427         this_ptr_conv.inner = untag_ptr(this_ptr);
49428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49430         this_ptr_conv.is_owned = false;
49431         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
49432 }
49433
49434 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) {
49435         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
49436         int64_t ret_ref = 0;
49437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49439         return ret_ref;
49440 }
49441
49442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49443         LDKRoutingFees a_conv;
49444         a_conv.inner = untag_ptr(a);
49445         a_conv.is_owned = ptr_is_owned(a);
49446         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49447         a_conv.is_owned = false;
49448         LDKRoutingFees b_conv;
49449         b_conv.inner = untag_ptr(b);
49450         b_conv.is_owned = ptr_is_owned(b);
49451         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49452         b_conv.is_owned = false;
49453         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
49454         return ret_conv;
49455 }
49456
49457 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
49458         LDKRoutingFees ret_var = RoutingFees_clone(arg);
49459         int64_t ret_ref = 0;
49460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49462         return ret_ref;
49463 }
49464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49465         LDKRoutingFees arg_conv;
49466         arg_conv.inner = untag_ptr(arg);
49467         arg_conv.is_owned = ptr_is_owned(arg);
49468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49469         arg_conv.is_owned = false;
49470         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
49471         return ret_conv;
49472 }
49473
49474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49475         LDKRoutingFees orig_conv;
49476         orig_conv.inner = untag_ptr(orig);
49477         orig_conv.is_owned = ptr_is_owned(orig);
49478         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49479         orig_conv.is_owned = false;
49480         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
49481         int64_t ret_ref = 0;
49482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49484         return ret_ref;
49485 }
49486
49487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
49488         LDKRoutingFees o_conv;
49489         o_conv.inner = untag_ptr(o);
49490         o_conv.is_owned = ptr_is_owned(o);
49491         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49492         o_conv.is_owned = false;
49493         int64_t ret_conv = RoutingFees_hash(&o_conv);
49494         return ret_conv;
49495 }
49496
49497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
49498         LDKRoutingFees obj_conv;
49499         obj_conv.inner = untag_ptr(obj);
49500         obj_conv.is_owned = ptr_is_owned(obj);
49501         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49502         obj_conv.is_owned = false;
49503         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
49504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49506         CVec_u8Z_free(ret_var);
49507         return ret_arr;
49508 }
49509
49510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49511         LDKu8slice ser_ref;
49512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49514         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
49515         *ret_conv = RoutingFees_read(ser_ref);
49516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49517         return tag_ptr(ret_conv, true);
49518 }
49519
49520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49521         LDKNodeAnnouncementInfo this_obj_conv;
49522         this_obj_conv.inner = untag_ptr(this_obj);
49523         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49525         NodeAnnouncementInfo_free(this_obj_conv);
49526 }
49527
49528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49529         LDKNodeAnnouncementInfo this_ptr_conv;
49530         this_ptr_conv.inner = untag_ptr(this_ptr);
49531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49533         this_ptr_conv.is_owned = false;
49534         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
49535         int64_t ret_ref = 0;
49536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49538         return ret_ref;
49539 }
49540
49541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49542         LDKNodeAnnouncementInfo this_ptr_conv;
49543         this_ptr_conv.inner = untag_ptr(this_ptr);
49544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49546         this_ptr_conv.is_owned = false;
49547         LDKNodeFeatures val_conv;
49548         val_conv.inner = untag_ptr(val);
49549         val_conv.is_owned = ptr_is_owned(val);
49550         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49551         val_conv = NodeFeatures_clone(&val_conv);
49552         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
49553 }
49554
49555 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
49556         LDKNodeAnnouncementInfo this_ptr_conv;
49557         this_ptr_conv.inner = untag_ptr(this_ptr);
49558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49560         this_ptr_conv.is_owned = false;
49561         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
49562         return ret_conv;
49563 }
49564
49565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49566         LDKNodeAnnouncementInfo this_ptr_conv;
49567         this_ptr_conv.inner = untag_ptr(this_ptr);
49568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49570         this_ptr_conv.is_owned = false;
49571         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
49572 }
49573
49574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
49575         LDKNodeAnnouncementInfo this_ptr_conv;
49576         this_ptr_conv.inner = untag_ptr(this_ptr);
49577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49579         this_ptr_conv.is_owned = false;
49580         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
49581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
49582         return ret_arr;
49583 }
49584
49585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49586         LDKNodeAnnouncementInfo this_ptr_conv;
49587         this_ptr_conv.inner = untag_ptr(this_ptr);
49588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49590         this_ptr_conv.is_owned = false;
49591         LDKThreeBytes val_ref;
49592         CHECK((*env)->GetArrayLength(env, val) == 3);
49593         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
49594         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
49595 }
49596
49597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
49598         LDKNodeAnnouncementInfo this_ptr_conv;
49599         this_ptr_conv.inner = untag_ptr(this_ptr);
49600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49602         this_ptr_conv.is_owned = false;
49603         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
49604         int64_t ret_ref = 0;
49605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49607         return ret_ref;
49608 }
49609
49610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49611         LDKNodeAnnouncementInfo this_ptr_conv;
49612         this_ptr_conv.inner = untag_ptr(this_ptr);
49613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49615         this_ptr_conv.is_owned = false;
49616         LDKNodeAlias val_conv;
49617         val_conv.inner = untag_ptr(val);
49618         val_conv.is_owned = ptr_is_owned(val);
49619         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49620         val_conv = NodeAlias_clone(&val_conv);
49621         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
49622 }
49623
49624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49625         LDKNodeAnnouncementInfo this_ptr_conv;
49626         this_ptr_conv.inner = untag_ptr(this_ptr);
49627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49629         this_ptr_conv.is_owned = false;
49630         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
49631         int64_t ret_ref = 0;
49632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49634         return ret_ref;
49635 }
49636
49637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49638         LDKNodeAnnouncementInfo this_ptr_conv;
49639         this_ptr_conv.inner = untag_ptr(this_ptr);
49640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49642         this_ptr_conv.is_owned = false;
49643         LDKNodeAnnouncement val_conv;
49644         val_conv.inner = untag_ptr(val);
49645         val_conv.is_owned = ptr_is_owned(val);
49646         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49647         val_conv = NodeAnnouncement_clone(&val_conv);
49648         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
49649 }
49650
49651 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_t announcement_message_arg) {
49652         LDKNodeFeatures features_arg_conv;
49653         features_arg_conv.inner = untag_ptr(features_arg);
49654         features_arg_conv.is_owned = ptr_is_owned(features_arg);
49655         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
49656         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
49657         LDKThreeBytes rgb_arg_ref;
49658         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
49659         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
49660         LDKNodeAlias alias_arg_conv;
49661         alias_arg_conv.inner = untag_ptr(alias_arg);
49662         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
49663         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
49664         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
49665         LDKNodeAnnouncement announcement_message_arg_conv;
49666         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
49667         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
49668         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
49669         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
49670         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
49671         int64_t ret_ref = 0;
49672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49674         return ret_ref;
49675 }
49676
49677 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
49678         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
49679         int64_t ret_ref = 0;
49680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49682         return ret_ref;
49683 }
49684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49685         LDKNodeAnnouncementInfo arg_conv;
49686         arg_conv.inner = untag_ptr(arg);
49687         arg_conv.is_owned = ptr_is_owned(arg);
49688         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49689         arg_conv.is_owned = false;
49690         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
49691         return ret_conv;
49692 }
49693
49694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49695         LDKNodeAnnouncementInfo orig_conv;
49696         orig_conv.inner = untag_ptr(orig);
49697         orig_conv.is_owned = ptr_is_owned(orig);
49698         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49699         orig_conv.is_owned = false;
49700         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
49701         int64_t ret_ref = 0;
49702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49704         return ret_ref;
49705 }
49706
49707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49708         LDKNodeAnnouncementInfo a_conv;
49709         a_conv.inner = untag_ptr(a);
49710         a_conv.is_owned = ptr_is_owned(a);
49711         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49712         a_conv.is_owned = false;
49713         LDKNodeAnnouncementInfo b_conv;
49714         b_conv.inner = untag_ptr(b);
49715         b_conv.is_owned = ptr_is_owned(b);
49716         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49717         b_conv.is_owned = false;
49718         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
49719         return ret_conv;
49720 }
49721
49722 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
49723         LDKNodeAnnouncementInfo this_arg_conv;
49724         this_arg_conv.inner = untag_ptr(this_arg);
49725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49727         this_arg_conv.is_owned = false;
49728         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
49729         int64_tArray ret_arr = NULL;
49730         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49731         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49732         for (size_t m = 0; m < ret_var.datalen; m++) {
49733                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
49734                 *ret_conv_12_copy = ret_var.data[m];
49735                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
49736                 ret_arr_ptr[m] = ret_conv_12_ref;
49737         }
49738         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49739         FREE(ret_var.data);
49740         return ret_arr;
49741 }
49742
49743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49744         LDKNodeAnnouncementInfo obj_conv;
49745         obj_conv.inner = untag_ptr(obj);
49746         obj_conv.is_owned = ptr_is_owned(obj);
49747         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49748         obj_conv.is_owned = false;
49749         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
49750         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49751         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49752         CVec_u8Z_free(ret_var);
49753         return ret_arr;
49754 }
49755
49756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49757         LDKu8slice ser_ref;
49758         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49759         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49760         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
49761         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
49762         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49763         return tag_ptr(ret_conv, true);
49764 }
49765
49766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49767         LDKNodeAlias this_obj_conv;
49768         this_obj_conv.inner = untag_ptr(this_obj);
49769         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49771         NodeAlias_free(this_obj_conv);
49772 }
49773
49774 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49775         LDKNodeAlias this_ptr_conv;
49776         this_ptr_conv.inner = untag_ptr(this_ptr);
49777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49779         this_ptr_conv.is_owned = false;
49780         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
49782         return ret_arr;
49783 }
49784
49785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49786         LDKNodeAlias this_ptr_conv;
49787         this_ptr_conv.inner = untag_ptr(this_ptr);
49788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49790         this_ptr_conv.is_owned = false;
49791         LDKThirtyTwoBytes val_ref;
49792         CHECK((*env)->GetArrayLength(env, val) == 32);
49793         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
49794         NodeAlias_set_a(&this_ptr_conv, val_ref);
49795 }
49796
49797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
49798         LDKThirtyTwoBytes a_arg_ref;
49799         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
49800         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
49801         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
49802         int64_t ret_ref = 0;
49803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49805         return ret_ref;
49806 }
49807
49808 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
49809         LDKNodeAlias ret_var = NodeAlias_clone(arg);
49810         int64_t ret_ref = 0;
49811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49813         return ret_ref;
49814 }
49815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49816         LDKNodeAlias arg_conv;
49817         arg_conv.inner = untag_ptr(arg);
49818         arg_conv.is_owned = ptr_is_owned(arg);
49819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49820         arg_conv.is_owned = false;
49821         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
49822         return ret_conv;
49823 }
49824
49825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49826         LDKNodeAlias orig_conv;
49827         orig_conv.inner = untag_ptr(orig);
49828         orig_conv.is_owned = ptr_is_owned(orig);
49829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49830         orig_conv.is_owned = false;
49831         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
49832         int64_t ret_ref = 0;
49833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49835         return ret_ref;
49836 }
49837
49838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49839         LDKNodeAlias a_conv;
49840         a_conv.inner = untag_ptr(a);
49841         a_conv.is_owned = ptr_is_owned(a);
49842         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49843         a_conv.is_owned = false;
49844         LDKNodeAlias b_conv;
49845         b_conv.inner = untag_ptr(b);
49846         b_conv.is_owned = ptr_is_owned(b);
49847         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49848         b_conv.is_owned = false;
49849         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
49850         return ret_conv;
49851 }
49852
49853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
49854         LDKNodeAlias obj_conv;
49855         obj_conv.inner = untag_ptr(obj);
49856         obj_conv.is_owned = ptr_is_owned(obj);
49857         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49858         obj_conv.is_owned = false;
49859         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
49860         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49861         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49862         CVec_u8Z_free(ret_var);
49863         return ret_arr;
49864 }
49865
49866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49867         LDKu8slice ser_ref;
49868         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49869         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49870         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
49871         *ret_conv = NodeAlias_read(ser_ref);
49872         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49873         return tag_ptr(ret_conv, true);
49874 }
49875
49876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49877         LDKNodeInfo this_obj_conv;
49878         this_obj_conv.inner = untag_ptr(this_obj);
49879         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49881         NodeInfo_free(this_obj_conv);
49882 }
49883
49884 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
49885         LDKNodeInfo this_ptr_conv;
49886         this_ptr_conv.inner = untag_ptr(this_ptr);
49887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49889         this_ptr_conv.is_owned = false;
49890         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
49891         int64_tArray ret_arr = NULL;
49892         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49893         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49894         for (size_t g = 0; g < ret_var.datalen; g++) {
49895                 int64_t ret_conv_6_conv = ret_var.data[g];
49896                 ret_arr_ptr[g] = ret_conv_6_conv;
49897         }
49898         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49899         FREE(ret_var.data);
49900         return ret_arr;
49901 }
49902
49903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49904         LDKNodeInfo this_ptr_conv;
49905         this_ptr_conv.inner = untag_ptr(this_ptr);
49906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49908         this_ptr_conv.is_owned = false;
49909         LDKCVec_u64Z val_constr;
49910         val_constr.datalen = (*env)->GetArrayLength(env, val);
49911         if (val_constr.datalen > 0)
49912                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49913         else
49914                 val_constr.data = NULL;
49915         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49916         for (size_t g = 0; g < val_constr.datalen; g++) {
49917                 int64_t val_conv_6 = val_vals[g];
49918                 val_constr.data[g] = val_conv_6;
49919         }
49920         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49921         NodeInfo_set_channels(&this_ptr_conv, val_constr);
49922 }
49923
49924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
49925         LDKNodeInfo this_ptr_conv;
49926         this_ptr_conv.inner = untag_ptr(this_ptr);
49927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49929         this_ptr_conv.is_owned = false;
49930         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
49931         int64_t ret_ref = 0;
49932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49934         return ret_ref;
49935 }
49936
49937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49938         LDKNodeInfo this_ptr_conv;
49939         this_ptr_conv.inner = untag_ptr(this_ptr);
49940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49942         this_ptr_conv.is_owned = false;
49943         LDKNodeAnnouncementInfo val_conv;
49944         val_conv.inner = untag_ptr(val);
49945         val_conv.is_owned = ptr_is_owned(val);
49946         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49947         val_conv = NodeAnnouncementInfo_clone(&val_conv);
49948         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
49949 }
49950
49951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t announcement_info_arg) {
49952         LDKCVec_u64Z channels_arg_constr;
49953         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
49954         if (channels_arg_constr.datalen > 0)
49955                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49956         else
49957                 channels_arg_constr.data = NULL;
49958         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
49959         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
49960                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
49961                 channels_arg_constr.data[g] = channels_arg_conv_6;
49962         }
49963         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
49964         LDKNodeAnnouncementInfo announcement_info_arg_conv;
49965         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
49966         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
49967         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
49968         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
49969         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
49970         int64_t ret_ref = 0;
49971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49972         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49973         return ret_ref;
49974 }
49975
49976 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
49977         LDKNodeInfo ret_var = NodeInfo_clone(arg);
49978         int64_t ret_ref = 0;
49979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49981         return ret_ref;
49982 }
49983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49984         LDKNodeInfo arg_conv;
49985         arg_conv.inner = untag_ptr(arg);
49986         arg_conv.is_owned = ptr_is_owned(arg);
49987         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49988         arg_conv.is_owned = false;
49989         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
49990         return ret_conv;
49991 }
49992
49993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49994         LDKNodeInfo orig_conv;
49995         orig_conv.inner = untag_ptr(orig);
49996         orig_conv.is_owned = ptr_is_owned(orig);
49997         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49998         orig_conv.is_owned = false;
49999         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
50000         int64_t ret_ref = 0;
50001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50003         return ret_ref;
50004 }
50005
50006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50007         LDKNodeInfo a_conv;
50008         a_conv.inner = untag_ptr(a);
50009         a_conv.is_owned = ptr_is_owned(a);
50010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50011         a_conv.is_owned = false;
50012         LDKNodeInfo b_conv;
50013         b_conv.inner = untag_ptr(b);
50014         b_conv.is_owned = ptr_is_owned(b);
50015         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50016         b_conv.is_owned = false;
50017         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
50018         return ret_conv;
50019 }
50020
50021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
50022         LDKNodeInfo obj_conv;
50023         obj_conv.inner = untag_ptr(obj);
50024         obj_conv.is_owned = ptr_is_owned(obj);
50025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50026         obj_conv.is_owned = false;
50027         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
50028         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50029         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50030         CVec_u8Z_free(ret_var);
50031         return ret_arr;
50032 }
50033
50034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50035         LDKu8slice ser_ref;
50036         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50037         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50038         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
50039         *ret_conv = NodeInfo_read(ser_ref);
50040         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50041         return tag_ptr(ret_conv, true);
50042 }
50043
50044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
50045         LDKNetworkGraph obj_conv;
50046         obj_conv.inner = untag_ptr(obj);
50047         obj_conv.is_owned = ptr_is_owned(obj);
50048         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50049         obj_conv.is_owned = false;
50050         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
50051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50053         CVec_u8Z_free(ret_var);
50054         return ret_arr;
50055 }
50056
50057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
50058         LDKu8slice ser_ref;
50059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50061         void* arg_ptr = untag_ptr(arg);
50062         CHECK_ACCESS(arg_ptr);
50063         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
50064         if (arg_conv.free == LDKLogger_JCalls_free) {
50065                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50066                 LDKLogger_JCalls_cloned(&arg_conv);
50067         }
50068         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
50069         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
50070         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50071         return tag_ptr(ret_conv, true);
50072 }
50073
50074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, jclass network, int64_t logger) {
50075         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
50076         void* logger_ptr = untag_ptr(logger);
50077         CHECK_ACCESS(logger_ptr);
50078         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50079         if (logger_conv.free == LDKLogger_JCalls_free) {
50080                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50081                 LDKLogger_JCalls_cloned(&logger_conv);
50082         }
50083         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
50084         int64_t ret_ref = 0;
50085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50087         return ret_ref;
50088 }
50089
50090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
50091         LDKNetworkGraph this_arg_conv;
50092         this_arg_conv.inner = untag_ptr(this_arg);
50093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50095         this_arg_conv.is_owned = false;
50096         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
50097         int64_t ret_ref = 0;
50098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50100         return ret_ref;
50101 }
50102
50103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50104         LDKNetworkGraph this_arg_conv;
50105         this_arg_conv.inner = untag_ptr(this_arg);
50106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50108         this_arg_conv.is_owned = false;
50109         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
50110         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
50111         int64_t ret_ref = tag_ptr(ret_copy, true);
50112         return ret_ref;
50113 }
50114
50115 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) {
50116         LDKNetworkGraph this_arg_conv;
50117         this_arg_conv.inner = untag_ptr(this_arg);
50118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50120         this_arg_conv.is_owned = false;
50121         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
50122 }
50123
50124 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) {
50125         LDKNetworkGraph this_arg_conv;
50126         this_arg_conv.inner = untag_ptr(this_arg);
50127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50129         this_arg_conv.is_owned = false;
50130         LDKNodeAnnouncement msg_conv;
50131         msg_conv.inner = untag_ptr(msg);
50132         msg_conv.is_owned = ptr_is_owned(msg);
50133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50134         msg_conv.is_owned = false;
50135         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50136         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
50137         return tag_ptr(ret_conv, true);
50138 }
50139
50140 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) {
50141         LDKNetworkGraph this_arg_conv;
50142         this_arg_conv.inner = untag_ptr(this_arg);
50143         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50145         this_arg_conv.is_owned = false;
50146         LDKUnsignedNodeAnnouncement msg_conv;
50147         msg_conv.inner = untag_ptr(msg);
50148         msg_conv.is_owned = ptr_is_owned(msg);
50149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50150         msg_conv.is_owned = false;
50151         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50152         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
50153         return tag_ptr(ret_conv, true);
50154 }
50155
50156 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 utxo_lookup) {
50157         LDKNetworkGraph this_arg_conv;
50158         this_arg_conv.inner = untag_ptr(this_arg);
50159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50161         this_arg_conv.is_owned = false;
50162         LDKChannelAnnouncement msg_conv;
50163         msg_conv.inner = untag_ptr(msg);
50164         msg_conv.is_owned = ptr_is_owned(msg);
50165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50166         msg_conv.is_owned = false;
50167         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50168         CHECK_ACCESS(utxo_lookup_ptr);
50169         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50170         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50171         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50172                 // Manually implement clone for Java trait instances
50173                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50174                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50175                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50176                 }
50177         }
50178         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50179         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50180         return tag_ptr(ret_conv, true);
50181 }
50182
50183 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 utxo_lookup) {
50184         LDKNetworkGraph this_arg_conv;
50185         this_arg_conv.inner = untag_ptr(this_arg);
50186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50188         this_arg_conv.is_owned = false;
50189         LDKUnsignedChannelAnnouncement msg_conv;
50190         msg_conv.inner = untag_ptr(msg);
50191         msg_conv.is_owned = ptr_is_owned(msg);
50192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50193         msg_conv.is_owned = false;
50194         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50195         CHECK_ACCESS(utxo_lookup_ptr);
50196         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50197         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50198         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50199                 // Manually implement clone for Java trait instances
50200                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50201                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50202                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50203                 }
50204         }
50205         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50206         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50207         return tag_ptr(ret_conv, true);
50208 }
50209
50210 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) {
50211         LDKNetworkGraph this_arg_conv;
50212         this_arg_conv.inner = untag_ptr(this_arg);
50213         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50215         this_arg_conv.is_owned = false;
50216         LDKChannelFeatures features_conv;
50217         features_conv.inner = untag_ptr(features);
50218         features_conv.is_owned = ptr_is_owned(features);
50219         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
50220         features_conv = ChannelFeatures_clone(&features_conv);
50221         LDKPublicKey node_id_1_ref;
50222         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
50223         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
50224         LDKPublicKey node_id_2_ref;
50225         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
50226         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
50227         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50228         *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);
50229         return tag_ptr(ret_conv, true);
50230 }
50231
50232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50233         LDKNetworkGraph this_arg_conv;
50234         this_arg_conv.inner = untag_ptr(this_arg);
50235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50237         this_arg_conv.is_owned = false;
50238         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
50239 }
50240
50241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
50242         LDKNetworkGraph this_arg_conv;
50243         this_arg_conv.inner = untag_ptr(this_arg);
50244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50246         this_arg_conv.is_owned = false;
50247         LDKPublicKey node_id_ref;
50248         CHECK((*env)->GetArrayLength(env, node_id) == 33);
50249         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
50250         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
50251 }
50252
50253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
50254         LDKNetworkGraph this_arg_conv;
50255         this_arg_conv.inner = untag_ptr(this_arg);
50256         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50258         this_arg_conv.is_owned = false;
50259         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
50260 }
50261
50262 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) {
50263         LDKNetworkGraph this_arg_conv;
50264         this_arg_conv.inner = untag_ptr(this_arg);
50265         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50267         this_arg_conv.is_owned = false;
50268         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
50269 }
50270
50271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50272         LDKNetworkGraph this_arg_conv;
50273         this_arg_conv.inner = untag_ptr(this_arg);
50274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50276         this_arg_conv.is_owned = false;
50277         LDKChannelUpdate msg_conv;
50278         msg_conv.inner = untag_ptr(msg);
50279         msg_conv.is_owned = ptr_is_owned(msg);
50280         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50281         msg_conv.is_owned = false;
50282         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50283         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
50284         return tag_ptr(ret_conv, true);
50285 }
50286
50287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50288         LDKNetworkGraph this_arg_conv;
50289         this_arg_conv.inner = untag_ptr(this_arg);
50290         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50292         this_arg_conv.is_owned = false;
50293         LDKUnsignedChannelUpdate msg_conv;
50294         msg_conv.inner = untag_ptr(msg);
50295         msg_conv.is_owned = ptr_is_owned(msg);
50296         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50297         msg_conv.is_owned = false;
50298         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50299         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
50300         return tag_ptr(ret_conv, true);
50301 }
50302
50303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50304         LDKReadOnlyNetworkGraph this_arg_conv;
50305         this_arg_conv.inner = untag_ptr(this_arg);
50306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50308         this_arg_conv.is_owned = false;
50309         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
50310         int64_t ret_ref = 0;
50311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50313         return ret_ref;
50314 }
50315
50316 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
50317         LDKReadOnlyNetworkGraph this_arg_conv;
50318         this_arg_conv.inner = untag_ptr(this_arg);
50319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50321         this_arg_conv.is_owned = false;
50322         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
50323         int64_tArray ret_arr = NULL;
50324         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50325         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50326         for (size_t g = 0; g < ret_var.datalen; g++) {
50327                 int64_t ret_conv_6_conv = ret_var.data[g];
50328                 ret_arr_ptr[g] = ret_conv_6_conv;
50329         }
50330         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50331         FREE(ret_var.data);
50332         return ret_arr;
50333 }
50334
50335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50336         LDKReadOnlyNetworkGraph this_arg_conv;
50337         this_arg_conv.inner = untag_ptr(this_arg);
50338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50340         this_arg_conv.is_owned = false;
50341         LDKNodeId node_id_conv;
50342         node_id_conv.inner = untag_ptr(node_id);
50343         node_id_conv.is_owned = ptr_is_owned(node_id);
50344         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50345         node_id_conv.is_owned = false;
50346         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
50347         int64_t ret_ref = 0;
50348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50350         return ret_ref;
50351 }
50352
50353 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
50354         LDKReadOnlyNetworkGraph this_arg_conv;
50355         this_arg_conv.inner = untag_ptr(this_arg);
50356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50358         this_arg_conv.is_owned = false;
50359         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
50360         int64_tArray ret_arr = NULL;
50361         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50362         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50363         for (size_t i = 0; i < ret_var.datalen; i++) {
50364                 LDKNodeId ret_conv_8_var = ret_var.data[i];
50365                 int64_t ret_conv_8_ref = 0;
50366                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
50367                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
50368                 ret_arr_ptr[i] = ret_conv_8_ref;
50369         }
50370         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50371         FREE(ret_var.data);
50372         return ret_arr;
50373 }
50374
50375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
50376         LDKReadOnlyNetworkGraph this_arg_conv;
50377         this_arg_conv.inner = untag_ptr(this_arg);
50378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50380         this_arg_conv.is_owned = false;
50381         LDKPublicKey pubkey_ref;
50382         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
50383         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
50384         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
50385         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
50386         int64_t ret_ref = tag_ptr(ret_copy, true);
50387         return ret_ref;
50388 }
50389
50390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50391         LDKDefaultRouter this_obj_conv;
50392         this_obj_conv.inner = untag_ptr(this_obj);
50393         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50395         DefaultRouter_free(this_obj_conv);
50396 }
50397
50398 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) {
50399         LDKNetworkGraph network_graph_conv;
50400         network_graph_conv.inner = untag_ptr(network_graph);
50401         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50402         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50403         network_graph_conv.is_owned = false;
50404         void* logger_ptr = untag_ptr(logger);
50405         CHECK_ACCESS(logger_ptr);
50406         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50407         if (logger_conv.free == LDKLogger_JCalls_free) {
50408                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50409                 LDKLogger_JCalls_cloned(&logger_conv);
50410         }
50411         LDKThirtyTwoBytes random_seed_bytes_ref;
50412         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50413         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
50414         void* scorer_ptr = untag_ptr(scorer);
50415         CHECK_ACCESS(scorer_ptr);
50416         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
50417         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
50418                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50419                 LDKLockableScore_JCalls_cloned(&scorer_conv);
50420         }
50421         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
50422         int64_t ret_ref = 0;
50423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50425         return ret_ref;
50426 }
50427
50428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
50429         LDKDefaultRouter this_arg_conv;
50430         this_arg_conv.inner = untag_ptr(this_arg);
50431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50433         this_arg_conv.is_owned = false;
50434         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
50435         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
50436         return tag_ptr(ret_ret, true);
50437 }
50438
50439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50440         if (!ptr_is_owned(this_ptr)) return;
50441         void* this_ptr_ptr = untag_ptr(this_ptr);
50442         CHECK_ACCESS(this_ptr_ptr);
50443         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
50444         FREE(untag_ptr(this_ptr));
50445         Router_free(this_ptr_conv);
50446 }
50447
50448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50449         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
50450         this_obj_conv.inner = untag_ptr(this_obj);
50451         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50453         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
50454 }
50455
50456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
50457         void* scorer_ptr = untag_ptr(scorer);
50458         CHECK_ACCESS(scorer_ptr);
50459         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
50460         if (scorer_conv.free == LDKScore_JCalls_free) {
50461                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50462                 LDKScore_JCalls_cloned(&scorer_conv);
50463         }
50464         LDKInFlightHtlcs inflight_htlcs_conv;
50465         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
50466         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
50467         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
50468         inflight_htlcs_conv.is_owned = false;
50469         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
50470         int64_t ret_ref = 0;
50471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50473         return ret_ref;
50474 }
50475
50476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50477         LDKScorerAccountingForInFlightHtlcs obj_conv;
50478         obj_conv.inner = untag_ptr(obj);
50479         obj_conv.is_owned = ptr_is_owned(obj);
50480         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50481         obj_conv.is_owned = false;
50482         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
50483         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50484         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50485         CVec_u8Z_free(ret_var);
50486         return ret_arr;
50487 }
50488
50489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50490         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
50491         this_arg_conv.inner = untag_ptr(this_arg);
50492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50494         this_arg_conv.is_owned = false;
50495         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50496         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
50497         return tag_ptr(ret_ret, true);
50498 }
50499
50500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50501         LDKInFlightHtlcs this_obj_conv;
50502         this_obj_conv.inner = untag_ptr(this_obj);
50503         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50505         InFlightHtlcs_free(this_obj_conv);
50506 }
50507
50508 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
50509         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
50510         int64_t ret_ref = 0;
50511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50513         return ret_ref;
50514 }
50515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50516         LDKInFlightHtlcs arg_conv;
50517         arg_conv.inner = untag_ptr(arg);
50518         arg_conv.is_owned = ptr_is_owned(arg);
50519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50520         arg_conv.is_owned = false;
50521         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
50522         return ret_conv;
50523 }
50524
50525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50526         LDKInFlightHtlcs orig_conv;
50527         orig_conv.inner = untag_ptr(orig);
50528         orig_conv.is_owned = ptr_is_owned(orig);
50529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50530         orig_conv.is_owned = false;
50531         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
50532         int64_t ret_ref = 0;
50533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50535         return ret_ref;
50536 }
50537
50538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
50539         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
50540         int64_t ret_ref = 0;
50541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50543         return ret_ref;
50544 }
50545
50546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1process_1path(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int8_tArray payer_node_id) {
50547         LDKInFlightHtlcs this_arg_conv;
50548         this_arg_conv.inner = untag_ptr(this_arg);
50549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50551         this_arg_conv.is_owned = false;
50552         LDKPath path_conv;
50553         path_conv.inner = untag_ptr(path);
50554         path_conv.is_owned = ptr_is_owned(path);
50555         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
50556         path_conv.is_owned = false;
50557         LDKPublicKey payer_node_id_ref;
50558         CHECK((*env)->GetArrayLength(env, payer_node_id) == 33);
50559         (*env)->GetByteArrayRegion(env, payer_node_id, 0, 33, payer_node_id_ref.compressed_form);
50560         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
50561 }
50562
50563 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) {
50564         LDKInFlightHtlcs this_arg_conv;
50565         this_arg_conv.inner = untag_ptr(this_arg);
50566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50568         this_arg_conv.is_owned = false;
50569         LDKNodeId source_conv;
50570         source_conv.inner = untag_ptr(source);
50571         source_conv.is_owned = ptr_is_owned(source);
50572         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
50573         source_conv.is_owned = false;
50574         LDKNodeId target_conv;
50575         target_conv.inner = untag_ptr(target);
50576         target_conv.is_owned = ptr_is_owned(target);
50577         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50578         target_conv.is_owned = false;
50579         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50580         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
50581         int64_t ret_ref = tag_ptr(ret_copy, true);
50582         return ret_ref;
50583 }
50584
50585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50586         LDKInFlightHtlcs obj_conv;
50587         obj_conv.inner = untag_ptr(obj);
50588         obj_conv.is_owned = ptr_is_owned(obj);
50589         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50590         obj_conv.is_owned = false;
50591         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
50592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50594         CVec_u8Z_free(ret_var);
50595         return ret_arr;
50596 }
50597
50598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50599         LDKu8slice ser_ref;
50600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50602         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
50603         *ret_conv = InFlightHtlcs_read(ser_ref);
50604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50605         return tag_ptr(ret_conv, true);
50606 }
50607
50608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50609         LDKRouteHop this_obj_conv;
50610         this_obj_conv.inner = untag_ptr(this_obj);
50611         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50613         RouteHop_free(this_obj_conv);
50614 }
50615
50616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
50617         LDKRouteHop this_ptr_conv;
50618         this_ptr_conv.inner = untag_ptr(this_ptr);
50619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50621         this_ptr_conv.is_owned = false;
50622         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
50624         return ret_arr;
50625 }
50626
50627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50628         LDKRouteHop this_ptr_conv;
50629         this_ptr_conv.inner = untag_ptr(this_ptr);
50630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50632         this_ptr_conv.is_owned = false;
50633         LDKPublicKey val_ref;
50634         CHECK((*env)->GetArrayLength(env, val) == 33);
50635         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50636         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
50637 }
50638
50639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50640         LDKRouteHop this_ptr_conv;
50641         this_ptr_conv.inner = untag_ptr(this_ptr);
50642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50644         this_ptr_conv.is_owned = false;
50645         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
50646         int64_t ret_ref = 0;
50647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50649         return ret_ref;
50650 }
50651
50652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50653         LDKRouteHop this_ptr_conv;
50654         this_ptr_conv.inner = untag_ptr(this_ptr);
50655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50657         this_ptr_conv.is_owned = false;
50658         LDKNodeFeatures val_conv;
50659         val_conv.inner = untag_ptr(val);
50660         val_conv.is_owned = ptr_is_owned(val);
50661         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50662         val_conv = NodeFeatures_clone(&val_conv);
50663         RouteHop_set_node_features(&this_ptr_conv, val_conv);
50664 }
50665
50666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50667         LDKRouteHop this_ptr_conv;
50668         this_ptr_conv.inner = untag_ptr(this_ptr);
50669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50671         this_ptr_conv.is_owned = false;
50672         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
50673         return ret_conv;
50674 }
50675
50676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50677         LDKRouteHop this_ptr_conv;
50678         this_ptr_conv.inner = untag_ptr(this_ptr);
50679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50681         this_ptr_conv.is_owned = false;
50682         RouteHop_set_short_channel_id(&this_ptr_conv, val);
50683 }
50684
50685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50686         LDKRouteHop this_ptr_conv;
50687         this_ptr_conv.inner = untag_ptr(this_ptr);
50688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50690         this_ptr_conv.is_owned = false;
50691         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
50692         int64_t ret_ref = 0;
50693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50694         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50695         return ret_ref;
50696 }
50697
50698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50699         LDKRouteHop this_ptr_conv;
50700         this_ptr_conv.inner = untag_ptr(this_ptr);
50701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50703         this_ptr_conv.is_owned = false;
50704         LDKChannelFeatures val_conv;
50705         val_conv.inner = untag_ptr(val);
50706         val_conv.is_owned = ptr_is_owned(val);
50707         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50708         val_conv = ChannelFeatures_clone(&val_conv);
50709         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
50710 }
50711
50712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50713         LDKRouteHop this_ptr_conv;
50714         this_ptr_conv.inner = untag_ptr(this_ptr);
50715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50717         this_ptr_conv.is_owned = false;
50718         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
50719         return ret_conv;
50720 }
50721
50722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50723         LDKRouteHop this_ptr_conv;
50724         this_ptr_conv.inner = untag_ptr(this_ptr);
50725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50727         this_ptr_conv.is_owned = false;
50728         RouteHop_set_fee_msat(&this_ptr_conv, val);
50729 }
50730
50731 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50732         LDKRouteHop this_ptr_conv;
50733         this_ptr_conv.inner = untag_ptr(this_ptr);
50734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50736         this_ptr_conv.is_owned = false;
50737         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
50738         return ret_conv;
50739 }
50740
50741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50742         LDKRouteHop this_ptr_conv;
50743         this_ptr_conv.inner = untag_ptr(this_ptr);
50744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50746         this_ptr_conv.is_owned = false;
50747         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
50748 }
50749
50750 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) {
50751         LDKPublicKey pubkey_arg_ref;
50752         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
50753         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
50754         LDKNodeFeatures node_features_arg_conv;
50755         node_features_arg_conv.inner = untag_ptr(node_features_arg);
50756         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
50757         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
50758         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
50759         LDKChannelFeatures channel_features_arg_conv;
50760         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
50761         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
50762         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
50763         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
50764         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);
50765         int64_t ret_ref = 0;
50766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50768         return ret_ref;
50769 }
50770
50771 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
50772         LDKRouteHop ret_var = RouteHop_clone(arg);
50773         int64_t ret_ref = 0;
50774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50776         return ret_ref;
50777 }
50778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50779         LDKRouteHop arg_conv;
50780         arg_conv.inner = untag_ptr(arg);
50781         arg_conv.is_owned = ptr_is_owned(arg);
50782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50783         arg_conv.is_owned = false;
50784         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
50785         return ret_conv;
50786 }
50787
50788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50789         LDKRouteHop orig_conv;
50790         orig_conv.inner = untag_ptr(orig);
50791         orig_conv.is_owned = ptr_is_owned(orig);
50792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50793         orig_conv.is_owned = false;
50794         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
50795         int64_t ret_ref = 0;
50796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50798         return ret_ref;
50799 }
50800
50801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
50802         LDKRouteHop o_conv;
50803         o_conv.inner = untag_ptr(o);
50804         o_conv.is_owned = ptr_is_owned(o);
50805         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50806         o_conv.is_owned = false;
50807         int64_t ret_conv = RouteHop_hash(&o_conv);
50808         return ret_conv;
50809 }
50810
50811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50812         LDKRouteHop a_conv;
50813         a_conv.inner = untag_ptr(a);
50814         a_conv.is_owned = ptr_is_owned(a);
50815         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50816         a_conv.is_owned = false;
50817         LDKRouteHop b_conv;
50818         b_conv.inner = untag_ptr(b);
50819         b_conv.is_owned = ptr_is_owned(b);
50820         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50821         b_conv.is_owned = false;
50822         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
50823         return ret_conv;
50824 }
50825
50826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50827         LDKRouteHop obj_conv;
50828         obj_conv.inner = untag_ptr(obj);
50829         obj_conv.is_owned = ptr_is_owned(obj);
50830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50831         obj_conv.is_owned = false;
50832         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
50833         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50834         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50835         CVec_u8Z_free(ret_var);
50836         return ret_arr;
50837 }
50838
50839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50840         LDKu8slice ser_ref;
50841         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50842         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50843         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
50844         *ret_conv = RouteHop_read(ser_ref);
50845         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50846         return tag_ptr(ret_conv, true);
50847 }
50848
50849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50850         LDKBlindedTail this_obj_conv;
50851         this_obj_conv.inner = untag_ptr(this_obj);
50852         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50854         BlindedTail_free(this_obj_conv);
50855 }
50856
50857 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
50858         LDKBlindedTail this_ptr_conv;
50859         this_ptr_conv.inner = untag_ptr(this_ptr);
50860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50862         this_ptr_conv.is_owned = false;
50863         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
50864         int64_tArray ret_arr = NULL;
50865         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50866         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50867         for (size_t m = 0; m < ret_var.datalen; m++) {
50868                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
50869                 int64_t ret_conv_12_ref = 0;
50870                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
50871                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
50872                 ret_arr_ptr[m] = ret_conv_12_ref;
50873         }
50874         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50875         FREE(ret_var.data);
50876         return ret_arr;
50877 }
50878
50879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50880         LDKBlindedTail this_ptr_conv;
50881         this_ptr_conv.inner = untag_ptr(this_ptr);
50882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50884         this_ptr_conv.is_owned = false;
50885         LDKCVec_BlindedHopZ val_constr;
50886         val_constr.datalen = (*env)->GetArrayLength(env, val);
50887         if (val_constr.datalen > 0)
50888                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50889         else
50890                 val_constr.data = NULL;
50891         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50892         for (size_t m = 0; m < val_constr.datalen; m++) {
50893                 int64_t val_conv_12 = val_vals[m];
50894                 LDKBlindedHop val_conv_12_conv;
50895                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
50896                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
50897                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
50898                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
50899                 val_constr.data[m] = val_conv_12_conv;
50900         }
50901         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50902         BlindedTail_set_hops(&this_ptr_conv, val_constr);
50903 }
50904
50905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
50906         LDKBlindedTail this_ptr_conv;
50907         this_ptr_conv.inner = untag_ptr(this_ptr);
50908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50910         this_ptr_conv.is_owned = false;
50911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form);
50913         return ret_arr;
50914 }
50915
50916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50917         LDKBlindedTail this_ptr_conv;
50918         this_ptr_conv.inner = untag_ptr(this_ptr);
50919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50921         this_ptr_conv.is_owned = false;
50922         LDKPublicKey val_ref;
50923         CHECK((*env)->GetArrayLength(env, val) == 33);
50924         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50925         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
50926 }
50927
50928 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50929         LDKBlindedTail this_ptr_conv;
50930         this_ptr_conv.inner = untag_ptr(this_ptr);
50931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50933         this_ptr_conv.is_owned = false;
50934         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
50935         return ret_conv;
50936 }
50937
50938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50939         LDKBlindedTail this_ptr_conv;
50940         this_ptr_conv.inner = untag_ptr(this_ptr);
50941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50943         this_ptr_conv.is_owned = false;
50944         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
50945 }
50946
50947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50948         LDKBlindedTail this_ptr_conv;
50949         this_ptr_conv.inner = untag_ptr(this_ptr);
50950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50952         this_ptr_conv.is_owned = false;
50953         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
50954         return ret_conv;
50955 }
50956
50957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50958         LDKBlindedTail this_ptr_conv;
50959         this_ptr_conv.inner = untag_ptr(this_ptr);
50960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50962         this_ptr_conv.is_owned = false;
50963         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
50964 }
50965
50966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int8_tArray blinding_point_arg, int32_t excess_final_cltv_expiry_delta_arg, int64_t final_value_msat_arg) {
50967         LDKCVec_BlindedHopZ hops_arg_constr;
50968         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
50969         if (hops_arg_constr.datalen > 0)
50970                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50971         else
50972                 hops_arg_constr.data = NULL;
50973         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
50974         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
50975                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
50976                 LDKBlindedHop hops_arg_conv_12_conv;
50977                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
50978                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
50979                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
50980                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
50981                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
50982         }
50983         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
50984         LDKPublicKey blinding_point_arg_ref;
50985         CHECK((*env)->GetArrayLength(env, blinding_point_arg) == 33);
50986         (*env)->GetByteArrayRegion(env, blinding_point_arg, 0, 33, blinding_point_arg_ref.compressed_form);
50987         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
50988         int64_t ret_ref = 0;
50989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50991         return ret_ref;
50992 }
50993
50994 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
50995         LDKBlindedTail ret_var = BlindedTail_clone(arg);
50996         int64_t ret_ref = 0;
50997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50999         return ret_ref;
51000 }
51001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51002         LDKBlindedTail arg_conv;
51003         arg_conv.inner = untag_ptr(arg);
51004         arg_conv.is_owned = ptr_is_owned(arg);
51005         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51006         arg_conv.is_owned = false;
51007         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
51008         return ret_conv;
51009 }
51010
51011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51012         LDKBlindedTail orig_conv;
51013         orig_conv.inner = untag_ptr(orig);
51014         orig_conv.is_owned = ptr_is_owned(orig);
51015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51016         orig_conv.is_owned = false;
51017         LDKBlindedTail ret_var = BlindedTail_clone(&orig_conv);
51018         int64_t ret_ref = 0;
51019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51021         return ret_ref;
51022 }
51023
51024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1hash(JNIEnv *env, jclass clz, int64_t o) {
51025         LDKBlindedTail o_conv;
51026         o_conv.inner = untag_ptr(o);
51027         o_conv.is_owned = ptr_is_owned(o);
51028         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51029         o_conv.is_owned = false;
51030         int64_t ret_conv = BlindedTail_hash(&o_conv);
51031         return ret_conv;
51032 }
51033
51034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedTail_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51035         LDKBlindedTail a_conv;
51036         a_conv.inner = untag_ptr(a);
51037         a_conv.is_owned = ptr_is_owned(a);
51038         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51039         a_conv.is_owned = false;
51040         LDKBlindedTail b_conv;
51041         b_conv.inner = untag_ptr(b);
51042         b_conv.is_owned = ptr_is_owned(b);
51043         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51044         b_conv.is_owned = false;
51045         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
51046         return ret_conv;
51047 }
51048
51049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1write(JNIEnv *env, jclass clz, int64_t obj) {
51050         LDKBlindedTail obj_conv;
51051         obj_conv.inner = untag_ptr(obj);
51052         obj_conv.is_owned = ptr_is_owned(obj);
51053         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51054         obj_conv.is_owned = false;
51055         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
51056         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51057         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51058         CVec_u8Z_free(ret_var);
51059         return ret_arr;
51060 }
51061
51062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51063         LDKu8slice ser_ref;
51064         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51065         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51066         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
51067         *ret_conv = BlindedTail_read(ser_ref);
51068         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51069         return tag_ptr(ret_conv, true);
51070 }
51071
51072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51073         LDKPath this_obj_conv;
51074         this_obj_conv.inner = untag_ptr(this_obj);
51075         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51077         Path_free(this_obj_conv);
51078 }
51079
51080 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Path_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
51081         LDKPath this_ptr_conv;
51082         this_ptr_conv.inner = untag_ptr(this_ptr);
51083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51085         this_ptr_conv.is_owned = false;
51086         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
51087         int64_tArray ret_arr = NULL;
51088         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51089         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51090         for (size_t k = 0; k < ret_var.datalen; k++) {
51091                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
51092                 int64_t ret_conv_10_ref = 0;
51093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
51094                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
51095                 ret_arr_ptr[k] = ret_conv_10_ref;
51096         }
51097         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51098         FREE(ret_var.data);
51099         return ret_arr;
51100 }
51101
51102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51103         LDKPath this_ptr_conv;
51104         this_ptr_conv.inner = untag_ptr(this_ptr);
51105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51107         this_ptr_conv.is_owned = false;
51108         LDKCVec_RouteHopZ val_constr;
51109         val_constr.datalen = (*env)->GetArrayLength(env, val);
51110         if (val_constr.datalen > 0)
51111                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51112         else
51113                 val_constr.data = NULL;
51114         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51115         for (size_t k = 0; k < val_constr.datalen; k++) {
51116                 int64_t val_conv_10 = val_vals[k];
51117                 LDKRouteHop val_conv_10_conv;
51118                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
51119                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
51120                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
51121                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
51122                 val_constr.data[k] = val_conv_10_conv;
51123         }
51124         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51125         Path_set_hops(&this_ptr_conv, val_constr);
51126 }
51127
51128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1get_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr) {
51129         LDKPath this_ptr_conv;
51130         this_ptr_conv.inner = untag_ptr(this_ptr);
51131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51133         this_ptr_conv.is_owned = false;
51134         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
51135         int64_t ret_ref = 0;
51136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51138         return ret_ref;
51139 }
51140
51141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51142         LDKPath this_ptr_conv;
51143         this_ptr_conv.inner = untag_ptr(this_ptr);
51144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51146         this_ptr_conv.is_owned = false;
51147         LDKBlindedTail val_conv;
51148         val_conv.inner = untag_ptr(val);
51149         val_conv.is_owned = ptr_is_owned(val);
51150         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51151         val_conv = BlindedTail_clone(&val_conv);
51152         Path_set_blinded_tail(&this_ptr_conv, val_conv);
51153 }
51154
51155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int64_t blinded_tail_arg) {
51156         LDKCVec_RouteHopZ hops_arg_constr;
51157         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
51158         if (hops_arg_constr.datalen > 0)
51159                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51160         else
51161                 hops_arg_constr.data = NULL;
51162         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
51163         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
51164                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
51165                 LDKRouteHop hops_arg_conv_10_conv;
51166                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
51167                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
51168                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
51169                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
51170                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
51171         }
51172         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
51173         LDKBlindedTail blinded_tail_arg_conv;
51174         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
51175         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
51176         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
51177         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
51178         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
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
51185 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
51186         LDKPath ret_var = Path_clone(arg);
51187         int64_t ret_ref = 0;
51188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51190         return ret_ref;
51191 }
51192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51193         LDKPath arg_conv;
51194         arg_conv.inner = untag_ptr(arg);
51195         arg_conv.is_owned = ptr_is_owned(arg);
51196         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51197         arg_conv.is_owned = false;
51198         int64_t ret_conv = Path_clone_ptr(&arg_conv);
51199         return ret_conv;
51200 }
51201
51202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51203         LDKPath orig_conv;
51204         orig_conv.inner = untag_ptr(orig);
51205         orig_conv.is_owned = ptr_is_owned(orig);
51206         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51207         orig_conv.is_owned = false;
51208         LDKPath ret_var = Path_clone(&orig_conv);
51209         int64_t ret_ref = 0;
51210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51212         return ret_ref;
51213 }
51214
51215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1hash(JNIEnv *env, jclass clz, int64_t o) {
51216         LDKPath o_conv;
51217         o_conv.inner = untag_ptr(o);
51218         o_conv.is_owned = ptr_is_owned(o);
51219         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51220         o_conv.is_owned = false;
51221         int64_t ret_conv = Path_hash(&o_conv);
51222         return ret_conv;
51223 }
51224
51225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Path_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51226         LDKPath 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         LDKPath 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 = Path_eq(&a_conv, &b_conv);
51237         return ret_conv;
51238 }
51239
51240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51241         LDKPath this_arg_conv;
51242         this_arg_conv.inner = untag_ptr(this_arg);
51243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51245         this_arg_conv.is_owned = false;
51246         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
51247         return ret_conv;
51248 }
51249
51250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51251         LDKPath this_arg_conv;
51252         this_arg_conv.inner = untag_ptr(this_arg);
51253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51255         this_arg_conv.is_owned = false;
51256         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
51257         return ret_conv;
51258 }
51259
51260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
51261         LDKPath this_arg_conv;
51262         this_arg_conv.inner = untag_ptr(this_arg);
51263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51265         this_arg_conv.is_owned = false;
51266         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
51267         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
51268         int64_t ret_ref = tag_ptr(ret_copy, true);
51269         return ret_ref;
51270 }
51271
51272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51273         LDKRoute this_obj_conv;
51274         this_obj_conv.inner = untag_ptr(this_obj);
51275         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51277         Route_free(this_obj_conv);
51278 }
51279
51280 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
51281         LDKRoute this_ptr_conv;
51282         this_ptr_conv.inner = untag_ptr(this_ptr);
51283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51285         this_ptr_conv.is_owned = false;
51286         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
51287         int64_tArray ret_arr = NULL;
51288         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51289         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51290         for (size_t g = 0; g < ret_var.datalen; g++) {
51291                 LDKPath ret_conv_6_var = ret_var.data[g];
51292                 int64_t ret_conv_6_ref = 0;
51293                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
51294                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
51295                 ret_arr_ptr[g] = ret_conv_6_ref;
51296         }
51297         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51298         FREE(ret_var.data);
51299         return ret_arr;
51300 }
51301
51302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51303         LDKRoute this_ptr_conv;
51304         this_ptr_conv.inner = untag_ptr(this_ptr);
51305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51307         this_ptr_conv.is_owned = false;
51308         LDKCVec_PathZ val_constr;
51309         val_constr.datalen = (*env)->GetArrayLength(env, val);
51310         if (val_constr.datalen > 0)
51311                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51312         else
51313                 val_constr.data = NULL;
51314         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51315         for (size_t g = 0; g < val_constr.datalen; g++) {
51316                 int64_t val_conv_6 = val_vals[g];
51317                 LDKPath val_conv_6_conv;
51318                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
51319                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
51320                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
51321                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
51322                 val_constr.data[g] = val_conv_6_conv;
51323         }
51324         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51325         Route_set_paths(&this_ptr_conv, val_constr);
51326 }
51327
51328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51329         LDKRoute this_ptr_conv;
51330         this_ptr_conv.inner = untag_ptr(this_ptr);
51331         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51333         this_ptr_conv.is_owned = false;
51334         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
51335         int64_t ret_ref = 0;
51336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51338         return ret_ref;
51339 }
51340
51341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51342         LDKRoute this_ptr_conv;
51343         this_ptr_conv.inner = untag_ptr(this_ptr);
51344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51346         this_ptr_conv.is_owned = false;
51347         LDKPaymentParameters val_conv;
51348         val_conv.inner = untag_ptr(val);
51349         val_conv.is_owned = ptr_is_owned(val);
51350         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51351         val_conv = PaymentParameters_clone(&val_conv);
51352         Route_set_payment_params(&this_ptr_conv, val_conv);
51353 }
51354
51355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, int64_tArray paths_arg, int64_t payment_params_arg) {
51356         LDKCVec_PathZ paths_arg_constr;
51357         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
51358         if (paths_arg_constr.datalen > 0)
51359                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51360         else
51361                 paths_arg_constr.data = NULL;
51362         int64_t* paths_arg_vals = (*env)->GetLongArrayElements (env, paths_arg, NULL);
51363         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
51364                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
51365                 LDKPath paths_arg_conv_6_conv;
51366                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
51367                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
51368                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
51369                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
51370                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
51371         }
51372         (*env)->ReleaseLongArrayElements(env, paths_arg, paths_arg_vals, 0);
51373         LDKPaymentParameters payment_params_arg_conv;
51374         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51375         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51376         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51377         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51378         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
51379         int64_t ret_ref = 0;
51380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51382         return ret_ref;
51383 }
51384
51385 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
51386         LDKRoute ret_var = Route_clone(arg);
51387         int64_t ret_ref = 0;
51388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51390         return ret_ref;
51391 }
51392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51393         LDKRoute arg_conv;
51394         arg_conv.inner = untag_ptr(arg);
51395         arg_conv.is_owned = ptr_is_owned(arg);
51396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51397         arg_conv.is_owned = false;
51398         int64_t ret_conv = Route_clone_ptr(&arg_conv);
51399         return ret_conv;
51400 }
51401
51402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51403         LDKRoute orig_conv;
51404         orig_conv.inner = untag_ptr(orig);
51405         orig_conv.is_owned = ptr_is_owned(orig);
51406         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51407         orig_conv.is_owned = false;
51408         LDKRoute ret_var = Route_clone(&orig_conv);
51409         int64_t ret_ref = 0;
51410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51412         return ret_ref;
51413 }
51414
51415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
51416         LDKRoute o_conv;
51417         o_conv.inner = untag_ptr(o);
51418         o_conv.is_owned = ptr_is_owned(o);
51419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51420         o_conv.is_owned = false;
51421         int64_t ret_conv = Route_hash(&o_conv);
51422         return ret_conv;
51423 }
51424
51425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51426         LDKRoute a_conv;
51427         a_conv.inner = untag_ptr(a);
51428         a_conv.is_owned = ptr_is_owned(a);
51429         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51430         a_conv.is_owned = false;
51431         LDKRoute b_conv;
51432         b_conv.inner = untag_ptr(b);
51433         b_conv.is_owned = ptr_is_owned(b);
51434         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51435         b_conv.is_owned = false;
51436         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
51437         return ret_conv;
51438 }
51439
51440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
51441         LDKRoute this_arg_conv;
51442         this_arg_conv.inner = untag_ptr(this_arg);
51443         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51445         this_arg_conv.is_owned = false;
51446         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
51447         return ret_conv;
51448 }
51449
51450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
51451         LDKRoute this_arg_conv;
51452         this_arg_conv.inner = untag_ptr(this_arg);
51453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51455         this_arg_conv.is_owned = false;
51456         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
51457         return ret_conv;
51458 }
51459
51460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
51461         LDKRoute obj_conv;
51462         obj_conv.inner = untag_ptr(obj);
51463         obj_conv.is_owned = ptr_is_owned(obj);
51464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51465         obj_conv.is_owned = false;
51466         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
51467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51469         CVec_u8Z_free(ret_var);
51470         return ret_arr;
51471 }
51472
51473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51474         LDKu8slice ser_ref;
51475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51477         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
51478         *ret_conv = Route_read(ser_ref);
51479         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51480         return tag_ptr(ret_conv, true);
51481 }
51482
51483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51484         LDKRouteParameters this_obj_conv;
51485         this_obj_conv.inner = untag_ptr(this_obj);
51486         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51488         RouteParameters_free(this_obj_conv);
51489 }
51490
51491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51492         LDKRouteParameters this_ptr_conv;
51493         this_ptr_conv.inner = untag_ptr(this_ptr);
51494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51496         this_ptr_conv.is_owned = false;
51497         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
51498         int64_t ret_ref = 0;
51499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51500         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51501         return ret_ref;
51502 }
51503
51504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51505         LDKRouteParameters this_ptr_conv;
51506         this_ptr_conv.inner = untag_ptr(this_ptr);
51507         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51509         this_ptr_conv.is_owned = false;
51510         LDKPaymentParameters val_conv;
51511         val_conv.inner = untag_ptr(val);
51512         val_conv.is_owned = ptr_is_owned(val);
51513         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51514         val_conv = PaymentParameters_clone(&val_conv);
51515         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
51516 }
51517
51518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51519         LDKRouteParameters this_ptr_conv;
51520         this_ptr_conv.inner = untag_ptr(this_ptr);
51521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51523         this_ptr_conv.is_owned = false;
51524         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
51525         return ret_conv;
51526 }
51527
51528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51529         LDKRouteParameters this_ptr_conv;
51530         this_ptr_conv.inner = untag_ptr(this_ptr);
51531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51533         this_ptr_conv.is_owned = false;
51534         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
51535 }
51536
51537 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) {
51538         LDKPaymentParameters payment_params_arg_conv;
51539         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51540         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51541         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51542         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51543         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg);
51544         int64_t ret_ref = 0;
51545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51546         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51547         return ret_ref;
51548 }
51549
51550 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
51551         LDKRouteParameters ret_var = RouteParameters_clone(arg);
51552         int64_t ret_ref = 0;
51553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51555         return ret_ref;
51556 }
51557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51558         LDKRouteParameters arg_conv;
51559         arg_conv.inner = untag_ptr(arg);
51560         arg_conv.is_owned = ptr_is_owned(arg);
51561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51562         arg_conv.is_owned = false;
51563         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
51564         return ret_conv;
51565 }
51566
51567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51568         LDKRouteParameters orig_conv;
51569         orig_conv.inner = untag_ptr(orig);
51570         orig_conv.is_owned = ptr_is_owned(orig);
51571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51572         orig_conv.is_owned = false;
51573         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
51574         int64_t ret_ref = 0;
51575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51577         return ret_ref;
51578 }
51579
51580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51581         LDKRouteParameters a_conv;
51582         a_conv.inner = untag_ptr(a);
51583         a_conv.is_owned = ptr_is_owned(a);
51584         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51585         a_conv.is_owned = false;
51586         LDKRouteParameters b_conv;
51587         b_conv.inner = untag_ptr(b);
51588         b_conv.is_owned = ptr_is_owned(b);
51589         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51590         b_conv.is_owned = false;
51591         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
51592         return ret_conv;
51593 }
51594
51595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51596         LDKRouteParameters obj_conv;
51597         obj_conv.inner = untag_ptr(obj);
51598         obj_conv.is_owned = ptr_is_owned(obj);
51599         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51600         obj_conv.is_owned = false;
51601         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
51602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51604         CVec_u8Z_free(ret_var);
51605         return ret_arr;
51606 }
51607
51608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51609         LDKu8slice ser_ref;
51610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51612         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
51613         *ret_conv = RouteParameters_read(ser_ref);
51614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51615         return tag_ptr(ret_conv, true);
51616 }
51617
51618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51619         LDKPaymentParameters this_obj_conv;
51620         this_obj_conv.inner = untag_ptr(this_obj);
51621         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51623         PaymentParameters_free(this_obj_conv);
51624 }
51625
51626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
51627         LDKPaymentParameters this_ptr_conv;
51628         this_ptr_conv.inner = untag_ptr(this_ptr);
51629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51631         this_ptr_conv.is_owned = false;
51632         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
51634         return ret_arr;
51635 }
51636
51637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51638         LDKPaymentParameters this_ptr_conv;
51639         this_ptr_conv.inner = untag_ptr(this_ptr);
51640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51642         this_ptr_conv.is_owned = false;
51643         LDKPublicKey val_ref;
51644         CHECK((*env)->GetArrayLength(env, val) == 33);
51645         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51646         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
51647 }
51648
51649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
51650         LDKPaymentParameters this_ptr_conv;
51651         this_ptr_conv.inner = untag_ptr(this_ptr);
51652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51654         this_ptr_conv.is_owned = false;
51655         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
51656         int64_t ret_ref = 0;
51657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51659         return ret_ref;
51660 }
51661
51662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51663         LDKPaymentParameters this_ptr_conv;
51664         this_ptr_conv.inner = untag_ptr(this_ptr);
51665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51667         this_ptr_conv.is_owned = false;
51668         LDKInvoiceFeatures val_conv;
51669         val_conv.inner = untag_ptr(val);
51670         val_conv.is_owned = ptr_is_owned(val);
51671         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51672         val_conv = InvoiceFeatures_clone(&val_conv);
51673         PaymentParameters_set_features(&this_ptr_conv, val_conv);
51674 }
51675
51676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
51677         LDKPaymentParameters this_ptr_conv;
51678         this_ptr_conv.inner = untag_ptr(this_ptr);
51679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51681         this_ptr_conv.is_owned = false;
51682         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51683         *ret_copy = PaymentParameters_get_route_hints(&this_ptr_conv);
51684         int64_t ret_ref = tag_ptr(ret_copy, true);
51685         return ret_ref;
51686 }
51687
51688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51689         LDKPaymentParameters this_ptr_conv;
51690         this_ptr_conv.inner = untag_ptr(this_ptr);
51691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51693         this_ptr_conv.is_owned = false;
51694         void* val_ptr = untag_ptr(val);
51695         CHECK_ACCESS(val_ptr);
51696         LDKHints val_conv = *(LDKHints*)(val_ptr);
51697         val_conv = Hints_clone((LDKHints*)untag_ptr(val));
51698         PaymentParameters_set_route_hints(&this_ptr_conv, val_conv);
51699 }
51700
51701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
51702         LDKPaymentParameters this_ptr_conv;
51703         this_ptr_conv.inner = untag_ptr(this_ptr);
51704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51706         this_ptr_conv.is_owned = false;
51707         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51708         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
51709         int64_t ret_ref = tag_ptr(ret_copy, true);
51710         return ret_ref;
51711 }
51712
51713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51714         LDKPaymentParameters this_ptr_conv;
51715         this_ptr_conv.inner = untag_ptr(this_ptr);
51716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51718         this_ptr_conv.is_owned = false;
51719         void* val_ptr = untag_ptr(val);
51720         CHECK_ACCESS(val_ptr);
51721         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
51722         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
51723         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
51724 }
51725
51726 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51727         LDKPaymentParameters this_ptr_conv;
51728         this_ptr_conv.inner = untag_ptr(this_ptr);
51729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51731         this_ptr_conv.is_owned = false;
51732         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
51733         return ret_conv;
51734 }
51735
51736 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) {
51737         LDKPaymentParameters this_ptr_conv;
51738         this_ptr_conv.inner = untag_ptr(this_ptr);
51739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51741         this_ptr_conv.is_owned = false;
51742         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
51743 }
51744
51745 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
51746         LDKPaymentParameters this_ptr_conv;
51747         this_ptr_conv.inner = untag_ptr(this_ptr);
51748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51750         this_ptr_conv.is_owned = false;
51751         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
51752         return ret_conv;
51753 }
51754
51755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
51756         LDKPaymentParameters this_ptr_conv;
51757         this_ptr_conv.inner = untag_ptr(this_ptr);
51758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51760         this_ptr_conv.is_owned = false;
51761         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
51762 }
51763
51764 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) {
51765         LDKPaymentParameters this_ptr_conv;
51766         this_ptr_conv.inner = untag_ptr(this_ptr);
51767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51769         this_ptr_conv.is_owned = false;
51770         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
51771         return ret_conv;
51772 }
51773
51774 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) {
51775         LDKPaymentParameters this_ptr_conv;
51776         this_ptr_conv.inner = untag_ptr(this_ptr);
51777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51779         this_ptr_conv.is_owned = false;
51780         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
51781 }
51782
51783 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
51784         LDKPaymentParameters this_ptr_conv;
51785         this_ptr_conv.inner = untag_ptr(this_ptr);
51786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51788         this_ptr_conv.is_owned = false;
51789         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
51790         int64_tArray ret_arr = NULL;
51791         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51792         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51793         for (size_t g = 0; g < ret_var.datalen; g++) {
51794                 int64_t ret_conv_6_conv = ret_var.data[g];
51795                 ret_arr_ptr[g] = ret_conv_6_conv;
51796         }
51797         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51798         FREE(ret_var.data);
51799         return ret_arr;
51800 }
51801
51802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51803         LDKPaymentParameters this_ptr_conv;
51804         this_ptr_conv.inner = untag_ptr(this_ptr);
51805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51807         this_ptr_conv.is_owned = false;
51808         LDKCVec_u64Z val_constr;
51809         val_constr.datalen = (*env)->GetArrayLength(env, val);
51810         if (val_constr.datalen > 0)
51811                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51812         else
51813                 val_constr.data = NULL;
51814         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51815         for (size_t g = 0; g < val_constr.datalen; g++) {
51816                 int64_t val_conv_6 = val_vals[g];
51817                 val_constr.data[g] = val_conv_6;
51818         }
51819         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51820         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
51821 }
51822
51823 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51824         LDKPaymentParameters this_ptr_conv;
51825         this_ptr_conv.inner = untag_ptr(this_ptr);
51826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51828         this_ptr_conv.is_owned = false;
51829         int32_t ret_conv = PaymentParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
51830         return ret_conv;
51831 }
51832
51833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
51834         LDKPaymentParameters this_ptr_conv;
51835         this_ptr_conv.inner = untag_ptr(this_ptr);
51836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51838         this_ptr_conv.is_owned = false;
51839         PaymentParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
51840 }
51841
51842 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_t 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, int32_t final_cltv_expiry_delta_arg) {
51843         LDKPublicKey payee_pubkey_arg_ref;
51844         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
51845         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
51846         LDKInvoiceFeatures features_arg_conv;
51847         features_arg_conv.inner = untag_ptr(features_arg);
51848         features_arg_conv.is_owned = ptr_is_owned(features_arg);
51849         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
51850         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
51851         void* route_hints_arg_ptr = untag_ptr(route_hints_arg);
51852         CHECK_ACCESS(route_hints_arg_ptr);
51853         LDKHints route_hints_arg_conv = *(LDKHints*)(route_hints_arg_ptr);
51854         route_hints_arg_conv = Hints_clone((LDKHints*)untag_ptr(route_hints_arg));
51855         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
51856         CHECK_ACCESS(expiry_time_arg_ptr);
51857         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
51858         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
51859         LDKCVec_u64Z previously_failed_channels_arg_constr;
51860         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
51861         if (previously_failed_channels_arg_constr.datalen > 0)
51862                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51863         else
51864                 previously_failed_channels_arg_constr.data = NULL;
51865         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
51866         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
51867                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
51868                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
51869         }
51870         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
51871         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_conv, 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, final_cltv_expiry_delta_arg);
51872         int64_t ret_ref = 0;
51873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51875         return ret_ref;
51876 }
51877
51878 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
51879         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
51880         int64_t ret_ref = 0;
51881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51883         return ret_ref;
51884 }
51885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51886         LDKPaymentParameters arg_conv;
51887         arg_conv.inner = untag_ptr(arg);
51888         arg_conv.is_owned = ptr_is_owned(arg);
51889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51890         arg_conv.is_owned = false;
51891         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
51892         return ret_conv;
51893 }
51894
51895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51896         LDKPaymentParameters orig_conv;
51897         orig_conv.inner = untag_ptr(orig);
51898         orig_conv.is_owned = ptr_is_owned(orig);
51899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51900         orig_conv.is_owned = false;
51901         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
51902         int64_t ret_ref = 0;
51903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51905         return ret_ref;
51906 }
51907
51908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
51909         LDKPaymentParameters o_conv;
51910         o_conv.inner = untag_ptr(o);
51911         o_conv.is_owned = ptr_is_owned(o);
51912         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51913         o_conv.is_owned = false;
51914         int64_t ret_conv = PaymentParameters_hash(&o_conv);
51915         return ret_conv;
51916 }
51917
51918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51919         LDKPaymentParameters a_conv;
51920         a_conv.inner = untag_ptr(a);
51921         a_conv.is_owned = ptr_is_owned(a);
51922         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51923         a_conv.is_owned = false;
51924         LDKPaymentParameters b_conv;
51925         b_conv.inner = untag_ptr(b);
51926         b_conv.is_owned = ptr_is_owned(b);
51927         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51928         b_conv.is_owned = false;
51929         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
51930         return ret_conv;
51931 }
51932
51933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51934         LDKPaymentParameters obj_conv;
51935         obj_conv.inner = untag_ptr(obj);
51936         obj_conv.is_owned = ptr_is_owned(obj);
51937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51938         obj_conv.is_owned = false;
51939         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
51940         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51941         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51942         CVec_u8Z_free(ret_var);
51943         return ret_arr;
51944 }
51945
51946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser, int32_t arg) {
51947         LDKu8slice ser_ref;
51948         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51949         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51950         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
51951         *ret_conv = PaymentParameters_read(ser_ref, arg);
51952         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51953         return tag_ptr(ret_conv, true);
51954 }
51955
51956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta) {
51957         LDKPublicKey payee_pubkey_ref;
51958         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51959         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51960         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
51961         int64_t ret_ref = 0;
51962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51964         return ret_ref;
51965 }
51966
51967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta) {
51968         LDKPublicKey payee_pubkey_ref;
51969         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51970         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51971         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta);
51972         int64_t ret_ref = 0;
51973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51975         return ret_ref;
51976 }
51977
51978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hints_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51979         if (!ptr_is_owned(this_ptr)) return;
51980         void* this_ptr_ptr = untag_ptr(this_ptr);
51981         CHECK_ACCESS(this_ptr_ptr);
51982         LDKHints this_ptr_conv = *(LDKHints*)(this_ptr_ptr);
51983         FREE(untag_ptr(this_ptr));
51984         Hints_free(this_ptr_conv);
51985 }
51986
51987 static inline uint64_t Hints_clone_ptr(LDKHints *NONNULL_PTR arg) {
51988         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51989         *ret_copy = Hints_clone(arg);
51990         int64_t ret_ref = tag_ptr(ret_copy, true);
51991         return ret_ref;
51992 }
51993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51994         LDKHints* arg_conv = (LDKHints*)untag_ptr(arg);
51995         int64_t ret_conv = Hints_clone_ptr(arg_conv);
51996         return ret_conv;
51997 }
51998
51999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52000         LDKHints* orig_conv = (LDKHints*)untag_ptr(orig);
52001         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52002         *ret_copy = Hints_clone(orig_conv);
52003         int64_t ret_ref = tag_ptr(ret_copy, true);
52004         return ret_ref;
52005 }
52006
52007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1blinded(JNIEnv *env, jclass clz, int64_tArray a) {
52008         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a_constr;
52009         a_constr.datalen = (*env)->GetArrayLength(env, a);
52010         if (a_constr.datalen > 0)
52011                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
52012         else
52013                 a_constr.data = NULL;
52014         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52015         for (size_t l = 0; l < a_constr.datalen; l++) {
52016                 int64_t a_conv_37 = a_vals[l];
52017                 void* a_conv_37_ptr = untag_ptr(a_conv_37);
52018                 CHECK_ACCESS(a_conv_37_ptr);
52019                 LDKC2Tuple_BlindedPayInfoBlindedPathZ a_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(a_conv_37_ptr);
52020                 a_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(a_conv_37));
52021                 a_constr.data[l] = a_conv_37_conv;
52022         }
52023         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52024         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52025         *ret_copy = Hints_blinded(a_constr);
52026         int64_t ret_ref = tag_ptr(ret_copy, true);
52027         return ret_ref;
52028 }
52029
52030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clear(JNIEnv *env, jclass clz, int64_tArray a) {
52031         LDKCVec_RouteHintZ a_constr;
52032         a_constr.datalen = (*env)->GetArrayLength(env, a);
52033         if (a_constr.datalen > 0)
52034                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
52035         else
52036                 a_constr.data = NULL;
52037         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52038         for (size_t l = 0; l < a_constr.datalen; l++) {
52039                 int64_t a_conv_11 = a_vals[l];
52040                 LDKRouteHint a_conv_11_conv;
52041                 a_conv_11_conv.inner = untag_ptr(a_conv_11);
52042                 a_conv_11_conv.is_owned = ptr_is_owned(a_conv_11);
52043                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv_11_conv);
52044                 a_conv_11_conv = RouteHint_clone(&a_conv_11_conv);
52045                 a_constr.data[l] = a_conv_11_conv;
52046         }
52047         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52048         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52049         *ret_copy = Hints_clear(a_constr);
52050         int64_t ret_ref = tag_ptr(ret_copy, true);
52051         return ret_ref;
52052 }
52053
52054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1hash(JNIEnv *env, jclass clz, int64_t o) {
52055         LDKHints* o_conv = (LDKHints*)untag_ptr(o);
52056         int64_t ret_conv = Hints_hash(o_conv);
52057         return ret_conv;
52058 }
52059
52060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hints_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52061         LDKHints* a_conv = (LDKHints*)untag_ptr(a);
52062         LDKHints* b_conv = (LDKHints*)untag_ptr(b);
52063         jboolean ret_conv = Hints_eq(a_conv, b_conv);
52064         return ret_conv;
52065 }
52066
52067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52068         LDKRouteHint this_obj_conv;
52069         this_obj_conv.inner = untag_ptr(this_obj);
52070         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52072         RouteHint_free(this_obj_conv);
52073 }
52074
52075 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
52076         LDKRouteHint this_ptr_conv;
52077         this_ptr_conv.inner = untag_ptr(this_ptr);
52078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52080         this_ptr_conv.is_owned = false;
52081         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
52082         int64_tArray ret_arr = NULL;
52083         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52084         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52085         for (size_t o = 0; o < ret_var.datalen; o++) {
52086                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
52087                 int64_t ret_conv_14_ref = 0;
52088                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52089                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52090                 ret_arr_ptr[o] = ret_conv_14_ref;
52091         }
52092         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52093         FREE(ret_var.data);
52094         return ret_arr;
52095 }
52096
52097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
52098         LDKRouteHint this_ptr_conv;
52099         this_ptr_conv.inner = untag_ptr(this_ptr);
52100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52102         this_ptr_conv.is_owned = false;
52103         LDKCVec_RouteHintHopZ val_constr;
52104         val_constr.datalen = (*env)->GetArrayLength(env, val);
52105         if (val_constr.datalen > 0)
52106                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52107         else
52108                 val_constr.data = NULL;
52109         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
52110         for (size_t o = 0; o < val_constr.datalen; o++) {
52111                 int64_t val_conv_14 = val_vals[o];
52112                 LDKRouteHintHop val_conv_14_conv;
52113                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
52114                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
52115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
52116                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
52117                 val_constr.data[o] = val_conv_14_conv;
52118         }
52119         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
52120         RouteHint_set_a(&this_ptr_conv, val_constr);
52121 }
52122
52123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
52124         LDKCVec_RouteHintHopZ a_arg_constr;
52125         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
52126         if (a_arg_constr.datalen > 0)
52127                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52128         else
52129                 a_arg_constr.data = NULL;
52130         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
52131         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
52132                 int64_t a_arg_conv_14 = a_arg_vals[o];
52133                 LDKRouteHintHop a_arg_conv_14_conv;
52134                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
52135                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
52136                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
52137                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
52138                 a_arg_constr.data[o] = a_arg_conv_14_conv;
52139         }
52140         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
52141         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
52142         int64_t ret_ref = 0;
52143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52145         return ret_ref;
52146 }
52147
52148 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
52149         LDKRouteHint ret_var = RouteHint_clone(arg);
52150         int64_t ret_ref = 0;
52151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52153         return ret_ref;
52154 }
52155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52156         LDKRouteHint arg_conv;
52157         arg_conv.inner = untag_ptr(arg);
52158         arg_conv.is_owned = ptr_is_owned(arg);
52159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52160         arg_conv.is_owned = false;
52161         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
52162         return ret_conv;
52163 }
52164
52165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52166         LDKRouteHint orig_conv;
52167         orig_conv.inner = untag_ptr(orig);
52168         orig_conv.is_owned = ptr_is_owned(orig);
52169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52170         orig_conv.is_owned = false;
52171         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
52172         int64_t ret_ref = 0;
52173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52175         return ret_ref;
52176 }
52177
52178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
52179         LDKRouteHint o_conv;
52180         o_conv.inner = untag_ptr(o);
52181         o_conv.is_owned = ptr_is_owned(o);
52182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52183         o_conv.is_owned = false;
52184         int64_t ret_conv = RouteHint_hash(&o_conv);
52185         return ret_conv;
52186 }
52187
52188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52189         LDKRouteHint a_conv;
52190         a_conv.inner = untag_ptr(a);
52191         a_conv.is_owned = ptr_is_owned(a);
52192         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52193         a_conv.is_owned = false;
52194         LDKRouteHint b_conv;
52195         b_conv.inner = untag_ptr(b);
52196         b_conv.is_owned = ptr_is_owned(b);
52197         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52198         b_conv.is_owned = false;
52199         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
52200         return ret_conv;
52201 }
52202
52203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
52204         LDKRouteHint obj_conv;
52205         obj_conv.inner = untag_ptr(obj);
52206         obj_conv.is_owned = ptr_is_owned(obj);
52207         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52208         obj_conv.is_owned = false;
52209         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
52210         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52211         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52212         CVec_u8Z_free(ret_var);
52213         return ret_arr;
52214 }
52215
52216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52217         LDKu8slice ser_ref;
52218         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52219         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52220         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
52221         *ret_conv = RouteHint_read(ser_ref);
52222         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52223         return tag_ptr(ret_conv, true);
52224 }
52225
52226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52227         LDKRouteHintHop this_obj_conv;
52228         this_obj_conv.inner = untag_ptr(this_obj);
52229         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52231         RouteHintHop_free(this_obj_conv);
52232 }
52233
52234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52235         LDKRouteHintHop this_ptr_conv;
52236         this_ptr_conv.inner = untag_ptr(this_ptr);
52237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52239         this_ptr_conv.is_owned = false;
52240         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
52242         return ret_arr;
52243 }
52244
52245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
52246         LDKRouteHintHop this_ptr_conv;
52247         this_ptr_conv.inner = untag_ptr(this_ptr);
52248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52250         this_ptr_conv.is_owned = false;
52251         LDKPublicKey val_ref;
52252         CHECK((*env)->GetArrayLength(env, val) == 33);
52253         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
52254         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
52255 }
52256
52257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52258         LDKRouteHintHop this_ptr_conv;
52259         this_ptr_conv.inner = untag_ptr(this_ptr);
52260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52262         this_ptr_conv.is_owned = false;
52263         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
52264         return ret_conv;
52265 }
52266
52267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52268         LDKRouteHintHop this_ptr_conv;
52269         this_ptr_conv.inner = untag_ptr(this_ptr);
52270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52272         this_ptr_conv.is_owned = false;
52273         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
52274 }
52275
52276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
52277         LDKRouteHintHop this_ptr_conv;
52278         this_ptr_conv.inner = untag_ptr(this_ptr);
52279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52281         this_ptr_conv.is_owned = false;
52282         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
52283         int64_t ret_ref = 0;
52284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52286         return ret_ref;
52287 }
52288
52289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52290         LDKRouteHintHop this_ptr_conv;
52291         this_ptr_conv.inner = untag_ptr(this_ptr);
52292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52294         this_ptr_conv.is_owned = false;
52295         LDKRoutingFees val_conv;
52296         val_conv.inner = untag_ptr(val);
52297         val_conv.is_owned = ptr_is_owned(val);
52298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52299         val_conv = RoutingFees_clone(&val_conv);
52300         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
52301 }
52302
52303 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
52304         LDKRouteHintHop this_ptr_conv;
52305         this_ptr_conv.inner = untag_ptr(this_ptr);
52306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52308         this_ptr_conv.is_owned = false;
52309         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
52310         return ret_conv;
52311 }
52312
52313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
52314         LDKRouteHintHop this_ptr_conv;
52315         this_ptr_conv.inner = untag_ptr(this_ptr);
52316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52318         this_ptr_conv.is_owned = false;
52319         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
52320 }
52321
52322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52323         LDKRouteHintHop this_ptr_conv;
52324         this_ptr_conv.inner = untag_ptr(this_ptr);
52325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52327         this_ptr_conv.is_owned = false;
52328         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52329         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
52330         int64_t ret_ref = tag_ptr(ret_copy, true);
52331         return ret_ref;
52332 }
52333
52334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52335         LDKRouteHintHop this_ptr_conv;
52336         this_ptr_conv.inner = untag_ptr(this_ptr);
52337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52339         this_ptr_conv.is_owned = false;
52340         void* val_ptr = untag_ptr(val);
52341         CHECK_ACCESS(val_ptr);
52342         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52343         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52344         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
52345 }
52346
52347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52348         LDKRouteHintHop this_ptr_conv;
52349         this_ptr_conv.inner = untag_ptr(this_ptr);
52350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52352         this_ptr_conv.is_owned = false;
52353         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52354         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
52355         int64_t ret_ref = tag_ptr(ret_copy, true);
52356         return ret_ref;
52357 }
52358
52359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52360         LDKRouteHintHop this_ptr_conv;
52361         this_ptr_conv.inner = untag_ptr(this_ptr);
52362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52364         this_ptr_conv.is_owned = false;
52365         void* val_ptr = untag_ptr(val);
52366         CHECK_ACCESS(val_ptr);
52367         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52368         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52369         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
52370 }
52371
52372 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) {
52373         LDKPublicKey src_node_id_arg_ref;
52374         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
52375         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
52376         LDKRoutingFees fees_arg_conv;
52377         fees_arg_conv.inner = untag_ptr(fees_arg);
52378         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
52379         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
52380         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
52381         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
52382         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
52383         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
52384         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
52385         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
52386         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
52387         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
52388         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
52389         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);
52390         int64_t ret_ref = 0;
52391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52393         return ret_ref;
52394 }
52395
52396 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
52397         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
52398         int64_t ret_ref = 0;
52399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52401         return ret_ref;
52402 }
52403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52404         LDKRouteHintHop arg_conv;
52405         arg_conv.inner = untag_ptr(arg);
52406         arg_conv.is_owned = ptr_is_owned(arg);
52407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52408         arg_conv.is_owned = false;
52409         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
52410         return ret_conv;
52411 }
52412
52413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52414         LDKRouteHintHop orig_conv;
52415         orig_conv.inner = untag_ptr(orig);
52416         orig_conv.is_owned = ptr_is_owned(orig);
52417         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52418         orig_conv.is_owned = false;
52419         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
52420         int64_t ret_ref = 0;
52421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52423         return ret_ref;
52424 }
52425
52426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
52427         LDKRouteHintHop o_conv;
52428         o_conv.inner = untag_ptr(o);
52429         o_conv.is_owned = ptr_is_owned(o);
52430         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52431         o_conv.is_owned = false;
52432         int64_t ret_conv = RouteHintHop_hash(&o_conv);
52433         return ret_conv;
52434 }
52435
52436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52437         LDKRouteHintHop a_conv;
52438         a_conv.inner = untag_ptr(a);
52439         a_conv.is_owned = ptr_is_owned(a);
52440         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52441         a_conv.is_owned = false;
52442         LDKRouteHintHop b_conv;
52443         b_conv.inner = untag_ptr(b);
52444         b_conv.is_owned = ptr_is_owned(b);
52445         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52446         b_conv.is_owned = false;
52447         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
52448         return ret_conv;
52449 }
52450
52451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
52452         LDKRouteHintHop obj_conv;
52453         obj_conv.inner = untag_ptr(obj);
52454         obj_conv.is_owned = ptr_is_owned(obj);
52455         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52456         obj_conv.is_owned = false;
52457         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
52458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52460         CVec_u8Z_free(ret_var);
52461         return ret_arr;
52462 }
52463
52464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52465         LDKu8slice ser_ref;
52466         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52467         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52468         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
52469         *ret_conv = RouteHintHop_read(ser_ref);
52470         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52471         return tag_ptr(ret_conv, true);
52472 }
52473
52474 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) {
52475         LDKPublicKey our_node_pubkey_ref;
52476         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52477         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52478         LDKRouteParameters route_params_conv;
52479         route_params_conv.inner = untag_ptr(route_params);
52480         route_params_conv.is_owned = ptr_is_owned(route_params);
52481         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52482         route_params_conv.is_owned = false;
52483         LDKNetworkGraph network_graph_conv;
52484         network_graph_conv.inner = untag_ptr(network_graph);
52485         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52486         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52487         network_graph_conv.is_owned = false;
52488         LDKCVec_ChannelDetailsZ first_hops_constr;
52489         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
52490         if (first_hops != NULL) {
52491                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
52492                 if (first_hops_constr.datalen > 0)
52493                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
52494                 else
52495                         first_hops_constr.data = NULL;
52496                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
52497                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
52498                         int64_t first_hops_conv_16 = first_hops_vals[q];
52499                         LDKChannelDetails first_hops_conv_16_conv;
52500                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
52501                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
52502                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
52503                         first_hops_conv_16_conv.is_owned = false;
52504                         first_hops_constr.data[q] = first_hops_conv_16_conv;
52505                 }
52506                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
52507                 first_hops_ptr = &first_hops_constr;
52508         }
52509         void* logger_ptr = untag_ptr(logger);
52510         CHECK_ACCESS(logger_ptr);
52511         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52512         if (logger_conv.free == LDKLogger_JCalls_free) {
52513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52514                 LDKLogger_JCalls_cloned(&logger_conv);
52515         }
52516         void* scorer_ptr = untag_ptr(scorer);
52517         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
52518         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
52519         uint8_t random_seed_bytes_arr[32];
52520         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52521         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52522         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52523         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52524         *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);
52525         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
52526         return tag_ptr(ret_conv, true);
52527 }
52528
52529 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) {
52530         LDKPublicKey our_node_pubkey_ref;
52531         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52532         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52533         LDKCVec_PublicKeyZ hops_constr;
52534         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
52535         if (hops_constr.datalen > 0)
52536                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
52537         else
52538                 hops_constr.data = NULL;
52539         for (size_t i = 0; i < hops_constr.datalen; i++) {
52540                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
52541                 LDKPublicKey hops_conv_8_ref;
52542                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
52543                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
52544                 hops_constr.data[i] = hops_conv_8_ref;
52545         }
52546         LDKRouteParameters route_params_conv;
52547         route_params_conv.inner = untag_ptr(route_params);
52548         route_params_conv.is_owned = ptr_is_owned(route_params);
52549         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52550         route_params_conv.is_owned = false;
52551         LDKNetworkGraph network_graph_conv;
52552         network_graph_conv.inner = untag_ptr(network_graph);
52553         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52554         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52555         network_graph_conv.is_owned = false;
52556         void* logger_ptr = untag_ptr(logger);
52557         CHECK_ACCESS(logger_ptr);
52558         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52559         if (logger_conv.free == LDKLogger_JCalls_free) {
52560                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52561                 LDKLogger_JCalls_cloned(&logger_conv);
52562         }
52563         uint8_t random_seed_bytes_arr[32];
52564         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52565         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52566         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52567         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52568         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
52569         return tag_ptr(ret_conv, true);
52570 }
52571
52572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52573         if (!ptr_is_owned(this_ptr)) return;
52574         void* this_ptr_ptr = untag_ptr(this_ptr);
52575         CHECK_ACCESS(this_ptr_ptr);
52576         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
52577         FREE(untag_ptr(this_ptr));
52578         Score_free(this_ptr_conv);
52579 }
52580
52581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52582         if (!ptr_is_owned(this_ptr)) return;
52583         void* this_ptr_ptr = untag_ptr(this_ptr);
52584         CHECK_ACCESS(this_ptr_ptr);
52585         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
52586         FREE(untag_ptr(this_ptr));
52587         LockableScore_free(this_ptr_conv);
52588 }
52589
52590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52591         if (!ptr_is_owned(this_ptr)) return;
52592         void* this_ptr_ptr = untag_ptr(this_ptr);
52593         CHECK_ACCESS(this_ptr_ptr);
52594         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
52595         FREE(untag_ptr(this_ptr));
52596         WriteableScore_free(this_ptr_conv);
52597 }
52598
52599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52600         LDKMultiThreadedLockableScore this_obj_conv;
52601         this_obj_conv.inner = untag_ptr(this_obj);
52602         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52604         MultiThreadedLockableScore_free(this_obj_conv);
52605 }
52606
52607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52608         LDKMultiThreadedScoreLock this_obj_conv;
52609         this_obj_conv.inner = untag_ptr(this_obj);
52610         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52612         MultiThreadedScoreLock_free(this_obj_conv);
52613 }
52614
52615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52616         LDKMultiThreadedScoreLock this_arg_conv;
52617         this_arg_conv.inner = untag_ptr(this_arg);
52618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52620         this_arg_conv.is_owned = false;
52621         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52622         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
52623         return tag_ptr(ret_ret, true);
52624 }
52625
52626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
52627         LDKMultiThreadedScoreLock obj_conv;
52628         obj_conv.inner = untag_ptr(obj);
52629         obj_conv.is_owned = ptr_is_owned(obj);
52630         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52631         obj_conv.is_owned = false;
52632         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
52633         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52634         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52635         CVec_u8Z_free(ret_var);
52636         return ret_arr;
52637 }
52638
52639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52640         LDKMultiThreadedLockableScore this_arg_conv;
52641         this_arg_conv.inner = untag_ptr(this_arg);
52642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52644         this_arg_conv.is_owned = false;
52645         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
52646         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
52647         return tag_ptr(ret_ret, true);
52648 }
52649
52650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
52651         LDKMultiThreadedLockableScore obj_conv;
52652         obj_conv.inner = untag_ptr(obj);
52653         obj_conv.is_owned = ptr_is_owned(obj);
52654         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52655         obj_conv.is_owned = false;
52656         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
52657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52659         CVec_u8Z_free(ret_var);
52660         return ret_arr;
52661 }
52662
52663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52664         LDKMultiThreadedLockableScore this_arg_conv;
52665         this_arg_conv.inner = untag_ptr(this_arg);
52666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52668         this_arg_conv.is_owned = false;
52669         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
52670         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
52671         return tag_ptr(ret_ret, true);
52672 }
52673
52674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
52675         void* score_ptr = untag_ptr(score);
52676         CHECK_ACCESS(score_ptr);
52677         LDKScore score_conv = *(LDKScore*)(score_ptr);
52678         if (score_conv.free == LDKScore_JCalls_free) {
52679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52680                 LDKScore_JCalls_cloned(&score_conv);
52681         }
52682         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
52683         int64_t ret_ref = 0;
52684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52686         return ret_ref;
52687 }
52688
52689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52690         LDKChannelUsage this_obj_conv;
52691         this_obj_conv.inner = untag_ptr(this_obj);
52692         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52694         ChannelUsage_free(this_obj_conv);
52695 }
52696
52697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52698         LDKChannelUsage this_ptr_conv;
52699         this_ptr_conv.inner = untag_ptr(this_ptr);
52700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52702         this_ptr_conv.is_owned = false;
52703         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
52704         return ret_conv;
52705 }
52706
52707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52708         LDKChannelUsage this_ptr_conv;
52709         this_ptr_conv.inner = untag_ptr(this_ptr);
52710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52712         this_ptr_conv.is_owned = false;
52713         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
52714 }
52715
52716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52717         LDKChannelUsage this_ptr_conv;
52718         this_ptr_conv.inner = untag_ptr(this_ptr);
52719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52721         this_ptr_conv.is_owned = false;
52722         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
52723         return ret_conv;
52724 }
52725
52726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52727         LDKChannelUsage this_ptr_conv;
52728         this_ptr_conv.inner = untag_ptr(this_ptr);
52729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52731         this_ptr_conv.is_owned = false;
52732         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
52733 }
52734
52735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
52736         LDKChannelUsage this_ptr_conv;
52737         this_ptr_conv.inner = untag_ptr(this_ptr);
52738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52740         this_ptr_conv.is_owned = false;
52741         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
52742         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
52743         int64_t ret_ref = tag_ptr(ret_copy, true);
52744         return ret_ref;
52745 }
52746
52747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52748         LDKChannelUsage this_ptr_conv;
52749         this_ptr_conv.inner = untag_ptr(this_ptr);
52750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52752         this_ptr_conv.is_owned = false;
52753         void* val_ptr = untag_ptr(val);
52754         CHECK_ACCESS(val_ptr);
52755         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
52756         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
52757         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
52758 }
52759
52760 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) {
52761         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
52762         CHECK_ACCESS(effective_capacity_arg_ptr);
52763         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
52764         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
52765         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
52766         int64_t ret_ref = 0;
52767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52769         return ret_ref;
52770 }
52771
52772 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
52773         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
52774         int64_t ret_ref = 0;
52775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52777         return ret_ref;
52778 }
52779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52780         LDKChannelUsage arg_conv;
52781         arg_conv.inner = untag_ptr(arg);
52782         arg_conv.is_owned = ptr_is_owned(arg);
52783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52784         arg_conv.is_owned = false;
52785         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
52786         return ret_conv;
52787 }
52788
52789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52790         LDKChannelUsage orig_conv;
52791         orig_conv.inner = untag_ptr(orig);
52792         orig_conv.is_owned = ptr_is_owned(orig);
52793         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52794         orig_conv.is_owned = false;
52795         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
52796         int64_t ret_ref = 0;
52797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52799         return ret_ref;
52800 }
52801
52802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52803         LDKFixedPenaltyScorer this_obj_conv;
52804         this_obj_conv.inner = untag_ptr(this_obj);
52805         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52807         FixedPenaltyScorer_free(this_obj_conv);
52808 }
52809
52810 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
52811         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
52812         int64_t ret_ref = 0;
52813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52815         return ret_ref;
52816 }
52817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52818         LDKFixedPenaltyScorer arg_conv;
52819         arg_conv.inner = untag_ptr(arg);
52820         arg_conv.is_owned = ptr_is_owned(arg);
52821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52822         arg_conv.is_owned = false;
52823         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
52824         return ret_conv;
52825 }
52826
52827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52828         LDKFixedPenaltyScorer orig_conv;
52829         orig_conv.inner = untag_ptr(orig);
52830         orig_conv.is_owned = ptr_is_owned(orig);
52831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52832         orig_conv.is_owned = false;
52833         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
52834         int64_t ret_ref = 0;
52835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52837         return ret_ref;
52838 }
52839
52840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
52841         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
52842         int64_t ret_ref = 0;
52843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52845         return ret_ref;
52846 }
52847
52848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52849         LDKFixedPenaltyScorer this_arg_conv;
52850         this_arg_conv.inner = untag_ptr(this_arg);
52851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52853         this_arg_conv.is_owned = false;
52854         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52855         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
52856         return tag_ptr(ret_ret, true);
52857 }
52858
52859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
52860         LDKFixedPenaltyScorer obj_conv;
52861         obj_conv.inner = untag_ptr(obj);
52862         obj_conv.is_owned = ptr_is_owned(obj);
52863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52864         obj_conv.is_owned = false;
52865         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
52866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52868         CVec_u8Z_free(ret_var);
52869         return ret_arr;
52870 }
52871
52872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
52873         LDKu8slice ser_ref;
52874         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52875         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52876         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
52877         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
52878         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52879         return tag_ptr(ret_conv, true);
52880 }
52881
52882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52883         LDKProbabilisticScorer this_obj_conv;
52884         this_obj_conv.inner = untag_ptr(this_obj);
52885         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52887         ProbabilisticScorer_free(this_obj_conv);
52888 }
52889
52890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52891         LDKProbabilisticScoringParameters this_obj_conv;
52892         this_obj_conv.inner = untag_ptr(this_obj);
52893         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52895         ProbabilisticScoringParameters_free(this_obj_conv);
52896 }
52897
52898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52899         LDKProbabilisticScoringParameters this_ptr_conv;
52900         this_ptr_conv.inner = untag_ptr(this_ptr);
52901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52903         this_ptr_conv.is_owned = false;
52904         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
52905         return ret_conv;
52906 }
52907
52908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52909         LDKProbabilisticScoringParameters this_ptr_conv;
52910         this_ptr_conv.inner = untag_ptr(this_ptr);
52911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52913         this_ptr_conv.is_owned = false;
52914         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
52915 }
52916
52917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52918         LDKProbabilisticScoringParameters this_ptr_conv;
52919         this_ptr_conv.inner = untag_ptr(this_ptr);
52920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52922         this_ptr_conv.is_owned = false;
52923         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
52924         return ret_conv;
52925 }
52926
52927 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) {
52928         LDKProbabilisticScoringParameters this_ptr_conv;
52929         this_ptr_conv.inner = untag_ptr(this_ptr);
52930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52932         this_ptr_conv.is_owned = false;
52933         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52934 }
52935
52936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52937         LDKProbabilisticScoringParameters this_ptr_conv;
52938         this_ptr_conv.inner = untag_ptr(this_ptr);
52939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52941         this_ptr_conv.is_owned = false;
52942         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52943         return ret_conv;
52944 }
52945
52946 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) {
52947         LDKProbabilisticScoringParameters this_ptr_conv;
52948         this_ptr_conv.inner = untag_ptr(this_ptr);
52949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52951         this_ptr_conv.is_owned = false;
52952         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52953 }
52954
52955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
52956         LDKProbabilisticScoringParameters this_ptr_conv;
52957         this_ptr_conv.inner = untag_ptr(this_ptr);
52958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52960         this_ptr_conv.is_owned = false;
52961         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
52962         return ret_conv;
52963 }
52964
52965 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) {
52966         LDKProbabilisticScoringParameters this_ptr_conv;
52967         this_ptr_conv.inner = untag_ptr(this_ptr);
52968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52970         this_ptr_conv.is_owned = false;
52971         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
52972 }
52973
52974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52975         LDKProbabilisticScoringParameters this_ptr_conv;
52976         this_ptr_conv.inner = untag_ptr(this_ptr);
52977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52979         this_ptr_conv.is_owned = false;
52980         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52981         return ret_conv;
52982 }
52983
52984 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) {
52985         LDKProbabilisticScoringParameters this_ptr_conv;
52986         this_ptr_conv.inner = untag_ptr(this_ptr);
52987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52989         this_ptr_conv.is_owned = false;
52990         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52991 }
52992
52993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52994         LDKProbabilisticScoringParameters this_ptr_conv;
52995         this_ptr_conv.inner = untag_ptr(this_ptr);
52996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52998         this_ptr_conv.is_owned = false;
52999         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
53000         return ret_conv;
53001 }
53002
53003 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) {
53004         LDKProbabilisticScoringParameters this_ptr_conv;
53005         this_ptr_conv.inner = untag_ptr(this_ptr);
53006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53008         this_ptr_conv.is_owned = false;
53009         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
53010 }
53011
53012 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) {
53013         LDKProbabilisticScoringParameters this_ptr_conv;
53014         this_ptr_conv.inner = untag_ptr(this_ptr);
53015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53017         this_ptr_conv.is_owned = false;
53018         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
53019         return ret_conv;
53020 }
53021
53022 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) {
53023         LDKProbabilisticScoringParameters this_ptr_conv;
53024         this_ptr_conv.inner = untag_ptr(this_ptr);
53025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53027         this_ptr_conv.is_owned = false;
53028         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
53029 }
53030
53031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
53032         LDKProbabilisticScoringParameters this_ptr_conv;
53033         this_ptr_conv.inner = untag_ptr(this_ptr);
53034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53036         this_ptr_conv.is_owned = false;
53037         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
53038         return ret_conv;
53039 }
53040
53041 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) {
53042         LDKProbabilisticScoringParameters this_ptr_conv;
53043         this_ptr_conv.inner = untag_ptr(this_ptr);
53044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53046         this_ptr_conv.is_owned = false;
53047         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
53048 }
53049
53050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53051         LDKProbabilisticScoringParameters this_ptr_conv;
53052         this_ptr_conv.inner = untag_ptr(this_ptr);
53053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53055         this_ptr_conv.is_owned = false;
53056         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
53057         return ret_conv;
53058 }
53059
53060 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) {
53061         LDKProbabilisticScoringParameters this_ptr_conv;
53062         this_ptr_conv.inner = untag_ptr(this_ptr);
53063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53065         this_ptr_conv.is_owned = false;
53066         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
53067 }
53068
53069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53070         LDKProbabilisticScoringParameters this_ptr_conv;
53071         this_ptr_conv.inner = untag_ptr(this_ptr);
53072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53074         this_ptr_conv.is_owned = false;
53075         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
53076         return ret_conv;
53077 }
53078
53079 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) {
53080         LDKProbabilisticScoringParameters this_ptr_conv;
53081         this_ptr_conv.inner = untag_ptr(this_ptr);
53082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53084         this_ptr_conv.is_owned = false;
53085         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
53086 }
53087
53088 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
53089         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
53090         int64_t ret_ref = 0;
53091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53093         return ret_ref;
53094 }
53095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53096         LDKProbabilisticScoringParameters arg_conv;
53097         arg_conv.inner = untag_ptr(arg);
53098         arg_conv.is_owned = ptr_is_owned(arg);
53099         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53100         arg_conv.is_owned = false;
53101         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
53102         return ret_conv;
53103 }
53104
53105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53106         LDKProbabilisticScoringParameters orig_conv;
53107         orig_conv.inner = untag_ptr(orig);
53108         orig_conv.is_owned = ptr_is_owned(orig);
53109         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53110         orig_conv.is_owned = false;
53111         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
53112         int64_t ret_ref = 0;
53113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53114         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53115         return ret_ref;
53116 }
53117
53118 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) {
53119         LDKProbabilisticScoringParameters params_conv;
53120         params_conv.inner = untag_ptr(params);
53121         params_conv.is_owned = ptr_is_owned(params);
53122         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
53123         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
53124         LDKNetworkGraph network_graph_conv;
53125         network_graph_conv.inner = untag_ptr(network_graph);
53126         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53127         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53128         network_graph_conv.is_owned = false;
53129         void* logger_ptr = untag_ptr(logger);
53130         CHECK_ACCESS(logger_ptr);
53131         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53132         if (logger_conv.free == LDKLogger_JCalls_free) {
53133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53134                 LDKLogger_JCalls_cloned(&logger_conv);
53135         }
53136         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
53137         int64_t ret_ref = 0;
53138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53140         return ret_ref;
53141 }
53142
53143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
53144         LDKProbabilisticScorer 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         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
53150 }
53151
53152 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) {
53153         LDKProbabilisticScorer this_arg_conv;
53154         this_arg_conv.inner = untag_ptr(this_arg);
53155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53157         this_arg_conv.is_owned = false;
53158         LDKNodeId target_conv;
53159         target_conv.inner = untag_ptr(target);
53160         target_conv.is_owned = ptr_is_owned(target);
53161         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53162         target_conv.is_owned = false;
53163         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
53164         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
53165         int64_t ret_ref = tag_ptr(ret_copy, true);
53166         return ret_ref;
53167 }
53168
53169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1historical_1estimated_1channel_1liquidity_1probabilities(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
53170         LDKProbabilisticScorer this_arg_conv;
53171         this_arg_conv.inner = untag_ptr(this_arg);
53172         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53174         this_arg_conv.is_owned = false;
53175         LDKNodeId target_conv;
53176         target_conv.inner = untag_ptr(target);
53177         target_conv.is_owned = ptr_is_owned(target);
53178         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53179         target_conv.is_owned = false;
53180         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
53181         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
53182         int64_t ret_ref = tag_ptr(ret_copy, true);
53183         return ret_ref;
53184 }
53185
53186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53187         LDKProbabilisticScorer this_arg_conv;
53188         this_arg_conv.inner = untag_ptr(this_arg);
53189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53191         this_arg_conv.is_owned = false;
53192         LDKNodeId node_id_conv;
53193         node_id_conv.inner = untag_ptr(node_id);
53194         node_id_conv.is_owned = ptr_is_owned(node_id);
53195         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53196         node_id_conv.is_owned = false;
53197         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
53198 }
53199
53200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53201         LDKProbabilisticScorer this_arg_conv;
53202         this_arg_conv.inner = untag_ptr(this_arg);
53203         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53205         this_arg_conv.is_owned = false;
53206         LDKNodeId node_id_conv;
53207         node_id_conv.inner = untag_ptr(node_id);
53208         node_id_conv.is_owned = ptr_is_owned(node_id);
53209         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53210         node_id_conv.is_owned = false;
53211         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
53212 }
53213
53214 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) {
53215         LDKProbabilisticScorer this_arg_conv;
53216         this_arg_conv.inner = untag_ptr(this_arg);
53217         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53219         this_arg_conv.is_owned = false;
53220         LDKNodeId node_id_conv;
53221         node_id_conv.inner = untag_ptr(node_id);
53222         node_id_conv.is_owned = ptr_is_owned(node_id);
53223         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53224         node_id_conv.is_owned = false;
53225         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
53226 }
53227
53228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53229         LDKProbabilisticScorer 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         LDKNodeId node_id_conv;
53235         node_id_conv.inner = untag_ptr(node_id);
53236         node_id_conv.is_owned = ptr_is_owned(node_id);
53237         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53238         node_id_conv.is_owned = false;
53239         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
53240 }
53241
53242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
53243         LDKProbabilisticScorer this_arg_conv;
53244         this_arg_conv.inner = untag_ptr(this_arg);
53245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53247         this_arg_conv.is_owned = false;
53248         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
53249 }
53250
53251 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) {
53252         LDKProbabilisticScoringParameters this_arg_conv;
53253         this_arg_conv.inner = untag_ptr(this_arg);
53254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53256         this_arg_conv.is_owned = false;
53257         LDKCVec_NodeIdZ node_ids_constr;
53258         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
53259         if (node_ids_constr.datalen > 0)
53260                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
53261         else
53262                 node_ids_constr.data = NULL;
53263         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
53264         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
53265                 int64_t node_ids_conv_8 = node_ids_vals[i];
53266                 LDKNodeId node_ids_conv_8_conv;
53267                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
53268                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
53269                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
53270                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
53271                 node_ids_constr.data[i] = node_ids_conv_8_conv;
53272         }
53273         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
53274         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
53275 }
53276
53277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
53278         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
53279         int64_t ret_ref = 0;
53280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53282         return ret_ref;
53283 }
53284
53285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
53286         LDKProbabilisticScorer this_arg_conv;
53287         this_arg_conv.inner = untag_ptr(this_arg);
53288         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53290         this_arg_conv.is_owned = false;
53291         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
53292         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
53293         return tag_ptr(ret_ret, true);
53294 }
53295
53296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
53297         LDKProbabilisticScorer obj_conv;
53298         obj_conv.inner = untag_ptr(obj);
53299         obj_conv.is_owned = ptr_is_owned(obj);
53300         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53301         obj_conv.is_owned = false;
53302         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
53303         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53304         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53305         CVec_u8Z_free(ret_var);
53306         return ret_arr;
53307 }
53308
53309 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) {
53310         LDKu8slice ser_ref;
53311         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53312         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53313         LDKProbabilisticScoringParameters arg_a_conv;
53314         arg_a_conv.inner = untag_ptr(arg_a);
53315         arg_a_conv.is_owned = ptr_is_owned(arg_a);
53316         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
53317         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
53318         LDKNetworkGraph arg_b_conv;
53319         arg_b_conv.inner = untag_ptr(arg_b);
53320         arg_b_conv.is_owned = ptr_is_owned(arg_b);
53321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
53322         arg_b_conv.is_owned = false;
53323         void* arg_c_ptr = untag_ptr(arg_c);
53324         CHECK_ACCESS(arg_c_ptr);
53325         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
53326         if (arg_c_conv.free == LDKLogger_JCalls_free) {
53327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53328                 LDKLogger_JCalls_cloned(&arg_c_conv);
53329         }
53330         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
53331         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
53332         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53333         return tag_ptr(ret_conv, true);
53334 }
53335
53336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53337         LDKOnionMessenger this_obj_conv;
53338         this_obj_conv.inner = untag_ptr(this_obj);
53339         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53341         OnionMessenger_free(this_obj_conv);
53342 }
53343
53344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53345         if (!ptr_is_owned(this_ptr)) return;
53346         void* this_ptr_ptr = untag_ptr(this_ptr);
53347         CHECK_ACCESS(this_ptr_ptr);
53348         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
53349         FREE(untag_ptr(this_ptr));
53350         Destination_free(this_ptr_conv);
53351 }
53352
53353 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
53354         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53355         *ret_copy = Destination_clone(arg);
53356         int64_t ret_ref = tag_ptr(ret_copy, true);
53357         return ret_ref;
53358 }
53359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53360         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
53361         int64_t ret_conv = Destination_clone_ptr(arg_conv);
53362         return ret_conv;
53363 }
53364
53365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53366         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
53367         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53368         *ret_copy = Destination_clone(orig_conv);
53369         int64_t ret_ref = tag_ptr(ret_copy, true);
53370         return ret_ref;
53371 }
53372
53373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
53374         LDKPublicKey a_ref;
53375         CHECK((*env)->GetArrayLength(env, a) == 33);
53376         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
53377         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53378         *ret_copy = Destination_node(a_ref);
53379         int64_t ret_ref = tag_ptr(ret_copy, true);
53380         return ret_ref;
53381 }
53382
53383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
53384         LDKBlindedPath a_conv;
53385         a_conv.inner = untag_ptr(a);
53386         a_conv.is_owned = ptr_is_owned(a);
53387         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53388         a_conv = BlindedPath_clone(&a_conv);
53389         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53390         *ret_copy = Destination_blinded_path(a_conv);
53391         int64_t ret_ref = tag_ptr(ret_copy, true);
53392         return ret_ref;
53393 }
53394
53395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53396         if (!ptr_is_owned(this_ptr)) return;
53397         void* this_ptr_ptr = untag_ptr(this_ptr);
53398         CHECK_ACCESS(this_ptr_ptr);
53399         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
53400         FREE(untag_ptr(this_ptr));
53401         SendError_free(this_ptr_conv);
53402 }
53403
53404 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
53405         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53406         *ret_copy = SendError_clone(arg);
53407         int64_t ret_ref = tag_ptr(ret_copy, true);
53408         return ret_ref;
53409 }
53410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53411         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
53412         int64_t ret_conv = SendError_clone_ptr(arg_conv);
53413         return ret_conv;
53414 }
53415
53416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53417         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
53418         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53419         *ret_copy = SendError_clone(orig_conv);
53420         int64_t ret_ref = tag_ptr(ret_copy, true);
53421         return ret_ref;
53422 }
53423
53424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
53425         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
53426         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53427         *ret_copy = SendError_secp256k1(a_conv);
53428         int64_t ret_ref = tag_ptr(ret_copy, true);
53429         return ret_ref;
53430 }
53431
53432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
53433         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53434         *ret_copy = SendError_too_big_packet();
53435         int64_t ret_ref = tag_ptr(ret_copy, true);
53436         return ret_ref;
53437 }
53438
53439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
53440         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53441         *ret_copy = SendError_too_few_blinded_hops();
53442         int64_t ret_ref = tag_ptr(ret_copy, true);
53443         return ret_ref;
53444 }
53445
53446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
53447         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53448         *ret_copy = SendError_invalid_first_hop();
53449         int64_t ret_ref = tag_ptr(ret_copy, true);
53450         return ret_ref;
53451 }
53452
53453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
53454         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53455         *ret_copy = SendError_invalid_message();
53456         int64_t ret_ref = tag_ptr(ret_copy, true);
53457         return ret_ref;
53458 }
53459
53460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
53461         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53462         *ret_copy = SendError_buffer_full();
53463         int64_t ret_ref = tag_ptr(ret_copy, true);
53464         return ret_ref;
53465 }
53466
53467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
53468         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53469         *ret_copy = SendError_get_node_id_failed();
53470         int64_t ret_ref = tag_ptr(ret_copy, true);
53471         return ret_ref;
53472 }
53473
53474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
53475         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53476         *ret_copy = SendError_blinded_path_advance_failed();
53477         int64_t ret_ref = tag_ptr(ret_copy, true);
53478         return ret_ref;
53479 }
53480
53481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53482         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
53483         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
53484         jboolean ret_conv = SendError_eq(a_conv, b_conv);
53485         return ret_conv;
53486 }
53487
53488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53489         if (!ptr_is_owned(this_ptr)) return;
53490         void* this_ptr_ptr = untag_ptr(this_ptr);
53491         CHECK_ACCESS(this_ptr_ptr);
53492         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
53493         FREE(untag_ptr(this_ptr));
53494         CustomOnionMessageHandler_free(this_ptr_conv);
53495 }
53496
53497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1new(JNIEnv *env, jclass clz, int64_t entropy_source, int64_t node_signer, int64_t logger, int64_t custom_handler) {
53498         void* entropy_source_ptr = untag_ptr(entropy_source);
53499         CHECK_ACCESS(entropy_source_ptr);
53500         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
53501         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
53502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53503                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
53504         }
53505         void* node_signer_ptr = untag_ptr(node_signer);
53506         CHECK_ACCESS(node_signer_ptr);
53507         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
53508         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
53509                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53510                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
53511         }
53512         void* logger_ptr = untag_ptr(logger);
53513         CHECK_ACCESS(logger_ptr);
53514         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53515         if (logger_conv.free == LDKLogger_JCalls_free) {
53516                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53517                 LDKLogger_JCalls_cloned(&logger_conv);
53518         }
53519         void* custom_handler_ptr = untag_ptr(custom_handler);
53520         CHECK_ACCESS(custom_handler_ptr);
53521         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
53522         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
53523                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53524                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
53525         }
53526         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, custom_handler_conv);
53527         int64_t ret_ref = 0;
53528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53530         return ret_ref;
53531 }
53532
53533 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) {
53534         LDKOnionMessenger this_arg_conv;
53535         this_arg_conv.inner = untag_ptr(this_arg);
53536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53538         this_arg_conv.is_owned = false;
53539         LDKCVec_PublicKeyZ intermediate_nodes_constr;
53540         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
53541         if (intermediate_nodes_constr.datalen > 0)
53542                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53543         else
53544                 intermediate_nodes_constr.data = NULL;
53545         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
53546                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
53547                 LDKPublicKey intermediate_nodes_conv_8_ref;
53548                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
53549                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
53550                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
53551         }
53552         void* destination_ptr = untag_ptr(destination);
53553         CHECK_ACCESS(destination_ptr);
53554         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
53555         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
53556         void* message_ptr = untag_ptr(message);
53557         CHECK_ACCESS(message_ptr);
53558         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
53559         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
53560         LDKBlindedPath reply_path_conv;
53561         reply_path_conv.inner = untag_ptr(reply_path);
53562         reply_path_conv.is_owned = ptr_is_owned(reply_path);
53563         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
53564         reply_path_conv = BlindedPath_clone(&reply_path_conv);
53565         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
53566         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
53567         return tag_ptr(ret_conv, true);
53568 }
53569
53570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53571         LDKOnionMessenger this_arg_conv;
53572         this_arg_conv.inner = untag_ptr(this_arg);
53573         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53575         this_arg_conv.is_owned = false;
53576         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
53577         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
53578         return tag_ptr(ret_ret, true);
53579 }
53580
53581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
53582         LDKOnionMessenger this_arg_conv;
53583         this_arg_conv.inner = untag_ptr(this_arg);
53584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53586         this_arg_conv.is_owned = false;
53587         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
53588         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
53589         return tag_ptr(ret_ret, true);
53590 }
53591
53592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53593         if (!ptr_is_owned(this_ptr)) return;
53594         void* this_ptr_ptr = untag_ptr(this_ptr);
53595         CHECK_ACCESS(this_ptr_ptr);
53596         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
53597         FREE(untag_ptr(this_ptr));
53598         OnionMessageContents_free(this_ptr_conv);
53599 }
53600
53601 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
53602         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53603         *ret_copy = OnionMessageContents_clone(arg);
53604         int64_t ret_ref = tag_ptr(ret_copy, true);
53605         return ret_ref;
53606 }
53607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53608         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
53609         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
53610         return ret_conv;
53611 }
53612
53613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53614         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
53615         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53616         *ret_copy = OnionMessageContents_clone(orig_conv);
53617         int64_t ret_ref = tag_ptr(ret_copy, true);
53618         return ret_ref;
53619 }
53620
53621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
53622         void* a_ptr = untag_ptr(a);
53623         CHECK_ACCESS(a_ptr);
53624         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
53625         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
53626                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53627                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
53628         }
53629         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53630         *ret_copy = OnionMessageContents_custom(a_conv);
53631         int64_t ret_ref = tag_ptr(ret_copy, true);
53632         return ret_ref;
53633 }
53634
53635 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
53636         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53637         *ret_ret = CustomOnionMessageContents_clone(arg);
53638         return tag_ptr(ret_ret, true);
53639 }
53640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53641         void* arg_ptr = untag_ptr(arg);
53642         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53643         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
53644         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
53645         return ret_conv;
53646 }
53647
53648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53649         void* orig_ptr = untag_ptr(orig);
53650         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53651         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
53652         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53653         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
53654         return tag_ptr(ret_ret, true);
53655 }
53656
53657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53658         if (!ptr_is_owned(this_ptr)) return;
53659         void* this_ptr_ptr = untag_ptr(this_ptr);
53660         CHECK_ACCESS(this_ptr_ptr);
53661         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
53662         FREE(untag_ptr(this_ptr));
53663         CustomOnionMessageContents_free(this_ptr_conv);
53664 }
53665
53666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53667         LDKBlindedPath this_obj_conv;
53668         this_obj_conv.inner = untag_ptr(this_obj);
53669         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53671         BlindedPath_free(this_obj_conv);
53672 }
53673
53674 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
53675         LDKBlindedPath ret_var = BlindedPath_clone(arg);
53676         int64_t ret_ref = 0;
53677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53679         return ret_ref;
53680 }
53681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53682         LDKBlindedPath arg_conv;
53683         arg_conv.inner = untag_ptr(arg);
53684         arg_conv.is_owned = ptr_is_owned(arg);
53685         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53686         arg_conv.is_owned = false;
53687         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
53688         return ret_conv;
53689 }
53690
53691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53692         LDKBlindedPath orig_conv;
53693         orig_conv.inner = untag_ptr(orig);
53694         orig_conv.is_owned = ptr_is_owned(orig);
53695         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53696         orig_conv.is_owned = false;
53697         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
53698         int64_t ret_ref = 0;
53699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53701         return ret_ref;
53702 }
53703
53704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1hash(JNIEnv *env, jclass clz, int64_t o) {
53705         LDKBlindedPath o_conv;
53706         o_conv.inner = untag_ptr(o);
53707         o_conv.is_owned = ptr_is_owned(o);
53708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53709         o_conv.is_owned = false;
53710         int64_t ret_conv = BlindedPath_hash(&o_conv);
53711         return ret_conv;
53712 }
53713
53714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPath_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53715         LDKBlindedPath a_conv;
53716         a_conv.inner = untag_ptr(a);
53717         a_conv.is_owned = ptr_is_owned(a);
53718         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53719         a_conv.is_owned = false;
53720         LDKBlindedPath b_conv;
53721         b_conv.inner = untag_ptr(b);
53722         b_conv.is_owned = ptr_is_owned(b);
53723         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53724         b_conv.is_owned = false;
53725         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
53726         return ret_conv;
53727 }
53728
53729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53730         LDKBlindedHop this_obj_conv;
53731         this_obj_conv.inner = untag_ptr(this_obj);
53732         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53734         BlindedHop_free(this_obj_conv);
53735 }
53736
53737 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
53738         LDKBlindedHop ret_var = BlindedHop_clone(arg);
53739         int64_t ret_ref = 0;
53740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53742         return ret_ref;
53743 }
53744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53745         LDKBlindedHop arg_conv;
53746         arg_conv.inner = untag_ptr(arg);
53747         arg_conv.is_owned = ptr_is_owned(arg);
53748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53749         arg_conv.is_owned = false;
53750         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
53751         return ret_conv;
53752 }
53753
53754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53755         LDKBlindedHop orig_conv;
53756         orig_conv.inner = untag_ptr(orig);
53757         orig_conv.is_owned = ptr_is_owned(orig);
53758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53759         orig_conv.is_owned = false;
53760         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
53761         int64_t ret_ref = 0;
53762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53764         return ret_ref;
53765 }
53766
53767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
53768         LDKBlindedHop o_conv;
53769         o_conv.inner = untag_ptr(o);
53770         o_conv.is_owned = ptr_is_owned(o);
53771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53772         o_conv.is_owned = false;
53773         int64_t ret_conv = BlindedHop_hash(&o_conv);
53774         return ret_conv;
53775 }
53776
53777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53778         LDKBlindedHop a_conv;
53779         a_conv.inner = untag_ptr(a);
53780         a_conv.is_owned = ptr_is_owned(a);
53781         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53782         a_conv.is_owned = false;
53783         LDKBlindedHop b_conv;
53784         b_conv.inner = untag_ptr(b);
53785         b_conv.is_owned = ptr_is_owned(b);
53786         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53787         b_conv.is_owned = false;
53788         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
53789         return ret_conv;
53790 }
53791
53792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new_1for_1message(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t entropy_source) {
53793         LDKCVec_PublicKeyZ node_pks_constr;
53794         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
53795         if (node_pks_constr.datalen > 0)
53796                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53797         else
53798                 node_pks_constr.data = NULL;
53799         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
53800                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
53801                 LDKPublicKey node_pks_conv_8_ref;
53802                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
53803                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
53804                 node_pks_constr.data[i] = node_pks_conv_8_ref;
53805         }
53806         void* entropy_source_ptr = untag_ptr(entropy_source);
53807         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
53808         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
53809         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
53810         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
53811         return tag_ptr(ret_conv, true);
53812 }
53813
53814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
53815         LDKBlindedPath obj_conv;
53816         obj_conv.inner = untag_ptr(obj);
53817         obj_conv.is_owned = ptr_is_owned(obj);
53818         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53819         obj_conv.is_owned = false;
53820         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
53821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53823         CVec_u8Z_free(ret_var);
53824         return ret_arr;
53825 }
53826
53827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53828         LDKu8slice ser_ref;
53829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53831         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
53832         *ret_conv = BlindedPath_read(ser_ref);
53833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53834         return tag_ptr(ret_conv, true);
53835 }
53836
53837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
53838         LDKBlindedHop obj_conv;
53839         obj_conv.inner = untag_ptr(obj);
53840         obj_conv.is_owned = ptr_is_owned(obj);
53841         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53842         obj_conv.is_owned = false;
53843         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
53844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53846         CVec_u8Z_free(ret_var);
53847         return ret_arr;
53848 }
53849
53850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53851         LDKu8slice ser_ref;
53852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53854         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
53855         *ret_conv = BlindedHop_read(ser_ref);
53856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53857         return tag_ptr(ret_conv, true);
53858 }
53859
53860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53861         if (!ptr_is_owned(this_ptr)) return;
53862         void* this_ptr_ptr = untag_ptr(this_ptr);
53863         CHECK_ACCESS(this_ptr_ptr);
53864         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
53865         FREE(untag_ptr(this_ptr));
53866         PaymentPurpose_free(this_ptr_conv);
53867 }
53868
53869 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
53870         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53871         *ret_copy = PaymentPurpose_clone(arg);
53872         int64_t ret_ref = tag_ptr(ret_copy, true);
53873         return ret_ref;
53874 }
53875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53876         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
53877         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
53878         return ret_conv;
53879 }
53880
53881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53882         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
53883         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53884         *ret_copy = PaymentPurpose_clone(orig_conv);
53885         int64_t ret_ref = tag_ptr(ret_copy, true);
53886         return ret_ref;
53887 }
53888
53889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
53890         LDKThirtyTwoBytes payment_preimage_ref;
53891         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53892         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53893         LDKThirtyTwoBytes payment_secret_ref;
53894         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
53895         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
53896         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53897         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
53898         int64_t ret_ref = tag_ptr(ret_copy, true);
53899         return ret_ref;
53900 }
53901
53902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
53903         LDKThirtyTwoBytes a_ref;
53904         CHECK((*env)->GetArrayLength(env, a) == 32);
53905         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
53906         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53907         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
53908         int64_t ret_ref = tag_ptr(ret_copy, true);
53909         return ret_ref;
53910 }
53911
53912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53913         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
53914         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
53915         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
53916         return ret_conv;
53917 }
53918
53919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
53920         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
53921         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
53922         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53923         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53924         CVec_u8Z_free(ret_var);
53925         return ret_arr;
53926 }
53927
53928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53929         LDKu8slice ser_ref;
53930         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53931         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53932         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
53933         *ret_conv = PaymentPurpose_read(ser_ref);
53934         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53935         return tag_ptr(ret_conv, true);
53936 }
53937
53938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PathFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53939         if (!ptr_is_owned(this_ptr)) return;
53940         void* this_ptr_ptr = untag_ptr(this_ptr);
53941         CHECK_ACCESS(this_ptr_ptr);
53942         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
53943         FREE(untag_ptr(this_ptr));
53944         PathFailure_free(this_ptr_conv);
53945 }
53946
53947 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
53948         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53949         *ret_copy = PathFailure_clone(arg);
53950         int64_t ret_ref = tag_ptr(ret_copy, true);
53951         return ret_ref;
53952 }
53953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53954         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
53955         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
53956         return ret_conv;
53957 }
53958
53959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53960         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
53961         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53962         *ret_copy = PathFailure_clone(orig_conv);
53963         int64_t ret_ref = tag_ptr(ret_copy, true);
53964         return ret_ref;
53965 }
53966
53967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1initial_1send(JNIEnv *env, jclass clz, int64_t err) {
53968         void* err_ptr = untag_ptr(err);
53969         CHECK_ACCESS(err_ptr);
53970         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
53971         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
53972         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53973         *ret_copy = PathFailure_initial_send(err_conv);
53974         int64_t ret_ref = tag_ptr(ret_copy, true);
53975         return ret_ref;
53976 }
53977
53978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1on_1path(JNIEnv *env, jclass clz, int64_t network_update) {
53979         void* network_update_ptr = untag_ptr(network_update);
53980         CHECK_ACCESS(network_update_ptr);
53981         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
53982         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
53983         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53984         *ret_copy = PathFailure_on_path(network_update_conv);
53985         int64_t ret_ref = tag_ptr(ret_copy, true);
53986         return ret_ref;
53987 }
53988
53989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PathFailure_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53990         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
53991         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
53992         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
53993         return ret_conv;
53994 }
53995
53996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PathFailure_1write(JNIEnv *env, jclass clz, int64_t obj) {
53997         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
53998         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
53999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54001         CVec_u8Z_free(ret_var);
54002         return ret_arr;
54003 }
54004
54005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54006         LDKu8slice ser_ref;
54007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54009         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
54010         *ret_conv = PathFailure_read(ser_ref);
54011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54012         return tag_ptr(ret_conv, true);
54013 }
54014
54015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54016         if (!ptr_is_owned(this_ptr)) return;
54017         void* this_ptr_ptr = untag_ptr(this_ptr);
54018         CHECK_ACCESS(this_ptr_ptr);
54019         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
54020         FREE(untag_ptr(this_ptr));
54021         ClosureReason_free(this_ptr_conv);
54022 }
54023
54024 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
54025         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54026         *ret_copy = ClosureReason_clone(arg);
54027         int64_t ret_ref = tag_ptr(ret_copy, true);
54028         return ret_ref;
54029 }
54030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54031         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
54032         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
54033         return ret_conv;
54034 }
54035
54036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54037         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
54038         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54039         *ret_copy = ClosureReason_clone(orig_conv);
54040         int64_t ret_ref = tag_ptr(ret_copy, true);
54041         return ret_ref;
54042 }
54043
54044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, int64_t peer_msg) {
54045         LDKUntrustedString peer_msg_conv;
54046         peer_msg_conv.inner = untag_ptr(peer_msg);
54047         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
54048         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
54049         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
54050         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54051         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
54052         int64_t ret_ref = tag_ptr(ret_copy, true);
54053         return ret_ref;
54054 }
54055
54056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
54057         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54058         *ret_copy = ClosureReason_holder_force_closed();
54059         int64_t ret_ref = tag_ptr(ret_copy, true);
54060         return ret_ref;
54061 }
54062
54063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
54064         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54065         *ret_copy = ClosureReason_cooperative_closure();
54066         int64_t ret_ref = tag_ptr(ret_copy, true);
54067         return ret_ref;
54068 }
54069
54070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
54071         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54072         *ret_copy = ClosureReason_commitment_tx_confirmed();
54073         int64_t ret_ref = tag_ptr(ret_copy, true);
54074         return ret_ref;
54075 }
54076
54077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
54078         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54079         *ret_copy = ClosureReason_funding_timed_out();
54080         int64_t ret_ref = tag_ptr(ret_copy, true);
54081         return ret_ref;
54082 }
54083
54084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
54085         LDKStr err_conv = java_to_owned_str(env, err);
54086         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54087         *ret_copy = ClosureReason_processing_error(err_conv);
54088         int64_t ret_ref = tag_ptr(ret_copy, true);
54089         return ret_ref;
54090 }
54091
54092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
54093         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54094         *ret_copy = ClosureReason_disconnected_peer();
54095         int64_t ret_ref = tag_ptr(ret_copy, true);
54096         return ret_ref;
54097 }
54098
54099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
54100         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54101         *ret_copy = ClosureReason_outdated_channel_manager();
54102         int64_t ret_ref = tag_ptr(ret_copy, true);
54103         return ret_ref;
54104 }
54105
54106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54107         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
54108         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
54109         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
54110         return ret_conv;
54111 }
54112
54113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54114         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
54115         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
54116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54118         CVec_u8Z_free(ret_var);
54119         return ret_arr;
54120 }
54121
54122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54123         LDKu8slice ser_ref;
54124         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54125         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54126         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
54127         *ret_conv = ClosureReason_read(ser_ref);
54128         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54129         return tag_ptr(ret_conv, true);
54130 }
54131
54132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54133         if (!ptr_is_owned(this_ptr)) return;
54134         void* this_ptr_ptr = untag_ptr(this_ptr);
54135         CHECK_ACCESS(this_ptr_ptr);
54136         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
54137         FREE(untag_ptr(this_ptr));
54138         HTLCDestination_free(this_ptr_conv);
54139 }
54140
54141 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
54142         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54143         *ret_copy = HTLCDestination_clone(arg);
54144         int64_t ret_ref = tag_ptr(ret_copy, true);
54145         return ret_ref;
54146 }
54147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54148         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
54149         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
54150         return ret_conv;
54151 }
54152
54153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54154         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
54155         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54156         *ret_copy = HTLCDestination_clone(orig_conv);
54157         int64_t ret_ref = tag_ptr(ret_copy, true);
54158         return ret_ref;
54159 }
54160
54161 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) {
54162         LDKPublicKey node_id_ref;
54163         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54164         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54165         LDKThirtyTwoBytes channel_id_ref;
54166         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54167         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54168         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54169         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
54170         int64_t ret_ref = tag_ptr(ret_copy, true);
54171         return ret_ref;
54172 }
54173
54174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54175         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54176         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
54177         int64_t ret_ref = tag_ptr(ret_copy, true);
54178         return ret_ref;
54179 }
54180
54181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54182         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54183         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
54184         int64_t ret_ref = tag_ptr(ret_copy, true);
54185         return ret_ref;
54186 }
54187
54188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
54189         LDKThirtyTwoBytes payment_hash_ref;
54190         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54191         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54192         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54193         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
54194         int64_t ret_ref = tag_ptr(ret_copy, true);
54195         return ret_ref;
54196 }
54197
54198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54199         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
54200         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
54201         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
54202         return ret_conv;
54203 }
54204
54205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
54206         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
54207         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
54208         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54209         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54210         CVec_u8Z_free(ret_var);
54211         return ret_arr;
54212 }
54213
54214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54215         LDKu8slice ser_ref;
54216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54218         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
54219         *ret_conv = HTLCDestination_read(ser_ref);
54220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54221         return tag_ptr(ret_conv, true);
54222 }
54223
54224 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54225         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
54226         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_clone(orig_conv));
54227         return ret_conv;
54228 }
54229
54230 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1recipient_1rejected(JNIEnv *env, jclass clz) {
54231         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_recipient_rejected());
54232         return ret_conv;
54233 }
54234
54235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1user_1abandoned(JNIEnv *env, jclass clz) {
54236         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_user_abandoned());
54237         return ret_conv;
54238 }
54239
54240 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1retries_1exhausted(JNIEnv *env, jclass clz) {
54241         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_retries_exhausted());
54242         return ret_conv;
54243 }
54244
54245 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1payment_1expired(JNIEnv *env, jclass clz) {
54246         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_payment_expired());
54247         return ret_conv;
54248 }
54249
54250 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1route_1not_1found(JNIEnv *env, jclass clz) {
54251         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_route_not_found());
54252         return ret_conv;
54253 }
54254
54255 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1unexpected_1error(JNIEnv *env, jclass clz) {
54256         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_unexpected_error());
54257         return ret_conv;
54258 }
54259
54260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54261         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
54262         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
54263         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
54264         return ret_conv;
54265 }
54266
54267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54268         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
54269         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
54270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54272         CVec_u8Z_free(ret_var);
54273         return ret_arr;
54274 }
54275
54276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54277         LDKu8slice ser_ref;
54278         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54279         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54280         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
54281         *ret_conv = PaymentFailureReason_read(ser_ref);
54282         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54283         return tag_ptr(ret_conv, true);
54284 }
54285
54286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54287         if (!ptr_is_owned(this_ptr)) return;
54288         void* this_ptr_ptr = untag_ptr(this_ptr);
54289         CHECK_ACCESS(this_ptr_ptr);
54290         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
54291         FREE(untag_ptr(this_ptr));
54292         Event_free(this_ptr_conv);
54293 }
54294
54295 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
54296         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54297         *ret_copy = Event_clone(arg);
54298         int64_t ret_ref = tag_ptr(ret_copy, true);
54299         return ret_ref;
54300 }
54301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54302         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
54303         int64_t ret_conv = Event_clone_ptr(arg_conv);
54304         return ret_conv;
54305 }
54306
54307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54308         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
54309         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54310         *ret_copy = Event_clone(orig_conv);
54311         int64_t ret_ref = tag_ptr(ret_copy, true);
54312         return ret_ref;
54313 }
54314
54315 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) {
54316         LDKThirtyTwoBytes temporary_channel_id_ref;
54317         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54318         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54319         LDKPublicKey counterparty_node_id_ref;
54320         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54321         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54322         LDKCVec_u8Z output_script_ref;
54323         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
54324         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
54325         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
54326         LDKU128 user_channel_id_ref;
54327         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54328         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54329         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54330         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
54331         int64_t ret_ref = tag_ptr(ret_copy, true);
54332         return ret_ref;
54333 }
54334
54335 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 onion_fields, int64_t amount_msat, int64_t purpose, int8_tArray via_channel_id, int64_t via_user_channel_id, int64_t claim_deadline) {
54336         LDKPublicKey receiver_node_id_ref;
54337         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54338         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54339         LDKThirtyTwoBytes payment_hash_ref;
54340         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54341         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54342         LDKRecipientOnionFields onion_fields_conv;
54343         onion_fields_conv.inner = untag_ptr(onion_fields);
54344         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
54345         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
54346         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
54347         void* purpose_ptr = untag_ptr(purpose);
54348         CHECK_ACCESS(purpose_ptr);
54349         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54350         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54351         LDKThirtyTwoBytes via_channel_id_ref;
54352         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
54353         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
54354         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
54355         CHECK_ACCESS(via_user_channel_id_ptr);
54356         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
54357         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
54358         void* claim_deadline_ptr = untag_ptr(claim_deadline);
54359         CHECK_ACCESS(claim_deadline_ptr);
54360         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
54361         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
54362         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54363         *ret_copy = Event_payment_claimable(receiver_node_id_ref, payment_hash_ref, onion_fields_conv, amount_msat, purpose_conv, via_channel_id_ref, via_user_channel_id_conv, claim_deadline_conv);
54364         int64_t ret_ref = tag_ptr(ret_copy, true);
54365         return ret_ref;
54366 }
54367
54368 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) {
54369         LDKPublicKey receiver_node_id_ref;
54370         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54371         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54372         LDKThirtyTwoBytes payment_hash_ref;
54373         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54374         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54375         void* purpose_ptr = untag_ptr(purpose);
54376         CHECK_ACCESS(purpose_ptr);
54377         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54378         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54379         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54380         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
54381         int64_t ret_ref = tag_ptr(ret_copy, true);
54382         return ret_ref;
54383 }
54384
54385 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) {
54386         LDKThirtyTwoBytes payment_id_ref;
54387         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54388         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54389         LDKThirtyTwoBytes payment_preimage_ref;
54390         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
54391         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
54392         LDKThirtyTwoBytes payment_hash_ref;
54393         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54394         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54395         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
54396         CHECK_ACCESS(fee_paid_msat_ptr);
54397         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
54398         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
54399         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54400         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
54401         int64_t ret_ref = tag_ptr(ret_copy, true);
54402         return ret_ref;
54403 }
54404
54405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
54406         LDKThirtyTwoBytes payment_id_ref;
54407         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54408         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54409         LDKThirtyTwoBytes payment_hash_ref;
54410         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54411         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54412         void* reason_ptr = untag_ptr(reason);
54413         CHECK_ACCESS(reason_ptr);
54414         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
54415         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
54416         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54417         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
54418         int64_t ret_ref = tag_ptr(ret_copy, true);
54419         return ret_ref;
54420 }
54421
54422 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_t path) {
54423         LDKThirtyTwoBytes payment_id_ref;
54424         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54425         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54426         LDKThirtyTwoBytes payment_hash_ref;
54427         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54428         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54429         LDKPath path_conv;
54430         path_conv.inner = untag_ptr(path);
54431         path_conv.is_owned = ptr_is_owned(path);
54432         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54433         path_conv = Path_clone(&path_conv);
54434         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54435         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_conv);
54436         int64_t ret_ref = tag_ptr(ret_copy, true);
54437         return ret_ref;
54438 }
54439
54440 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 failure, int64_t path, int64_t short_channel_id) {
54441         LDKThirtyTwoBytes payment_id_ref;
54442         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54443         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54444         LDKThirtyTwoBytes payment_hash_ref;
54445         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54446         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54447         void* failure_ptr = untag_ptr(failure);
54448         CHECK_ACCESS(failure_ptr);
54449         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
54450         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
54451         LDKPath path_conv;
54452         path_conv.inner = untag_ptr(path);
54453         path_conv.is_owned = ptr_is_owned(path);
54454         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54455         path_conv = Path_clone(&path_conv);
54456         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54457         CHECK_ACCESS(short_channel_id_ptr);
54458         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54459         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54460         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54461         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
54462         int64_t ret_ref = tag_ptr(ret_copy, true);
54463         return ret_ref;
54464 }
54465
54466 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_t path) {
54467         LDKThirtyTwoBytes payment_id_ref;
54468         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54469         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54470         LDKThirtyTwoBytes payment_hash_ref;
54471         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54472         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54473         LDKPath path_conv;
54474         path_conv.inner = untag_ptr(path);
54475         path_conv.is_owned = ptr_is_owned(path);
54476         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54477         path_conv = Path_clone(&path_conv);
54478         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54479         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
54480         int64_t ret_ref = tag_ptr(ret_copy, true);
54481         return ret_ref;
54482 }
54483
54484 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_t path, int64_t short_channel_id) {
54485         LDKThirtyTwoBytes payment_id_ref;
54486         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54487         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54488         LDKThirtyTwoBytes payment_hash_ref;
54489         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54490         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54491         LDKPath path_conv;
54492         path_conv.inner = untag_ptr(path);
54493         path_conv.is_owned = ptr_is_owned(path);
54494         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54495         path_conv = Path_clone(&path_conv);
54496         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54497         CHECK_ACCESS(short_channel_id_ptr);
54498         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54499         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54500         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54501         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
54502         int64_t ret_ref = tag_ptr(ret_copy, true);
54503         return ret_ref;
54504 }
54505
54506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
54507         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54508         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
54509         int64_t ret_ref = tag_ptr(ret_copy, true);
54510         return ret_ref;
54511 }
54512
54513 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) {
54514         LDKThirtyTwoBytes intercept_id_ref;
54515         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
54516         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
54517         LDKThirtyTwoBytes payment_hash_ref;
54518         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54519         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54520         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54521         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
54522         int64_t ret_ref = tag_ptr(ret_copy, true);
54523         return ret_ref;
54524 }
54525
54526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
54527         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
54528         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
54529         if (outputs_constr.datalen > 0)
54530                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
54531         else
54532                 outputs_constr.data = NULL;
54533         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
54534         for (size_t b = 0; b < outputs_constr.datalen; b++) {
54535                 int64_t outputs_conv_27 = outputs_vals[b];
54536                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
54537                 CHECK_ACCESS(outputs_conv_27_ptr);
54538                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
54539                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
54540                 outputs_constr.data[b] = outputs_conv_27_conv;
54541         }
54542         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
54543         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54544         *ret_copy = Event_spendable_outputs(outputs_constr);
54545         int64_t ret_ref = tag_ptr(ret_copy, true);
54546         return ret_ref;
54547 }
54548
54549 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, int64_t outbound_amount_forwarded_msat) {
54550         LDKThirtyTwoBytes prev_channel_id_ref;
54551         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54552         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54553         LDKThirtyTwoBytes next_channel_id_ref;
54554         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
54555         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
54556         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
54557         CHECK_ACCESS(fee_earned_msat_ptr);
54558         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
54559         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
54560         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
54561         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
54562         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
54563         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
54564         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54565         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx, outbound_amount_forwarded_msat_conv);
54566         int64_t ret_ref = tag_ptr(ret_copy, true);
54567         return ret_ref;
54568 }
54569
54570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1pending(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray user_channel_id, int8_tArray former_temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_txo) {
54571         LDKThirtyTwoBytes channel_id_ref;
54572         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54573         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54574         LDKU128 user_channel_id_ref;
54575         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54576         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54577         LDKThirtyTwoBytes former_temporary_channel_id_ref;
54578         CHECK((*env)->GetArrayLength(env, former_temporary_channel_id) == 32);
54579         (*env)->GetByteArrayRegion(env, former_temporary_channel_id, 0, 32, former_temporary_channel_id_ref.data);
54580         LDKPublicKey counterparty_node_id_ref;
54581         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54582         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54583         LDKOutPoint funding_txo_conv;
54584         funding_txo_conv.inner = untag_ptr(funding_txo);
54585         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
54586         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
54587         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
54588         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54589         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_ref, counterparty_node_id_ref, funding_txo_conv);
54590         int64_t ret_ref = tag_ptr(ret_copy, true);
54591         return ret_ref;
54592 }
54593
54594 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) {
54595         LDKThirtyTwoBytes channel_id_ref;
54596         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54597         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54598         LDKU128 user_channel_id_ref;
54599         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54600         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54601         LDKPublicKey counterparty_node_id_ref;
54602         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54603         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54604         LDKChannelTypeFeatures channel_type_conv;
54605         channel_type_conv.inner = untag_ptr(channel_type);
54606         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54607         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54608         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54609         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54610         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
54611         int64_t ret_ref = tag_ptr(ret_copy, true);
54612         return ret_ref;
54613 }
54614
54615 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) {
54616         LDKThirtyTwoBytes channel_id_ref;
54617         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54618         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54619         LDKU128 user_channel_id_ref;
54620         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54621         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54622         void* reason_ptr = untag_ptr(reason);
54623         CHECK_ACCESS(reason_ptr);
54624         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
54625         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
54626         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54627         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
54628         int64_t ret_ref = tag_ptr(ret_copy, true);
54629         return ret_ref;
54630 }
54631
54632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
54633         LDKThirtyTwoBytes channel_id_ref;
54634         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54635         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54636         LDKTransaction transaction_ref;
54637         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
54638         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
54639         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
54640         transaction_ref.data_is_owned = true;
54641         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54642         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
54643         int64_t ret_ref = tag_ptr(ret_copy, true);
54644         return ret_ref;
54645 }
54646
54647 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) {
54648         LDKThirtyTwoBytes temporary_channel_id_ref;
54649         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54650         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54651         LDKPublicKey counterparty_node_id_ref;
54652         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54653         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54654         LDKChannelTypeFeatures channel_type_conv;
54655         channel_type_conv.inner = untag_ptr(channel_type);
54656         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54657         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54658         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54659         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54660         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
54661         int64_t ret_ref = tag_ptr(ret_copy, true);
54662         return ret_ref;
54663 }
54664
54665 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) {
54666         LDKThirtyTwoBytes prev_channel_id_ref;
54667         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54668         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54669         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
54670         CHECK_ACCESS(failed_next_destination_ptr);
54671         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
54672         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
54673         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54674         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
54675         int64_t ret_ref = tag_ptr(ret_copy, true);
54676         return ret_ref;
54677 }
54678
54679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Event_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54680         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
54681         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
54682         jboolean ret_conv = Event_eq(a_conv, b_conv);
54683         return ret_conv;
54684 }
54685
54686 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
54687         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
54688         LDKCVec_u8Z ret_var = Event_write(obj_conv);
54689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54691         CVec_u8Z_free(ret_var);
54692         return ret_arr;
54693 }
54694
54695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54696         LDKu8slice ser_ref;
54697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54699         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
54700         *ret_conv = Event_read(ser_ref);
54701         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54702         return tag_ptr(ret_conv, true);
54703 }
54704
54705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54706         if (!ptr_is_owned(this_ptr)) return;
54707         void* this_ptr_ptr = untag_ptr(this_ptr);
54708         CHECK_ACCESS(this_ptr_ptr);
54709         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
54710         FREE(untag_ptr(this_ptr));
54711         MessageSendEvent_free(this_ptr_conv);
54712 }
54713
54714 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
54715         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54716         *ret_copy = MessageSendEvent_clone(arg);
54717         int64_t ret_ref = tag_ptr(ret_copy, true);
54718         return ret_ref;
54719 }
54720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54721         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
54722         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
54723         return ret_conv;
54724 }
54725
54726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54727         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
54728         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54729         *ret_copy = MessageSendEvent_clone(orig_conv);
54730         int64_t ret_ref = tag_ptr(ret_copy, true);
54731         return ret_ref;
54732 }
54733
54734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54735         LDKPublicKey node_id_ref;
54736         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54737         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54738         LDKAcceptChannel msg_conv;
54739         msg_conv.inner = untag_ptr(msg);
54740         msg_conv.is_owned = ptr_is_owned(msg);
54741         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54742         msg_conv = AcceptChannel_clone(&msg_conv);
54743         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54744         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
54745         int64_t ret_ref = tag_ptr(ret_copy, true);
54746         return ret_ref;
54747 }
54748
54749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54750         LDKPublicKey node_id_ref;
54751         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54752         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54753         LDKOpenChannel msg_conv;
54754         msg_conv.inner = untag_ptr(msg);
54755         msg_conv.is_owned = ptr_is_owned(msg);
54756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54757         msg_conv = OpenChannel_clone(&msg_conv);
54758         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54759         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
54760         int64_t ret_ref = tag_ptr(ret_copy, true);
54761         return ret_ref;
54762 }
54763
54764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54765         LDKPublicKey node_id_ref;
54766         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54767         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54768         LDKFundingCreated msg_conv;
54769         msg_conv.inner = untag_ptr(msg);
54770         msg_conv.is_owned = ptr_is_owned(msg);
54771         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54772         msg_conv = FundingCreated_clone(&msg_conv);
54773         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54774         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
54775         int64_t ret_ref = tag_ptr(ret_copy, true);
54776         return ret_ref;
54777 }
54778
54779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54780         LDKPublicKey node_id_ref;
54781         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54782         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54783         LDKFundingSigned msg_conv;
54784         msg_conv.inner = untag_ptr(msg);
54785         msg_conv.is_owned = ptr_is_owned(msg);
54786         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54787         msg_conv = FundingSigned_clone(&msg_conv);
54788         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54789         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
54790         int64_t ret_ref = tag_ptr(ret_copy, true);
54791         return ret_ref;
54792 }
54793
54794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54795         LDKPublicKey node_id_ref;
54796         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54797         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54798         LDKChannelReady msg_conv;
54799         msg_conv.inner = untag_ptr(msg);
54800         msg_conv.is_owned = ptr_is_owned(msg);
54801         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54802         msg_conv = ChannelReady_clone(&msg_conv);
54803         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54804         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
54805         int64_t ret_ref = tag_ptr(ret_copy, true);
54806         return ret_ref;
54807 }
54808
54809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54810         LDKPublicKey node_id_ref;
54811         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54812         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54813         LDKAnnouncementSignatures msg_conv;
54814         msg_conv.inner = untag_ptr(msg);
54815         msg_conv.is_owned = ptr_is_owned(msg);
54816         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54817         msg_conv = AnnouncementSignatures_clone(&msg_conv);
54818         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54819         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
54820         int64_t ret_ref = tag_ptr(ret_copy, true);
54821         return ret_ref;
54822 }
54823
54824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
54825         LDKPublicKey node_id_ref;
54826         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54827         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54828         LDKCommitmentUpdate updates_conv;
54829         updates_conv.inner = untag_ptr(updates);
54830         updates_conv.is_owned = ptr_is_owned(updates);
54831         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
54832         updates_conv = CommitmentUpdate_clone(&updates_conv);
54833         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54834         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
54835         int64_t ret_ref = tag_ptr(ret_copy, true);
54836         return ret_ref;
54837 }
54838
54839 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) {
54840         LDKPublicKey node_id_ref;
54841         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54842         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54843         LDKRevokeAndACK msg_conv;
54844         msg_conv.inner = untag_ptr(msg);
54845         msg_conv.is_owned = ptr_is_owned(msg);
54846         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54847         msg_conv = RevokeAndACK_clone(&msg_conv);
54848         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54849         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
54850         int64_t ret_ref = tag_ptr(ret_copy, true);
54851         return ret_ref;
54852 }
54853
54854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54855         LDKPublicKey node_id_ref;
54856         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54857         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54858         LDKClosingSigned msg_conv;
54859         msg_conv.inner = untag_ptr(msg);
54860         msg_conv.is_owned = ptr_is_owned(msg);
54861         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54862         msg_conv = ClosingSigned_clone(&msg_conv);
54863         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54864         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
54865         int64_t ret_ref = tag_ptr(ret_copy, true);
54866         return ret_ref;
54867 }
54868
54869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54870         LDKPublicKey node_id_ref;
54871         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54872         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54873         LDKShutdown msg_conv;
54874         msg_conv.inner = untag_ptr(msg);
54875         msg_conv.is_owned = ptr_is_owned(msg);
54876         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54877         msg_conv = Shutdown_clone(&msg_conv);
54878         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54879         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
54880         int64_t ret_ref = tag_ptr(ret_copy, true);
54881         return ret_ref;
54882 }
54883
54884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54885         LDKPublicKey node_id_ref;
54886         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54887         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54888         LDKChannelReestablish msg_conv;
54889         msg_conv.inner = untag_ptr(msg);
54890         msg_conv.is_owned = ptr_is_owned(msg);
54891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54892         msg_conv = ChannelReestablish_clone(&msg_conv);
54893         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54894         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
54895         int64_t ret_ref = tag_ptr(ret_copy, true);
54896         return ret_ref;
54897 }
54898
54899 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) {
54900         LDKPublicKey node_id_ref;
54901         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54902         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54903         LDKChannelAnnouncement msg_conv;
54904         msg_conv.inner = untag_ptr(msg);
54905         msg_conv.is_owned = ptr_is_owned(msg);
54906         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54907         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54908         LDKChannelUpdate update_msg_conv;
54909         update_msg_conv.inner = untag_ptr(update_msg);
54910         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54911         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54912         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54913         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54914         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
54915         int64_t ret_ref = tag_ptr(ret_copy, true);
54916         return ret_ref;
54917 }
54918
54919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
54920         LDKChannelAnnouncement msg_conv;
54921         msg_conv.inner = untag_ptr(msg);
54922         msg_conv.is_owned = ptr_is_owned(msg);
54923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54924         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54925         LDKChannelUpdate update_msg_conv;
54926         update_msg_conv.inner = untag_ptr(update_msg);
54927         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54928         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54929         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54930         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54931         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
54932         int64_t ret_ref = tag_ptr(ret_copy, true);
54933         return ret_ref;
54934 }
54935
54936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
54937         LDKChannelUpdate msg_conv;
54938         msg_conv.inner = untag_ptr(msg);
54939         msg_conv.is_owned = ptr_is_owned(msg);
54940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54941         msg_conv = ChannelUpdate_clone(&msg_conv);
54942         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54943         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
54944         int64_t ret_ref = tag_ptr(ret_copy, true);
54945         return ret_ref;
54946 }
54947
54948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
54949         LDKNodeAnnouncement msg_conv;
54950         msg_conv.inner = untag_ptr(msg);
54951         msg_conv.is_owned = ptr_is_owned(msg);
54952         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54953         msg_conv = NodeAnnouncement_clone(&msg_conv);
54954         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54955         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
54956         int64_t ret_ref = tag_ptr(ret_copy, true);
54957         return ret_ref;
54958 }
54959
54960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54961         LDKPublicKey node_id_ref;
54962         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54963         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54964         LDKChannelUpdate msg_conv;
54965         msg_conv.inner = untag_ptr(msg);
54966         msg_conv.is_owned = ptr_is_owned(msg);
54967         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54968         msg_conv = ChannelUpdate_clone(&msg_conv);
54969         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54970         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
54971         int64_t ret_ref = tag_ptr(ret_copy, true);
54972         return ret_ref;
54973 }
54974
54975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
54976         LDKPublicKey node_id_ref;
54977         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54978         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54979         void* action_ptr = untag_ptr(action);
54980         CHECK_ACCESS(action_ptr);
54981         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
54982         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
54983         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54984         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
54985         int64_t ret_ref = tag_ptr(ret_copy, true);
54986         return ret_ref;
54987 }
54988
54989 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) {
54990         LDKPublicKey node_id_ref;
54991         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54992         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54993         LDKQueryChannelRange msg_conv;
54994         msg_conv.inner = untag_ptr(msg);
54995         msg_conv.is_owned = ptr_is_owned(msg);
54996         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54997         msg_conv = QueryChannelRange_clone(&msg_conv);
54998         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54999         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
55000         int64_t ret_ref = tag_ptr(ret_copy, true);
55001         return ret_ref;
55002 }
55003
55004 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) {
55005         LDKPublicKey node_id_ref;
55006         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55007         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55008         LDKQueryShortChannelIds msg_conv;
55009         msg_conv.inner = untag_ptr(msg);
55010         msg_conv.is_owned = ptr_is_owned(msg);
55011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55012         msg_conv = QueryShortChannelIds_clone(&msg_conv);
55013         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55014         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
55015         int64_t ret_ref = tag_ptr(ret_copy, true);
55016         return ret_ref;
55017 }
55018
55019 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) {
55020         LDKPublicKey node_id_ref;
55021         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55022         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55023         LDKReplyChannelRange msg_conv;
55024         msg_conv.inner = untag_ptr(msg);
55025         msg_conv.is_owned = ptr_is_owned(msg);
55026         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55027         msg_conv = ReplyChannelRange_clone(&msg_conv);
55028         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55029         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
55030         int64_t ret_ref = tag_ptr(ret_copy, true);
55031         return ret_ref;
55032 }
55033
55034 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) {
55035         LDKPublicKey node_id_ref;
55036         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55037         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55038         LDKGossipTimestampFilter msg_conv;
55039         msg_conv.inner = untag_ptr(msg);
55040         msg_conv.is_owned = ptr_is_owned(msg);
55041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55042         msg_conv = GossipTimestampFilter_clone(&msg_conv);
55043         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55044         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
55045         int64_t ret_ref = tag_ptr(ret_copy, true);
55046         return ret_ref;
55047 }
55048
55049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55050         if (!ptr_is_owned(this_ptr)) return;
55051         void* this_ptr_ptr = untag_ptr(this_ptr);
55052         CHECK_ACCESS(this_ptr_ptr);
55053         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
55054         FREE(untag_ptr(this_ptr));
55055         MessageSendEventsProvider_free(this_ptr_conv);
55056 }
55057
55058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55059         if (!ptr_is_owned(this_ptr)) return;
55060         void* this_ptr_ptr = untag_ptr(this_ptr);
55061         CHECK_ACCESS(this_ptr_ptr);
55062         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
55063         FREE(untag_ptr(this_ptr));
55064         OnionMessageProvider_free(this_ptr_conv);
55065 }
55066
55067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55068         if (!ptr_is_owned(this_ptr)) return;
55069         void* this_ptr_ptr = untag_ptr(this_ptr);
55070         CHECK_ACCESS(this_ptr_ptr);
55071         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
55072         FREE(untag_ptr(this_ptr));
55073         EventsProvider_free(this_ptr_conv);
55074 }
55075
55076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55077         if (!ptr_is_owned(this_ptr)) return;
55078         void* this_ptr_ptr = untag_ptr(this_ptr);
55079         CHECK_ACCESS(this_ptr_ptr);
55080         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
55081         FREE(untag_ptr(this_ptr));
55082         EventHandler_free(this_ptr_conv);
55083 }
55084
55085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55086         LDKFilesystemPersister this_obj_conv;
55087         this_obj_conv.inner = untag_ptr(this_obj);
55088         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55090         FilesystemPersister_free(this_obj_conv);
55091 }
55092
55093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
55094         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
55095         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
55096         int64_t ret_ref = 0;
55097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55099         return ret_ref;
55100 }
55101
55102 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
55103         LDKFilesystemPersister this_arg_conv;
55104         this_arg_conv.inner = untag_ptr(this_arg);
55105         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55107         this_arg_conv.is_owned = false;
55108         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
55109         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
55110         Str_free(ret_str);
55111         return ret_conv;
55112 }
55113
55114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t entropy_source, int64_t signer_provider) {
55115         LDKFilesystemPersister this_arg_conv;
55116         this_arg_conv.inner = untag_ptr(this_arg);
55117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55119         this_arg_conv.is_owned = false;
55120         void* entropy_source_ptr = untag_ptr(entropy_source);
55121         CHECK_ACCESS(entropy_source_ptr);
55122         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
55123         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
55124                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55125                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
55126         }
55127         void* signer_provider_ptr = untag_ptr(signer_provider);
55128         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
55129         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
55130         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
55131         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, entropy_source_conv, signer_provider_conv);
55132         return tag_ptr(ret_conv, true);
55133 }
55134
55135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55136         LDKBackgroundProcessor this_obj_conv;
55137         this_obj_conv.inner = untag_ptr(this_obj);
55138         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55140         BackgroundProcessor_free(this_obj_conv);
55141 }
55142
55143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55144         if (!ptr_is_owned(this_ptr)) return;
55145         void* this_ptr_ptr = untag_ptr(this_ptr);
55146         CHECK_ACCESS(this_ptr_ptr);
55147         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
55148         FREE(untag_ptr(this_ptr));
55149         GossipSync_free(this_ptr_conv);
55150 }
55151
55152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
55153         LDKP2PGossipSync a_conv;
55154         a_conv.inner = untag_ptr(a);
55155         a_conv.is_owned = ptr_is_owned(a);
55156         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55157         a_conv.is_owned = false;
55158         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55159         *ret_copy = GossipSync_p2_p(&a_conv);
55160         int64_t ret_ref = tag_ptr(ret_copy, true);
55161         return ret_ref;
55162 }
55163
55164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
55165         LDKRapidGossipSync a_conv;
55166         a_conv.inner = untag_ptr(a);
55167         a_conv.is_owned = ptr_is_owned(a);
55168         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55169         a_conv.is_owned = false;
55170         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55171         *ret_copy = GossipSync_rapid(&a_conv);
55172         int64_t ret_ref = tag_ptr(ret_copy, true);
55173         return ret_ref;
55174 }
55175
55176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
55177         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55178         *ret_copy = GossipSync_none();
55179         int64_t ret_ref = tag_ptr(ret_copy, true);
55180         return ret_ref;
55181 }
55182
55183 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) {
55184         void* persister_ptr = untag_ptr(persister);
55185         CHECK_ACCESS(persister_ptr);
55186         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
55187         if (persister_conv.free == LDKPersister_JCalls_free) {
55188                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55189                 LDKPersister_JCalls_cloned(&persister_conv);
55190         }
55191         void* event_handler_ptr = untag_ptr(event_handler);
55192         CHECK_ACCESS(event_handler_ptr);
55193         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
55194         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
55195                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55196                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
55197         }
55198         LDKChainMonitor chain_monitor_conv;
55199         chain_monitor_conv.inner = untag_ptr(chain_monitor);
55200         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
55201         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
55202         chain_monitor_conv.is_owned = false;
55203         LDKChannelManager channel_manager_conv;
55204         channel_manager_conv.inner = untag_ptr(channel_manager);
55205         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
55206         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
55207         channel_manager_conv.is_owned = false;
55208         void* gossip_sync_ptr = untag_ptr(gossip_sync);
55209         CHECK_ACCESS(gossip_sync_ptr);
55210         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
55211         // WARNING: we may need a move here but no clone is available for LDKGossipSync
55212         LDKPeerManager peer_manager_conv;
55213         peer_manager_conv.inner = untag_ptr(peer_manager);
55214         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
55215         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
55216         peer_manager_conv.is_owned = false;
55217         void* logger_ptr = untag_ptr(logger);
55218         CHECK_ACCESS(logger_ptr);
55219         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
55220         if (logger_conv.free == LDKLogger_JCalls_free) {
55221                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55222                 LDKLogger_JCalls_cloned(&logger_conv);
55223         }
55224         void* scorer_ptr = untag_ptr(scorer);
55225         CHECK_ACCESS(scorer_ptr);
55226         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
55227         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
55228         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
55229                 // Manually implement clone for Java trait instances
55230                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
55231                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55232                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
55233                 }
55234         }
55235         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);
55236         int64_t ret_ref = 0;
55237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55239         return ret_ref;
55240 }
55241
55242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
55243         LDKBackgroundProcessor this_arg_conv;
55244         this_arg_conv.inner = untag_ptr(this_arg);
55245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55247         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55248         
55249         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55250         *ret_conv = BackgroundProcessor_join(this_arg_conv);
55251         return tag_ptr(ret_conv, true);
55252 }
55253
55254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
55255         LDKBackgroundProcessor this_arg_conv;
55256         this_arg_conv.inner = untag_ptr(this_arg);
55257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55259         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55260         
55261         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55262         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
55263         return tag_ptr(ret_conv, true);
55264 }
55265
55266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55267         if (!ptr_is_owned(this_ptr)) return;
55268         void* this_ptr_ptr = untag_ptr(this_ptr);
55269         CHECK_ACCESS(this_ptr_ptr);
55270         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
55271         FREE(untag_ptr(this_ptr));
55272         ParseError_free(this_ptr_conv);
55273 }
55274
55275 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
55276         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55277         *ret_copy = ParseError_clone(arg);
55278         int64_t ret_ref = tag_ptr(ret_copy, true);
55279         return ret_ref;
55280 }
55281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55282         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
55283         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
55284         return ret_conv;
55285 }
55286
55287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55288         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
55289         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55290         *ret_copy = ParseError_clone(orig_conv);
55291         int64_t ret_ref = tag_ptr(ret_copy, true);
55292         return ret_ref;
55293 }
55294
55295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
55296         void* a_ptr = untag_ptr(a);
55297         CHECK_ACCESS(a_ptr);
55298         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
55299         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
55300         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55301         *ret_copy = ParseError_bech32_error(a_conv);
55302         int64_t ret_ref = tag_ptr(ret_copy, true);
55303         return ret_ref;
55304 }
55305
55306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
55307         
55308         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55309         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
55310         int64_t ret_ref = tag_ptr(ret_copy, true);
55311         return ret_ref;
55312 }
55313
55314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
55315         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
55316         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55317         *ret_copy = ParseError_malformed_signature(a_conv);
55318         int64_t ret_ref = tag_ptr(ret_copy, true);
55319         return ret_ref;
55320 }
55321
55322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
55323         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55324         *ret_copy = ParseError_bad_prefix();
55325         int64_t ret_ref = tag_ptr(ret_copy, true);
55326         return ret_ref;
55327 }
55328
55329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
55330         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55331         *ret_copy = ParseError_unknown_currency();
55332         int64_t ret_ref = tag_ptr(ret_copy, true);
55333         return ret_ref;
55334 }
55335
55336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
55337         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55338         *ret_copy = ParseError_unknown_si_prefix();
55339         int64_t ret_ref = tag_ptr(ret_copy, true);
55340         return ret_ref;
55341 }
55342
55343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
55344         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55345         *ret_copy = ParseError_malformed_hrp();
55346         int64_t ret_ref = tag_ptr(ret_copy, true);
55347         return ret_ref;
55348 }
55349
55350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
55351         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55352         *ret_copy = ParseError_too_short_data_part();
55353         int64_t ret_ref = tag_ptr(ret_copy, true);
55354         return ret_ref;
55355 }
55356
55357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
55358         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55359         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
55360         int64_t ret_ref = tag_ptr(ret_copy, true);
55361         return ret_ref;
55362 }
55363
55364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
55365         
55366         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55367         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
55368         int64_t ret_ref = tag_ptr(ret_copy, true);
55369         return ret_ref;
55370 }
55371
55372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
55373         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55374         *ret_copy = ParseError_padding_error();
55375         int64_t ret_ref = tag_ptr(ret_copy, true);
55376         return ret_ref;
55377 }
55378
55379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
55380         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55381         *ret_copy = ParseError_integer_overflow_error();
55382         int64_t ret_ref = tag_ptr(ret_copy, true);
55383         return ret_ref;
55384 }
55385
55386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
55387         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55388         *ret_copy = ParseError_invalid_seg_wit_program_length();
55389         int64_t ret_ref = tag_ptr(ret_copy, true);
55390         return ret_ref;
55391 }
55392
55393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
55394         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55395         *ret_copy = ParseError_invalid_pub_key_hash_length();
55396         int64_t ret_ref = tag_ptr(ret_copy, true);
55397         return ret_ref;
55398 }
55399
55400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
55401         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55402         *ret_copy = ParseError_invalid_script_hash_length();
55403         int64_t ret_ref = tag_ptr(ret_copy, true);
55404         return ret_ref;
55405 }
55406
55407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
55408         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55409         *ret_copy = ParseError_invalid_recovery_id();
55410         int64_t ret_ref = tag_ptr(ret_copy, true);
55411         return ret_ref;
55412 }
55413
55414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
55415         LDKStr a_conv = java_to_owned_str(env, a);
55416         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55417         *ret_copy = ParseError_invalid_slice_length(a_conv);
55418         int64_t ret_ref = tag_ptr(ret_copy, true);
55419         return ret_ref;
55420 }
55421
55422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
55423         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55424         *ret_copy = ParseError_skip();
55425         int64_t ret_ref = tag_ptr(ret_copy, true);
55426         return ret_ref;
55427 }
55428
55429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55430         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
55431         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
55432         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
55433         return ret_conv;
55434 }
55435
55436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55437         if (!ptr_is_owned(this_ptr)) return;
55438         void* this_ptr_ptr = untag_ptr(this_ptr);
55439         CHECK_ACCESS(this_ptr_ptr);
55440         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
55441         FREE(untag_ptr(this_ptr));
55442         ParseOrSemanticError_free(this_ptr_conv);
55443 }
55444
55445 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
55446         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55447         *ret_copy = ParseOrSemanticError_clone(arg);
55448         int64_t ret_ref = tag_ptr(ret_copy, true);
55449         return ret_ref;
55450 }
55451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55452         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
55453         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
55454         return ret_conv;
55455 }
55456
55457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55458         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
55459         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55460         *ret_copy = ParseOrSemanticError_clone(orig_conv);
55461         int64_t ret_ref = tag_ptr(ret_copy, true);
55462         return ret_ref;
55463 }
55464
55465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
55466         void* a_ptr = untag_ptr(a);
55467         CHECK_ACCESS(a_ptr);
55468         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
55469         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
55470         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55471         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
55472         int64_t ret_ref = tag_ptr(ret_copy, true);
55473         return ret_ref;
55474 }
55475
55476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
55477         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
55478         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55479         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
55480         int64_t ret_ref = tag_ptr(ret_copy, true);
55481         return ret_ref;
55482 }
55483
55484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55485         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
55486         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
55487         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
55488         return ret_conv;
55489 }
55490
55491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55492         LDKInvoice this_obj_conv;
55493         this_obj_conv.inner = untag_ptr(this_obj);
55494         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55496         Invoice_free(this_obj_conv);
55497 }
55498
55499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55500         LDKInvoice a_conv;
55501         a_conv.inner = untag_ptr(a);
55502         a_conv.is_owned = ptr_is_owned(a);
55503         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55504         a_conv.is_owned = false;
55505         LDKInvoice b_conv;
55506         b_conv.inner = untag_ptr(b);
55507         b_conv.is_owned = ptr_is_owned(b);
55508         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55509         b_conv.is_owned = false;
55510         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
55511         return ret_conv;
55512 }
55513
55514 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
55515         LDKInvoice ret_var = Invoice_clone(arg);
55516         int64_t ret_ref = 0;
55517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55519         return ret_ref;
55520 }
55521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55522         LDKInvoice arg_conv;
55523         arg_conv.inner = untag_ptr(arg);
55524         arg_conv.is_owned = ptr_is_owned(arg);
55525         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55526         arg_conv.is_owned = false;
55527         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
55528         return ret_conv;
55529 }
55530
55531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55532         LDKInvoice orig_conv;
55533         orig_conv.inner = untag_ptr(orig);
55534         orig_conv.is_owned = ptr_is_owned(orig);
55535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55536         orig_conv.is_owned = false;
55537         LDKInvoice ret_var = Invoice_clone(&orig_conv);
55538         int64_t ret_ref = 0;
55539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55541         return ret_ref;
55542 }
55543
55544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55545         LDKInvoice o_conv;
55546         o_conv.inner = untag_ptr(o);
55547         o_conv.is_owned = ptr_is_owned(o);
55548         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55549         o_conv.is_owned = false;
55550         int64_t ret_conv = Invoice_hash(&o_conv);
55551         return ret_conv;
55552 }
55553
55554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55555         LDKSignedRawInvoice this_obj_conv;
55556         this_obj_conv.inner = untag_ptr(this_obj);
55557         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55559         SignedRawInvoice_free(this_obj_conv);
55560 }
55561
55562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55563         LDKSignedRawInvoice a_conv;
55564         a_conv.inner = untag_ptr(a);
55565         a_conv.is_owned = ptr_is_owned(a);
55566         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55567         a_conv.is_owned = false;
55568         LDKSignedRawInvoice b_conv;
55569         b_conv.inner = untag_ptr(b);
55570         b_conv.is_owned = ptr_is_owned(b);
55571         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55572         b_conv.is_owned = false;
55573         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
55574         return ret_conv;
55575 }
55576
55577 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
55578         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
55579         int64_t ret_ref = 0;
55580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55582         return ret_ref;
55583 }
55584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55585         LDKSignedRawInvoice arg_conv;
55586         arg_conv.inner = untag_ptr(arg);
55587         arg_conv.is_owned = ptr_is_owned(arg);
55588         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55589         arg_conv.is_owned = false;
55590         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
55591         return ret_conv;
55592 }
55593
55594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55595         LDKSignedRawInvoice orig_conv;
55596         orig_conv.inner = untag_ptr(orig);
55597         orig_conv.is_owned = ptr_is_owned(orig);
55598         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55599         orig_conv.is_owned = false;
55600         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
55601         int64_t ret_ref = 0;
55602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55604         return ret_ref;
55605 }
55606
55607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55608         LDKSignedRawInvoice o_conv;
55609         o_conv.inner = untag_ptr(o);
55610         o_conv.is_owned = ptr_is_owned(o);
55611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55612         o_conv.is_owned = false;
55613         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
55614         return ret_conv;
55615 }
55616
55617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55618         LDKRawInvoice this_obj_conv;
55619         this_obj_conv.inner = untag_ptr(this_obj);
55620         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55622         RawInvoice_free(this_obj_conv);
55623 }
55624
55625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
55626         LDKRawInvoice this_ptr_conv;
55627         this_ptr_conv.inner = untag_ptr(this_ptr);
55628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55630         this_ptr_conv.is_owned = false;
55631         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
55632         int64_t ret_ref = 0;
55633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55635         return ret_ref;
55636 }
55637
55638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55639         LDKRawInvoice this_ptr_conv;
55640         this_ptr_conv.inner = untag_ptr(this_ptr);
55641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55643         this_ptr_conv.is_owned = false;
55644         LDKRawDataPart val_conv;
55645         val_conv.inner = untag_ptr(val);
55646         val_conv.is_owned = ptr_is_owned(val);
55647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55648         val_conv = RawDataPart_clone(&val_conv);
55649         RawInvoice_set_data(&this_ptr_conv, val_conv);
55650 }
55651
55652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55653         LDKRawInvoice a_conv;
55654         a_conv.inner = untag_ptr(a);
55655         a_conv.is_owned = ptr_is_owned(a);
55656         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55657         a_conv.is_owned = false;
55658         LDKRawInvoice b_conv;
55659         b_conv.inner = untag_ptr(b);
55660         b_conv.is_owned = ptr_is_owned(b);
55661         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55662         b_conv.is_owned = false;
55663         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
55664         return ret_conv;
55665 }
55666
55667 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
55668         LDKRawInvoice ret_var = RawInvoice_clone(arg);
55669         int64_t ret_ref = 0;
55670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55672         return ret_ref;
55673 }
55674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55675         LDKRawInvoice arg_conv;
55676         arg_conv.inner = untag_ptr(arg);
55677         arg_conv.is_owned = ptr_is_owned(arg);
55678         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55679         arg_conv.is_owned = false;
55680         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
55681         return ret_conv;
55682 }
55683
55684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55685         LDKRawInvoice orig_conv;
55686         orig_conv.inner = untag_ptr(orig);
55687         orig_conv.is_owned = ptr_is_owned(orig);
55688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55689         orig_conv.is_owned = false;
55690         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
55691         int64_t ret_ref = 0;
55692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55694         return ret_ref;
55695 }
55696
55697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55698         LDKRawInvoice o_conv;
55699         o_conv.inner = untag_ptr(o);
55700         o_conv.is_owned = ptr_is_owned(o);
55701         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55702         o_conv.is_owned = false;
55703         int64_t ret_conv = RawInvoice_hash(&o_conv);
55704         return ret_conv;
55705 }
55706
55707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55708         LDKRawDataPart this_obj_conv;
55709         this_obj_conv.inner = untag_ptr(this_obj);
55710         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55712         RawDataPart_free(this_obj_conv);
55713 }
55714
55715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
55716         LDKRawDataPart this_ptr_conv;
55717         this_ptr_conv.inner = untag_ptr(this_ptr);
55718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55720         this_ptr_conv.is_owned = false;
55721         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
55722         int64_t ret_ref = 0;
55723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55725         return ret_ref;
55726 }
55727
55728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55729         LDKRawDataPart this_ptr_conv;
55730         this_ptr_conv.inner = untag_ptr(this_ptr);
55731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55733         this_ptr_conv.is_owned = false;
55734         LDKPositiveTimestamp val_conv;
55735         val_conv.inner = untag_ptr(val);
55736         val_conv.is_owned = ptr_is_owned(val);
55737         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55738         val_conv = PositiveTimestamp_clone(&val_conv);
55739         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
55740 }
55741
55742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55743         LDKRawDataPart a_conv;
55744         a_conv.inner = untag_ptr(a);
55745         a_conv.is_owned = ptr_is_owned(a);
55746         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55747         a_conv.is_owned = false;
55748         LDKRawDataPart b_conv;
55749         b_conv.inner = untag_ptr(b);
55750         b_conv.is_owned = ptr_is_owned(b);
55751         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55752         b_conv.is_owned = false;
55753         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
55754         return ret_conv;
55755 }
55756
55757 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
55758         LDKRawDataPart ret_var = RawDataPart_clone(arg);
55759         int64_t ret_ref = 0;
55760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55762         return ret_ref;
55763 }
55764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55765         LDKRawDataPart arg_conv;
55766         arg_conv.inner = untag_ptr(arg);
55767         arg_conv.is_owned = ptr_is_owned(arg);
55768         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55769         arg_conv.is_owned = false;
55770         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
55771         return ret_conv;
55772 }
55773
55774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55775         LDKRawDataPart orig_conv;
55776         orig_conv.inner = untag_ptr(orig);
55777         orig_conv.is_owned = ptr_is_owned(orig);
55778         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55779         orig_conv.is_owned = false;
55780         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
55781         int64_t ret_ref = 0;
55782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55784         return ret_ref;
55785 }
55786
55787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
55788         LDKRawDataPart o_conv;
55789         o_conv.inner = untag_ptr(o);
55790         o_conv.is_owned = ptr_is_owned(o);
55791         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55792         o_conv.is_owned = false;
55793         int64_t ret_conv = RawDataPart_hash(&o_conv);
55794         return ret_conv;
55795 }
55796
55797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55798         LDKPositiveTimestamp this_obj_conv;
55799         this_obj_conv.inner = untag_ptr(this_obj);
55800         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55802         PositiveTimestamp_free(this_obj_conv);
55803 }
55804
55805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55806         LDKPositiveTimestamp a_conv;
55807         a_conv.inner = untag_ptr(a);
55808         a_conv.is_owned = ptr_is_owned(a);
55809         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55810         a_conv.is_owned = false;
55811         LDKPositiveTimestamp b_conv;
55812         b_conv.inner = untag_ptr(b);
55813         b_conv.is_owned = ptr_is_owned(b);
55814         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55815         b_conv.is_owned = false;
55816         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
55817         return ret_conv;
55818 }
55819
55820 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
55821         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
55822         int64_t ret_ref = 0;
55823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55825         return ret_ref;
55826 }
55827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55828         LDKPositiveTimestamp arg_conv;
55829         arg_conv.inner = untag_ptr(arg);
55830         arg_conv.is_owned = ptr_is_owned(arg);
55831         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55832         arg_conv.is_owned = false;
55833         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
55834         return ret_conv;
55835 }
55836
55837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55838         LDKPositiveTimestamp orig_conv;
55839         orig_conv.inner = untag_ptr(orig);
55840         orig_conv.is_owned = ptr_is_owned(orig);
55841         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55842         orig_conv.is_owned = false;
55843         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
55844         int64_t ret_ref = 0;
55845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55847         return ret_ref;
55848 }
55849
55850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
55851         LDKPositiveTimestamp o_conv;
55852         o_conv.inner = untag_ptr(o);
55853         o_conv.is_owned = ptr_is_owned(o);
55854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55855         o_conv.is_owned = false;
55856         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
55857         return ret_conv;
55858 }
55859
55860 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55861         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
55862         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
55863         return ret_conv;
55864 }
55865
55866 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
55867         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
55868         return ret_conv;
55869 }
55870
55871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
55872         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
55873         return ret_conv;
55874 }
55875
55876 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
55877         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
55878         return ret_conv;
55879 }
55880
55881 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
55882         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
55883         return ret_conv;
55884 }
55885
55886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55887         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
55888         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
55889         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
55890         return ret_conv;
55891 }
55892
55893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
55894         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
55895         int64_t ret_conv = SiPrefix_hash(o_conv);
55896         return ret_conv;
55897 }
55898
55899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
55900         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
55901         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
55902         return ret_conv;
55903 }
55904
55905 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55906         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
55907         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
55908         return ret_conv;
55909 }
55910
55911 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
55912         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
55913         return ret_conv;
55914 }
55915
55916 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
55917         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
55918         return ret_conv;
55919 }
55920
55921 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
55922         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
55923         return ret_conv;
55924 }
55925
55926 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
55927         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
55928         return ret_conv;
55929 }
55930
55931 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
55932         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
55933         return ret_conv;
55934 }
55935
55936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
55937         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
55938         int64_t ret_conv = Currency_hash(o_conv);
55939         return ret_conv;
55940 }
55941
55942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55943         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
55944         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
55945         jboolean ret_conv = Currency_eq(a_conv, b_conv);
55946         return ret_conv;
55947 }
55948
55949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55950         LDKSha256 this_obj_conv;
55951         this_obj_conv.inner = untag_ptr(this_obj);
55952         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55954         Sha256_free(this_obj_conv);
55955 }
55956
55957 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
55958         LDKSha256 ret_var = Sha256_clone(arg);
55959         int64_t ret_ref = 0;
55960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55962         return ret_ref;
55963 }
55964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55965         LDKSha256 arg_conv;
55966         arg_conv.inner = untag_ptr(arg);
55967         arg_conv.is_owned = ptr_is_owned(arg);
55968         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55969         arg_conv.is_owned = false;
55970         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
55971         return ret_conv;
55972 }
55973
55974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55975         LDKSha256 orig_conv;
55976         orig_conv.inner = untag_ptr(orig);
55977         orig_conv.is_owned = ptr_is_owned(orig);
55978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55979         orig_conv.is_owned = false;
55980         LDKSha256 ret_var = Sha256_clone(&orig_conv);
55981         int64_t ret_ref = 0;
55982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55984         return ret_ref;
55985 }
55986
55987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
55988         LDKSha256 o_conv;
55989         o_conv.inner = untag_ptr(o);
55990         o_conv.is_owned = ptr_is_owned(o);
55991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55992         o_conv.is_owned = false;
55993         int64_t ret_conv = Sha256_hash(&o_conv);
55994         return ret_conv;
55995 }
55996
55997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55998         LDKSha256 a_conv;
55999         a_conv.inner = untag_ptr(a);
56000         a_conv.is_owned = ptr_is_owned(a);
56001         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56002         a_conv.is_owned = false;
56003         LDKSha256 b_conv;
56004         b_conv.inner = untag_ptr(b);
56005         b_conv.is_owned = ptr_is_owned(b);
56006         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56007         b_conv.is_owned = false;
56008         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
56009         return ret_conv;
56010 }
56011
56012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1from_1bytes(JNIEnv *env, jclass clz, int8_tArray bytes) {
56013         uint8_t bytes_arr[32];
56014         CHECK((*env)->GetArrayLength(env, bytes) == 32);
56015         (*env)->GetByteArrayRegion(env, bytes, 0, 32, bytes_arr);
56016         uint8_t (*bytes_ref)[32] = &bytes_arr;
56017         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
56018         int64_t ret_ref = 0;
56019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56021         return ret_ref;
56022 }
56023
56024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56025         LDKDescription this_obj_conv;
56026         this_obj_conv.inner = untag_ptr(this_obj);
56027         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56029         Description_free(this_obj_conv);
56030 }
56031
56032 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
56033         LDKDescription ret_var = Description_clone(arg);
56034         int64_t ret_ref = 0;
56035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56036         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56037         return ret_ref;
56038 }
56039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56040         LDKDescription arg_conv;
56041         arg_conv.inner = untag_ptr(arg);
56042         arg_conv.is_owned = ptr_is_owned(arg);
56043         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56044         arg_conv.is_owned = false;
56045         int64_t ret_conv = Description_clone_ptr(&arg_conv);
56046         return ret_conv;
56047 }
56048
56049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56050         LDKDescription orig_conv;
56051         orig_conv.inner = untag_ptr(orig);
56052         orig_conv.is_owned = ptr_is_owned(orig);
56053         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56054         orig_conv.is_owned = false;
56055         LDKDescription ret_var = Description_clone(&orig_conv);
56056         int64_t ret_ref = 0;
56057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56058         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56059         return ret_ref;
56060 }
56061
56062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
56063         LDKDescription o_conv;
56064         o_conv.inner = untag_ptr(o);
56065         o_conv.is_owned = ptr_is_owned(o);
56066         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56067         o_conv.is_owned = false;
56068         int64_t ret_conv = Description_hash(&o_conv);
56069         return ret_conv;
56070 }
56071
56072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56073         LDKDescription a_conv;
56074         a_conv.inner = untag_ptr(a);
56075         a_conv.is_owned = ptr_is_owned(a);
56076         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56077         a_conv.is_owned = false;
56078         LDKDescription b_conv;
56079         b_conv.inner = untag_ptr(b);
56080         b_conv.is_owned = ptr_is_owned(b);
56081         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56082         b_conv.is_owned = false;
56083         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
56084         return ret_conv;
56085 }
56086
56087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56088         LDKPayeePubKey this_obj_conv;
56089         this_obj_conv.inner = untag_ptr(this_obj);
56090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56092         PayeePubKey_free(this_obj_conv);
56093 }
56094
56095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56096         LDKPayeePubKey this_ptr_conv;
56097         this_ptr_conv.inner = untag_ptr(this_ptr);
56098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56100         this_ptr_conv.is_owned = false;
56101         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
56103         return ret_arr;
56104 }
56105
56106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
56107         LDKPayeePubKey this_ptr_conv;
56108         this_ptr_conv.inner = untag_ptr(this_ptr);
56109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56111         this_ptr_conv.is_owned = false;
56112         LDKPublicKey val_ref;
56113         CHECK((*env)->GetArrayLength(env, val) == 33);
56114         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
56115         PayeePubKey_set_a(&this_ptr_conv, val_ref);
56116 }
56117
56118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
56119         LDKPublicKey a_arg_ref;
56120         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
56121         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
56122         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
56123         int64_t ret_ref = 0;
56124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56126         return ret_ref;
56127 }
56128
56129 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
56130         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
56131         int64_t ret_ref = 0;
56132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56134         return ret_ref;
56135 }
56136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56137         LDKPayeePubKey arg_conv;
56138         arg_conv.inner = untag_ptr(arg);
56139         arg_conv.is_owned = ptr_is_owned(arg);
56140         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56141         arg_conv.is_owned = false;
56142         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
56143         return ret_conv;
56144 }
56145
56146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56147         LDKPayeePubKey orig_conv;
56148         orig_conv.inner = untag_ptr(orig);
56149         orig_conv.is_owned = ptr_is_owned(orig);
56150         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56151         orig_conv.is_owned = false;
56152         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
56153         int64_t ret_ref = 0;
56154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56156         return ret_ref;
56157 }
56158
56159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
56160         LDKPayeePubKey o_conv;
56161         o_conv.inner = untag_ptr(o);
56162         o_conv.is_owned = ptr_is_owned(o);
56163         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56164         o_conv.is_owned = false;
56165         int64_t ret_conv = PayeePubKey_hash(&o_conv);
56166         return ret_conv;
56167 }
56168
56169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56170         LDKPayeePubKey a_conv;
56171         a_conv.inner = untag_ptr(a);
56172         a_conv.is_owned = ptr_is_owned(a);
56173         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56174         a_conv.is_owned = false;
56175         LDKPayeePubKey b_conv;
56176         b_conv.inner = untag_ptr(b);
56177         b_conv.is_owned = ptr_is_owned(b);
56178         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56179         b_conv.is_owned = false;
56180         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
56181         return ret_conv;
56182 }
56183
56184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56185         LDKExpiryTime this_obj_conv;
56186         this_obj_conv.inner = untag_ptr(this_obj);
56187         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56189         ExpiryTime_free(this_obj_conv);
56190 }
56191
56192 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
56193         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
56194         int64_t ret_ref = 0;
56195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56197         return ret_ref;
56198 }
56199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56200         LDKExpiryTime arg_conv;
56201         arg_conv.inner = untag_ptr(arg);
56202         arg_conv.is_owned = ptr_is_owned(arg);
56203         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56204         arg_conv.is_owned = false;
56205         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
56206         return ret_conv;
56207 }
56208
56209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56210         LDKExpiryTime orig_conv;
56211         orig_conv.inner = untag_ptr(orig);
56212         orig_conv.is_owned = ptr_is_owned(orig);
56213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56214         orig_conv.is_owned = false;
56215         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
56216         int64_t ret_ref = 0;
56217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56219         return ret_ref;
56220 }
56221
56222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
56223         LDKExpiryTime o_conv;
56224         o_conv.inner = untag_ptr(o);
56225         o_conv.is_owned = ptr_is_owned(o);
56226         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56227         o_conv.is_owned = false;
56228         int64_t ret_conv = ExpiryTime_hash(&o_conv);
56229         return ret_conv;
56230 }
56231
56232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56233         LDKExpiryTime a_conv;
56234         a_conv.inner = untag_ptr(a);
56235         a_conv.is_owned = ptr_is_owned(a);
56236         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56237         a_conv.is_owned = false;
56238         LDKExpiryTime b_conv;
56239         b_conv.inner = untag_ptr(b);
56240         b_conv.is_owned = ptr_is_owned(b);
56241         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56242         b_conv.is_owned = false;
56243         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
56244         return ret_conv;
56245 }
56246
56247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56248         LDKMinFinalCltvExpiryDelta this_obj_conv;
56249         this_obj_conv.inner = untag_ptr(this_obj);
56250         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56252         MinFinalCltvExpiryDelta_free(this_obj_conv);
56253 }
56254
56255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56256         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56257         this_ptr_conv.inner = untag_ptr(this_ptr);
56258         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56260         this_ptr_conv.is_owned = false;
56261         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
56262         return ret_conv;
56263 }
56264
56265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
56266         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56267         this_ptr_conv.inner = untag_ptr(this_ptr);
56268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56270         this_ptr_conv.is_owned = false;
56271         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
56272 }
56273
56274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
56275         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
56276         int64_t ret_ref = 0;
56277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56279         return ret_ref;
56280 }
56281
56282 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
56283         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
56284         int64_t ret_ref = 0;
56285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56286         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56287         return ret_ref;
56288 }
56289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56290         LDKMinFinalCltvExpiryDelta arg_conv;
56291         arg_conv.inner = untag_ptr(arg);
56292         arg_conv.is_owned = ptr_is_owned(arg);
56293         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56294         arg_conv.is_owned = false;
56295         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
56296         return ret_conv;
56297 }
56298
56299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56300         LDKMinFinalCltvExpiryDelta orig_conv;
56301         orig_conv.inner = untag_ptr(orig);
56302         orig_conv.is_owned = ptr_is_owned(orig);
56303         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56304         orig_conv.is_owned = false;
56305         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
56306         int64_t ret_ref = 0;
56307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56309         return ret_ref;
56310 }
56311
56312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1hash(JNIEnv *env, jclass clz, int64_t o) {
56313         LDKMinFinalCltvExpiryDelta o_conv;
56314         o_conv.inner = untag_ptr(o);
56315         o_conv.is_owned = ptr_is_owned(o);
56316         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56317         o_conv.is_owned = false;
56318         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
56319         return ret_conv;
56320 }
56321
56322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56323         LDKMinFinalCltvExpiryDelta a_conv;
56324         a_conv.inner = untag_ptr(a);
56325         a_conv.is_owned = ptr_is_owned(a);
56326         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56327         a_conv.is_owned = false;
56328         LDKMinFinalCltvExpiryDelta b_conv;
56329         b_conv.inner = untag_ptr(b);
56330         b_conv.is_owned = ptr_is_owned(b);
56331         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56332         b_conv.is_owned = false;
56333         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
56334         return ret_conv;
56335 }
56336
56337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
56338         if (!ptr_is_owned(this_ptr)) return;
56339         void* this_ptr_ptr = untag_ptr(this_ptr);
56340         CHECK_ACCESS(this_ptr_ptr);
56341         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
56342         FREE(untag_ptr(this_ptr));
56343         Fallback_free(this_ptr_conv);
56344 }
56345
56346 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
56347         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56348         *ret_copy = Fallback_clone(arg);
56349         int64_t ret_ref = tag_ptr(ret_copy, true);
56350         return ret_ref;
56351 }
56352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56353         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
56354         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
56355         return ret_conv;
56356 }
56357
56358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56359         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
56360         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56361         *ret_copy = Fallback_clone(orig_conv);
56362         int64_t ret_ref = tag_ptr(ret_copy, true);
56363         return ret_ref;
56364 }
56365
56366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
56367         
56368         LDKCVec_u8Z program_ref;
56369         program_ref.datalen = (*env)->GetArrayLength(env, program);
56370         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
56371         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
56372         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56373         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
56374         int64_t ret_ref = tag_ptr(ret_copy, true);
56375         return ret_ref;
56376 }
56377
56378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56379         LDKTwentyBytes a_ref;
56380         CHECK((*env)->GetArrayLength(env, a) == 20);
56381         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56382         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56383         *ret_copy = Fallback_pub_key_hash(a_ref);
56384         int64_t ret_ref = tag_ptr(ret_copy, true);
56385         return ret_ref;
56386 }
56387
56388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56389         LDKTwentyBytes a_ref;
56390         CHECK((*env)->GetArrayLength(env, a) == 20);
56391         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56392         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56393         *ret_copy = Fallback_script_hash(a_ref);
56394         int64_t ret_ref = tag_ptr(ret_copy, true);
56395         return ret_ref;
56396 }
56397
56398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
56399         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
56400         int64_t ret_conv = Fallback_hash(o_conv);
56401         return ret_conv;
56402 }
56403
56404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56405         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
56406         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
56407         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
56408         return ret_conv;
56409 }
56410
56411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56412         LDKInvoiceSignature this_obj_conv;
56413         this_obj_conv.inner = untag_ptr(this_obj);
56414         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56416         InvoiceSignature_free(this_obj_conv);
56417 }
56418
56419 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
56420         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
56421         int64_t ret_ref = 0;
56422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56424         return ret_ref;
56425 }
56426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56427         LDKInvoiceSignature arg_conv;
56428         arg_conv.inner = untag_ptr(arg);
56429         arg_conv.is_owned = ptr_is_owned(arg);
56430         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56431         arg_conv.is_owned = false;
56432         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
56433         return ret_conv;
56434 }
56435
56436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56437         LDKInvoiceSignature orig_conv;
56438         orig_conv.inner = untag_ptr(orig);
56439         orig_conv.is_owned = ptr_is_owned(orig);
56440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56441         orig_conv.is_owned = false;
56442         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
56443         int64_t ret_ref = 0;
56444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56446         return ret_ref;
56447 }
56448
56449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
56450         LDKInvoiceSignature o_conv;
56451         o_conv.inner = untag_ptr(o);
56452         o_conv.is_owned = ptr_is_owned(o);
56453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56454         o_conv.is_owned = false;
56455         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
56456         return ret_conv;
56457 }
56458
56459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56460         LDKInvoiceSignature a_conv;
56461         a_conv.inner = untag_ptr(a);
56462         a_conv.is_owned = ptr_is_owned(a);
56463         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56464         a_conv.is_owned = false;
56465         LDKInvoiceSignature b_conv;
56466         b_conv.inner = untag_ptr(b);
56467         b_conv.is_owned = ptr_is_owned(b);
56468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56469         b_conv.is_owned = false;
56470         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
56471         return ret_conv;
56472 }
56473
56474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56475         LDKPrivateRoute this_obj_conv;
56476         this_obj_conv.inner = untag_ptr(this_obj);
56477         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56479         PrivateRoute_free(this_obj_conv);
56480 }
56481
56482 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
56483         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
56484         int64_t ret_ref = 0;
56485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56487         return ret_ref;
56488 }
56489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56490         LDKPrivateRoute arg_conv;
56491         arg_conv.inner = untag_ptr(arg);
56492         arg_conv.is_owned = ptr_is_owned(arg);
56493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56494         arg_conv.is_owned = false;
56495         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
56496         return ret_conv;
56497 }
56498
56499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56500         LDKPrivateRoute orig_conv;
56501         orig_conv.inner = untag_ptr(orig);
56502         orig_conv.is_owned = ptr_is_owned(orig);
56503         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56504         orig_conv.is_owned = false;
56505         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
56506         int64_t ret_ref = 0;
56507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56509         return ret_ref;
56510 }
56511
56512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
56513         LDKPrivateRoute o_conv;
56514         o_conv.inner = untag_ptr(o);
56515         o_conv.is_owned = ptr_is_owned(o);
56516         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56517         o_conv.is_owned = false;
56518         int64_t ret_conv = PrivateRoute_hash(&o_conv);
56519         return ret_conv;
56520 }
56521
56522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56523         LDKPrivateRoute a_conv;
56524         a_conv.inner = untag_ptr(a);
56525         a_conv.is_owned = ptr_is_owned(a);
56526         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56527         a_conv.is_owned = false;
56528         LDKPrivateRoute b_conv;
56529         b_conv.inner = untag_ptr(b);
56530         b_conv.is_owned = ptr_is_owned(b);
56531         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56532         b_conv.is_owned = false;
56533         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
56534         return ret_conv;
56535 }
56536
56537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
56538         LDKSignedRawInvoice this_arg_conv;
56539         this_arg_conv.inner = untag_ptr(this_arg);
56540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56542         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
56543         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
56544         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
56545         return tag_ptr(ret_conv, true);
56546 }
56547
56548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
56549         LDKSignedRawInvoice this_arg_conv;
56550         this_arg_conv.inner = untag_ptr(this_arg);
56551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56553         this_arg_conv.is_owned = false;
56554         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
56555         int64_t ret_ref = 0;
56556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56557         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56558         return ret_ref;
56559 }
56560
56561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56562         LDKSignedRawInvoice this_arg_conv;
56563         this_arg_conv.inner = untag_ptr(this_arg);
56564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56566         this_arg_conv.is_owned = false;
56567         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
56569         return ret_arr;
56570 }
56571
56572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56573         LDKSignedRawInvoice this_arg_conv;
56574         this_arg_conv.inner = untag_ptr(this_arg);
56575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56577         this_arg_conv.is_owned = false;
56578         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
56579         int64_t ret_ref = 0;
56580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56582         return ret_ref;
56583 }
56584
56585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56586         LDKSignedRawInvoice this_arg_conv;
56587         this_arg_conv.inner = untag_ptr(this_arg);
56588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56590         this_arg_conv.is_owned = false;
56591         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
56592         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
56593         return tag_ptr(ret_conv, true);
56594 }
56595
56596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56597         LDKSignedRawInvoice this_arg_conv;
56598         this_arg_conv.inner = untag_ptr(this_arg);
56599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56601         this_arg_conv.is_owned = false;
56602         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
56603         return ret_conv;
56604 }
56605
56606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56607         LDKRawInvoice this_arg_conv;
56608         this_arg_conv.inner = untag_ptr(this_arg);
56609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56611         this_arg_conv.is_owned = false;
56612         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
56614         return ret_arr;
56615 }
56616
56617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56618         LDKRawInvoice this_arg_conv;
56619         this_arg_conv.inner = untag_ptr(this_arg);
56620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56622         this_arg_conv.is_owned = false;
56623         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
56624         int64_t ret_ref = 0;
56625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56627         return ret_ref;
56628 }
56629
56630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
56631         LDKRawInvoice this_arg_conv;
56632         this_arg_conv.inner = untag_ptr(this_arg);
56633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56635         this_arg_conv.is_owned = false;
56636         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
56637         int64_t ret_ref = 0;
56638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56640         return ret_ref;
56641 }
56642
56643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56644         LDKRawInvoice this_arg_conv;
56645         this_arg_conv.inner = untag_ptr(this_arg);
56646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56648         this_arg_conv.is_owned = false;
56649         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
56650         int64_t ret_ref = 0;
56651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56653         return ret_ref;
56654 }
56655
56656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56657         LDKRawInvoice this_arg_conv;
56658         this_arg_conv.inner = untag_ptr(this_arg);
56659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56661         this_arg_conv.is_owned = false;
56662         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
56663         int64_t ret_ref = 0;
56664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56666         return ret_ref;
56667 }
56668
56669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56670         LDKRawInvoice this_arg_conv;
56671         this_arg_conv.inner = untag_ptr(this_arg);
56672         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56674         this_arg_conv.is_owned = false;
56675         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
56676         int64_t ret_ref = 0;
56677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56679         return ret_ref;
56680 }
56681
56682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
56683         LDKRawInvoice this_arg_conv;
56684         this_arg_conv.inner = untag_ptr(this_arg);
56685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56687         this_arg_conv.is_owned = false;
56688         LDKMinFinalCltvExpiryDelta ret_var = RawInvoice_min_final_cltv_expiry_delta(&this_arg_conv);
56689         int64_t ret_ref = 0;
56690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56692         return ret_ref;
56693 }
56694
56695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56696         LDKRawInvoice this_arg_conv;
56697         this_arg_conv.inner = untag_ptr(this_arg);
56698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56700         this_arg_conv.is_owned = false;
56701         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56702         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
56703         return ret_arr;
56704 }
56705
56706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56707         LDKRawInvoice this_arg_conv;
56708         this_arg_conv.inner = untag_ptr(this_arg);
56709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56711         this_arg_conv.is_owned = false;
56712         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56713         *ret_copy = RawInvoice_payment_metadata(&this_arg_conv);
56714         int64_t ret_ref = tag_ptr(ret_copy, true);
56715         return ret_ref;
56716 }
56717
56718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56719         LDKRawInvoice this_arg_conv;
56720         this_arg_conv.inner = untag_ptr(this_arg);
56721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56723         this_arg_conv.is_owned = false;
56724         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
56725         int64_t ret_ref = 0;
56726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56728         return ret_ref;
56729 }
56730
56731 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
56732         LDKRawInvoice this_arg_conv;
56733         this_arg_conv.inner = untag_ptr(this_arg);
56734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56736         this_arg_conv.is_owned = false;
56737         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
56738         int64_tArray ret_arr = NULL;
56739         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
56740         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
56741         for (size_t o = 0; o < ret_var.datalen; o++) {
56742                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
56743                 int64_t ret_conv_14_ref = 0;
56744                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
56745                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
56746                 ret_arr_ptr[o] = ret_conv_14_ref;
56747         }
56748         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
56749         FREE(ret_var.data);
56750         return ret_arr;
56751 }
56752
56753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
56754         LDKRawInvoice this_arg_conv;
56755         this_arg_conv.inner = untag_ptr(this_arg);
56756         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56758         this_arg_conv.is_owned = false;
56759         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56760         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
56761         int64_t ret_ref = tag_ptr(ret_copy, true);
56762         return ret_ref;
56763 }
56764
56765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
56766         LDKRawInvoice this_arg_conv;
56767         this_arg_conv.inner = untag_ptr(this_arg);
56768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56770         this_arg_conv.is_owned = false;
56771         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
56772         return ret_conv;
56773 }
56774
56775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
56776         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56777         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
56778         return tag_ptr(ret_conv, true);
56779 }
56780
56781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
56782         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56783         *ret_conv = PositiveTimestamp_from_system_time(time);
56784         return tag_ptr(ret_conv, true);
56785 }
56786
56787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
56788         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56789         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
56790         return tag_ptr(ret_conv, true);
56791 }
56792
56793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56794         LDKPositiveTimestamp this_arg_conv;
56795         this_arg_conv.inner = untag_ptr(this_arg);
56796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56798         this_arg_conv.is_owned = false;
56799         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
56800         return ret_conv;
56801 }
56802
56803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56804         LDKPositiveTimestamp this_arg_conv;
56805         this_arg_conv.inner = untag_ptr(this_arg);
56806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56808         this_arg_conv.is_owned = false;
56809         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
56810         return ret_conv;
56811 }
56812
56813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56814         LDKPositiveTimestamp this_arg_conv;
56815         this_arg_conv.inner = untag_ptr(this_arg);
56816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56818         this_arg_conv.is_owned = false;
56819         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
56820         return ret_conv;
56821 }
56822
56823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56824         LDKInvoice this_arg_conv;
56825         this_arg_conv.inner = untag_ptr(this_arg);
56826         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56828         this_arg_conv.is_owned = false;
56829         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_signable_hash(&this_arg_conv).data);
56831         return ret_arr;
56832 }
56833
56834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
56835         LDKInvoice this_arg_conv;
56836         this_arg_conv.inner = untag_ptr(this_arg);
56837         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56839         this_arg_conv = Invoice_clone(&this_arg_conv);
56840         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
56841         int64_t ret_ref = 0;
56842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56844         return ret_ref;
56845 }
56846
56847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56848         LDKInvoice this_arg_conv;
56849         this_arg_conv.inner = untag_ptr(this_arg);
56850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56852         this_arg_conv.is_owned = false;
56853         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
56854         *ret_conv = Invoice_check_signature(&this_arg_conv);
56855         return tag_ptr(ret_conv, true);
56856 }
56857
56858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
56859         LDKSignedRawInvoice signed_invoice_conv;
56860         signed_invoice_conv.inner = untag_ptr(signed_invoice);
56861         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
56862         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
56863         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
56864         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
56865         *ret_conv = Invoice_from_signed(signed_invoice_conv);
56866         return tag_ptr(ret_conv, true);
56867 }
56868
56869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56870         LDKInvoice this_arg_conv;
56871         this_arg_conv.inner = untag_ptr(this_arg);
56872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56874         this_arg_conv.is_owned = false;
56875         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
56876         return ret_conv;
56877 }
56878
56879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56880         LDKInvoice this_arg_conv;
56881         this_arg_conv.inner = untag_ptr(this_arg);
56882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56884         this_arg_conv.is_owned = false;
56885         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
56886         return ret_conv;
56887 }
56888
56889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56890         LDKInvoice this_arg_conv;
56891         this_arg_conv.inner = untag_ptr(this_arg);
56892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56894         this_arg_conv.is_owned = false;
56895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
56897         return ret_arr;
56898 }
56899
56900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56901         LDKInvoice this_arg_conv;
56902         this_arg_conv.inner = untag_ptr(this_arg);
56903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56905         this_arg_conv.is_owned = false;
56906         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56907         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
56908         return ret_arr;
56909 }
56910
56911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56912         LDKInvoice this_arg_conv;
56913         this_arg_conv.inner = untag_ptr(this_arg);
56914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56916         this_arg_conv.is_owned = false;
56917         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56918         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
56919         return ret_arr;
56920 }
56921
56922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56923         LDKInvoice this_arg_conv;
56924         this_arg_conv.inner = untag_ptr(this_arg);
56925         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56927         this_arg_conv.is_owned = false;
56928         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56929         *ret_copy = Invoice_payment_metadata(&this_arg_conv);
56930         int64_t ret_ref = tag_ptr(ret_copy, true);
56931         return ret_ref;
56932 }
56933
56934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56935         LDKInvoice this_arg_conv;
56936         this_arg_conv.inner = untag_ptr(this_arg);
56937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56939         this_arg_conv.is_owned = false;
56940         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
56941         int64_t ret_ref = 0;
56942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56944         return ret_ref;
56945 }
56946
56947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56948         LDKInvoice this_arg_conv;
56949         this_arg_conv.inner = untag_ptr(this_arg);
56950         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56952         this_arg_conv.is_owned = false;
56953         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
56955         return ret_arr;
56956 }
56957
56958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expires_1at(JNIEnv *env, jclass clz, int64_t this_arg) {
56959         LDKInvoice this_arg_conv;
56960         this_arg_conv.inner = untag_ptr(this_arg);
56961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56963         this_arg_conv.is_owned = false;
56964         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
56965         *ret_copy = Invoice_expires_at(&this_arg_conv);
56966         int64_t ret_ref = tag_ptr(ret_copy, true);
56967         return ret_ref;
56968 }
56969
56970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56971         LDKInvoice this_arg_conv;
56972         this_arg_conv.inner = untag_ptr(this_arg);
56973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56975         this_arg_conv.is_owned = false;
56976         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
56977         return ret_conv;
56978 }
56979
56980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
56981         LDKInvoice this_arg_conv;
56982         this_arg_conv.inner = untag_ptr(this_arg);
56983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56985         this_arg_conv.is_owned = false;
56986         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
56987         return ret_conv;
56988 }
56989
56990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1until_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
56991         LDKInvoice this_arg_conv;
56992         this_arg_conv.inner = untag_ptr(this_arg);
56993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56995         this_arg_conv.is_owned = false;
56996         int64_t ret_conv = Invoice_duration_until_expiry(&this_arg_conv);
56997         return ret_conv;
56998 }
56999
57000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiration_1remaining_1from_1epoch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t time) {
57001         LDKInvoice this_arg_conv;
57002         this_arg_conv.inner = untag_ptr(this_arg);
57003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57005         this_arg_conv.is_owned = false;
57006         int64_t ret_conv = Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
57007         return ret_conv;
57008 }
57009
57010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
57011         LDKInvoice this_arg_conv;
57012         this_arg_conv.inner = untag_ptr(this_arg);
57013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57015         this_arg_conv.is_owned = false;
57016         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
57017         return ret_conv;
57018 }
57019
57020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
57021         LDKInvoice this_arg_conv;
57022         this_arg_conv.inner = untag_ptr(this_arg);
57023         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57025         this_arg_conv.is_owned = false;
57026         int64_t ret_conv = Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
57027         return ret_conv;
57028 }
57029
57030 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Invoice_1fallback_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
57031         LDKInvoice this_arg_conv;
57032         this_arg_conv.inner = untag_ptr(this_arg);
57033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57035         this_arg_conv.is_owned = false;
57036         LDKCVec_AddressZ ret_var = Invoice_fallback_addresses(&this_arg_conv);
57037         jobjectArray ret_arr = NULL;
57038         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, String_clz, NULL);
57039         ;
57040         jstring *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57041         for (size_t i = 0; i < ret_var.datalen; i++) {
57042                 LDKStr ret_conv_8_str = ret_var.data[i];
57043                 jstring ret_conv_8_conv = str_ref_to_java(env, ret_conv_8_str.chars, ret_conv_8_str.len);
57044                 Str_free(ret_conv_8_str);
57045                 ret_arr_ptr[i] = ret_conv_8_conv;
57046         }
57047         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57048         FREE(ret_var.data);
57049         return ret_arr;
57050 }
57051
57052 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
57053         LDKInvoice this_arg_conv;
57054         this_arg_conv.inner = untag_ptr(this_arg);
57055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57057         this_arg_conv.is_owned = false;
57058         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
57059         int64_tArray ret_arr = NULL;
57060         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57061         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57062         for (size_t o = 0; o < ret_var.datalen; o++) {
57063                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
57064                 int64_t ret_conv_14_ref = 0;
57065                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
57066                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
57067                 ret_arr_ptr[o] = ret_conv_14_ref;
57068         }
57069         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57070         FREE(ret_var.data);
57071         return ret_arr;
57072 }
57073
57074 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
57075         LDKInvoice this_arg_conv;
57076         this_arg_conv.inner = untag_ptr(this_arg);
57077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57079         this_arg_conv.is_owned = false;
57080         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
57081         int64_tArray ret_arr = NULL;
57082         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57083         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57084         for (size_t l = 0; l < ret_var.datalen; l++) {
57085                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
57086                 int64_t ret_conv_11_ref = 0;
57087                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
57088                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
57089                 ret_arr_ptr[l] = ret_conv_11_ref;
57090         }
57091         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57092         FREE(ret_var.data);
57093         return ret_arr;
57094 }
57095
57096 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
57097         LDKInvoice this_arg_conv;
57098         this_arg_conv.inner = untag_ptr(this_arg);
57099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57101         this_arg_conv.is_owned = false;
57102         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
57103         return ret_conv;
57104 }
57105
57106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
57107         LDKInvoice this_arg_conv;
57108         this_arg_conv.inner = untag_ptr(this_arg);
57109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57111         this_arg_conv.is_owned = false;
57112         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57113         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
57114         int64_t ret_ref = tag_ptr(ret_copy, true);
57115         return ret_ref;
57116 }
57117
57118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
57119         LDKStr description_conv = java_to_owned_str(env, description);
57120         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
57121         *ret_conv = Description_new(description_conv);
57122         return tag_ptr(ret_conv, true);
57123 }
57124
57125 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57126         LDKDescription this_arg_conv;
57127         this_arg_conv.inner = untag_ptr(this_arg);
57128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57130         this_arg_conv = Description_clone(&this_arg_conv);
57131         LDKStr ret_str = Description_into_inner(this_arg_conv);
57132         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57133         Str_free(ret_str);
57134         return ret_conv;
57135 }
57136
57137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
57138         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
57139         int64_t ret_ref = 0;
57140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57142         return ret_ref;
57143 }
57144
57145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
57146         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
57147         int64_t ret_ref = 0;
57148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57150         return ret_ref;
57151 }
57152
57153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
57154         LDKExpiryTime this_arg_conv;
57155         this_arg_conv.inner = untag_ptr(this_arg);
57156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57158         this_arg_conv.is_owned = false;
57159         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
57160         return ret_conv;
57161 }
57162
57163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
57164         LDKExpiryTime this_arg_conv;
57165         this_arg_conv.inner = untag_ptr(this_arg);
57166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57168         this_arg_conv.is_owned = false;
57169         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
57170         return ret_conv;
57171 }
57172
57173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
57174         LDKRouteHint hops_conv;
57175         hops_conv.inner = untag_ptr(hops);
57176         hops_conv.is_owned = ptr_is_owned(hops);
57177         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
57178         hops_conv = RouteHint_clone(&hops_conv);
57179         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
57180         *ret_conv = PrivateRoute_new(hops_conv);
57181         return tag_ptr(ret_conv, true);
57182 }
57183
57184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57185         LDKPrivateRoute this_arg_conv;
57186         this_arg_conv.inner = untag_ptr(this_arg);
57187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57189         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
57190         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
57191         int64_t ret_ref = 0;
57192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57194         return ret_ref;
57195 }
57196
57197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57198         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
57199         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
57200         return ret_conv;
57201 }
57202
57203 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
57204         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
57205         return ret_conv;
57206 }
57207
57208 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
57209         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
57210         return ret_conv;
57211 }
57212
57213 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
57214         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
57215         return ret_conv;
57216 }
57217
57218 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
57219         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
57220         return ret_conv;
57221 }
57222
57223 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
57224         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
57225         return ret_conv;
57226 }
57227
57228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1min_1final_1cltv_1expiry_1delta_1too_1short(JNIEnv *env, jclass clz) {
57229         jclass ret_conv = LDKCreationError_to_java(env, CreationError_min_final_cltv_expiry_delta_too_short());
57230         return ret_conv;
57231 }
57232
57233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57234         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
57235         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
57236         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
57237         return ret_conv;
57238 }
57239
57240 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57241         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
57242         LDKStr ret_str = CreationError_to_str(o_conv);
57243         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57244         Str_free(ret_str);
57245         return ret_conv;
57246 }
57247
57248 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57249         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
57250         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
57251         return ret_conv;
57252 }
57253
57254 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
57255         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
57256         return ret_conv;
57257 }
57258
57259 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
57260         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
57261         return ret_conv;
57262 }
57263
57264 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
57265         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
57266         return ret_conv;
57267 }
57268
57269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
57270         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
57271         return ret_conv;
57272 }
57273
57274 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
57275         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
57276         return ret_conv;
57277 }
57278
57279 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
57280         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
57281         return ret_conv;
57282 }
57283
57284 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
57285         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
57286         return ret_conv;
57287 }
57288
57289 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
57290         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
57291         return ret_conv;
57292 }
57293
57294 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
57295         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
57296         return ret_conv;
57297 }
57298
57299 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
57300         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
57301         return ret_conv;
57302 }
57303
57304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57305         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
57306         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
57307         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
57308         return ret_conv;
57309 }
57310
57311 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57312         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
57313         LDKStr ret_str = SemanticError_to_str(o_conv);
57314         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57315         Str_free(ret_str);
57316         return ret_conv;
57317 }
57318
57319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57320         if (!ptr_is_owned(this_ptr)) return;
57321         void* this_ptr_ptr = untag_ptr(this_ptr);
57322         CHECK_ACCESS(this_ptr_ptr);
57323         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
57324         FREE(untag_ptr(this_ptr));
57325         SignOrCreationError_free(this_ptr_conv);
57326 }
57327
57328 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
57329         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57330         *ret_copy = SignOrCreationError_clone(arg);
57331         int64_t ret_ref = tag_ptr(ret_copy, true);
57332         return ret_ref;
57333 }
57334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57335         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
57336         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
57337         return ret_conv;
57338 }
57339
57340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57341         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
57342         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57343         *ret_copy = SignOrCreationError_clone(orig_conv);
57344         int64_t ret_ref = tag_ptr(ret_copy, true);
57345         return ret_ref;
57346 }
57347
57348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
57349         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57350         *ret_copy = SignOrCreationError_sign_error();
57351         int64_t ret_ref = tag_ptr(ret_copy, true);
57352         return ret_ref;
57353 }
57354
57355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
57356         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
57357         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57358         *ret_copy = SignOrCreationError_creation_error(a_conv);
57359         int64_t ret_ref = tag_ptr(ret_copy, true);
57360         return ret_ref;
57361 }
57362
57363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57364         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
57365         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
57366         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
57367         return ret_conv;
57368 }
57369
57370 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57371         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
57372         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
57373         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57374         Str_free(ret_str);
57375         return ret_conv;
57376 }
57377
57378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_pay_1invoice(JNIEnv *env, jclass clz, int64_t invoice, int64_t retry_strategy, int64_t channelmanager) {
57379         LDKInvoice invoice_conv;
57380         invoice_conv.inner = untag_ptr(invoice);
57381         invoice_conv.is_owned = ptr_is_owned(invoice);
57382         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57383         invoice_conv.is_owned = false;
57384         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57385         CHECK_ACCESS(retry_strategy_ptr);
57386         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57387         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57388         LDKChannelManager channelmanager_conv;
57389         channelmanager_conv.inner = untag_ptr(channelmanager);
57390         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57391         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57392         channelmanager_conv.is_owned = false;
57393         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57394         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
57395         return tag_ptr(ret_conv, true);
57396 }
57397
57398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_pay_1invoice_1with_1id(JNIEnv *env, jclass clz, int64_t invoice, int8_tArray payment_id, int64_t retry_strategy, int64_t channelmanager) {
57399         LDKInvoice invoice_conv;
57400         invoice_conv.inner = untag_ptr(invoice);
57401         invoice_conv.is_owned = ptr_is_owned(invoice);
57402         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57403         invoice_conv.is_owned = false;
57404         LDKThirtyTwoBytes payment_id_ref;
57405         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57406         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57407         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57408         CHECK_ACCESS(retry_strategy_ptr);
57409         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57410         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57411         LDKChannelManager channelmanager_conv;
57412         channelmanager_conv.inner = untag_ptr(channelmanager);
57413         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57414         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57415         channelmanager_conv.is_owned = false;
57416         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57417         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57418         return tag_ptr(ret_conv, true);
57419 }
57420
57421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t invoice, int64_t amount_msats, int64_t retry_strategy, int64_t channelmanager) {
57422         LDKInvoice invoice_conv;
57423         invoice_conv.inner = untag_ptr(invoice);
57424         invoice_conv.is_owned = ptr_is_owned(invoice);
57425         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57426         invoice_conv.is_owned = false;
57427         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57428         CHECK_ACCESS(retry_strategy_ptr);
57429         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57430         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57431         LDKChannelManager channelmanager_conv;
57432         channelmanager_conv.inner = untag_ptr(channelmanager);
57433         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57434         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57435         channelmanager_conv.is_owned = false;
57436         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57437         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, retry_strategy_conv, &channelmanager_conv);
57438         return tag_ptr(ret_conv, true);
57439 }
57440
57441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_pay_1zero_1value_1invoice_1with_1id(JNIEnv *env, jclass clz, int64_t invoice, int64_t amount_msats, int8_tArray payment_id, int64_t retry_strategy, int64_t channelmanager) {
57442         LDKInvoice invoice_conv;
57443         invoice_conv.inner = untag_ptr(invoice);
57444         invoice_conv.is_owned = ptr_is_owned(invoice);
57445         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57446         invoice_conv.is_owned = false;
57447         LDKThirtyTwoBytes payment_id_ref;
57448         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57449         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57450         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57451         CHECK_ACCESS(retry_strategy_ptr);
57452         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57453         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57454         LDKChannelManager channelmanager_conv;
57455         channelmanager_conv.inner = untag_ptr(channelmanager);
57456         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57457         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57458         channelmanager_conv.is_owned = false;
57459         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57460         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57461         return tag_ptr(ret_conv, true);
57462 }
57463
57464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57465         if (!ptr_is_owned(this_ptr)) return;
57466         void* this_ptr_ptr = untag_ptr(this_ptr);
57467         CHECK_ACCESS(this_ptr_ptr);
57468         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
57469         FREE(untag_ptr(this_ptr));
57470         PaymentError_free(this_ptr_conv);
57471 }
57472
57473 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
57474         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57475         *ret_copy = PaymentError_clone(arg);
57476         int64_t ret_ref = tag_ptr(ret_copy, true);
57477         return ret_ref;
57478 }
57479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57480         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
57481         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
57482         return ret_conv;
57483 }
57484
57485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57486         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
57487         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57488         *ret_copy = PaymentError_clone(orig_conv);
57489         int64_t ret_ref = tag_ptr(ret_copy, true);
57490         return ret_ref;
57491 }
57492
57493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
57494         LDKStr a_conv = java_to_owned_str(env, a);
57495         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57496         *ret_copy = PaymentError_invoice(a_conv);
57497         int64_t ret_ref = tag_ptr(ret_copy, true);
57498         return ret_ref;
57499 }
57500
57501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, jclass a) {
57502         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_java(env, a);
57503         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57504         *ret_copy = PaymentError_sending(a_conv);
57505         int64_t ret_ref = tag_ptr(ret_copy, true);
57506         return ret_ref;
57507 }
57508
57509 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 entropy_source, int64_t node_signer, int64_t logger, jclass network, int64_t min_final_cltv_expiry_delta, int64_t duration_since_epoch) {
57510         void* amt_msat_ptr = untag_ptr(amt_msat);
57511         CHECK_ACCESS(amt_msat_ptr);
57512         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57513         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57514         LDKThirtyTwoBytes payment_hash_ref;
57515         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57516         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57517         LDKStr description_conv = java_to_owned_str(env, description);
57518         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57519         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57520         if (phantom_route_hints_constr.datalen > 0)
57521                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57522         else
57523                 phantom_route_hints_constr.data = NULL;
57524         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57525         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57526                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57527                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57528                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57529                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57530                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57531                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57532                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57533         }
57534         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57535         void* entropy_source_ptr = untag_ptr(entropy_source);
57536         CHECK_ACCESS(entropy_source_ptr);
57537         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57538         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57539                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57540                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57541         }
57542         void* node_signer_ptr = untag_ptr(node_signer);
57543         CHECK_ACCESS(node_signer_ptr);
57544         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57545         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57546                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57547                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57548         }
57549         void* logger_ptr = untag_ptr(logger);
57550         CHECK_ACCESS(logger_ptr);
57551         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57552         if (logger_conv.free == LDKLogger_JCalls_free) {
57553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57554                 LDKLogger_JCalls_cloned(&logger_conv);
57555         }
57556         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57557         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57558         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57559         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57560         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57561         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57562         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, entropy_source_conv, node_signer_conv, logger_conv, network_conv, min_final_cltv_expiry_delta_conv, duration_since_epoch);
57563         return tag_ptr(ret_conv, true);
57564 }
57565
57566 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 entropy_source, int64_t node_signer, int64_t logger, jclass network, int64_t min_final_cltv_expiry_delta, int64_t duration_since_epoch) {
57567         void* amt_msat_ptr = untag_ptr(amt_msat);
57568         CHECK_ACCESS(amt_msat_ptr);
57569         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57570         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57571         LDKThirtyTwoBytes payment_hash_ref;
57572         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57573         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57574         LDKSha256 description_hash_conv;
57575         description_hash_conv.inner = untag_ptr(description_hash);
57576         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57577         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57578         description_hash_conv = Sha256_clone(&description_hash_conv);
57579         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57580         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57581         if (phantom_route_hints_constr.datalen > 0)
57582                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57583         else
57584                 phantom_route_hints_constr.data = NULL;
57585         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57586         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57587                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57588                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57589                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57590                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57591                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57592                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57593                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57594         }
57595         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57596         void* entropy_source_ptr = untag_ptr(entropy_source);
57597         CHECK_ACCESS(entropy_source_ptr);
57598         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57599         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57600                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57601                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57602         }
57603         void* node_signer_ptr = untag_ptr(node_signer);
57604         CHECK_ACCESS(node_signer_ptr);
57605         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57606         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57608                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57609         }
57610         void* logger_ptr = untag_ptr(logger);
57611         CHECK_ACCESS(logger_ptr);
57612         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57613         if (logger_conv.free == LDKLogger_JCalls_free) {
57614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57615                 LDKLogger_JCalls_cloned(&logger_conv);
57616         }
57617         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57618         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57619         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57620         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57621         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57622         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57623         *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, entropy_source_conv, node_signer_conv, logger_conv, network_conv, min_final_cltv_expiry_delta_conv, duration_since_epoch);
57624         return tag_ptr(ret_conv, true);
57625 }
57626
57627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t node_signer, int64_t logger, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
57628         LDKChannelManager channelmanager_conv;
57629         channelmanager_conv.inner = untag_ptr(channelmanager);
57630         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57631         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57632         channelmanager_conv.is_owned = false;
57633         void* node_signer_ptr = untag_ptr(node_signer);
57634         CHECK_ACCESS(node_signer_ptr);
57635         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57636         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57637                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57638                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57639         }
57640         void* logger_ptr = untag_ptr(logger);
57641         CHECK_ACCESS(logger_ptr);
57642         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57643         if (logger_conv.free == LDKLogger_JCalls_free) {
57644                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57645                 LDKLogger_JCalls_cloned(&logger_conv);
57646         }
57647         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57648         void* amt_msat_ptr = untag_ptr(amt_msat);
57649         CHECK_ACCESS(amt_msat_ptr);
57650         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57651         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57652         LDKStr description_conv = java_to_owned_str(env, description);
57653         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57654         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57655         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57656         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57657         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57658         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
57659         return tag_ptr(ret_conv, true);
57660 }
57661
57662 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 node_signer, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
57663         LDKChannelManager channelmanager_conv;
57664         channelmanager_conv.inner = untag_ptr(channelmanager);
57665         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57666         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57667         channelmanager_conv.is_owned = false;
57668         void* node_signer_ptr = untag_ptr(node_signer);
57669         CHECK_ACCESS(node_signer_ptr);
57670         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57671         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57672                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57673                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57674         }
57675         void* logger_ptr = untag_ptr(logger);
57676         CHECK_ACCESS(logger_ptr);
57677         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57678         if (logger_conv.free == LDKLogger_JCalls_free) {
57679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57680                 LDKLogger_JCalls_cloned(&logger_conv);
57681         }
57682         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57683         void* amt_msat_ptr = untag_ptr(amt_msat);
57684         CHECK_ACCESS(amt_msat_ptr);
57685         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57686         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57687         LDKSha256 description_hash_conv;
57688         description_hash_conv.inner = untag_ptr(description_hash);
57689         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57690         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57691         description_hash_conv = Sha256_clone(&description_hash_conv);
57692         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57693         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57694         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57695         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57696         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57697         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
57698         return tag_ptr(ret_conv, true);
57699 }
57700
57701 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 node_signer, int64_t logger, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
57702         LDKChannelManager channelmanager_conv;
57703         channelmanager_conv.inner = untag_ptr(channelmanager);
57704         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57705         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57706         channelmanager_conv.is_owned = false;
57707         void* node_signer_ptr = untag_ptr(node_signer);
57708         CHECK_ACCESS(node_signer_ptr);
57709         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57710         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57712                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57713         }
57714         void* logger_ptr = untag_ptr(logger);
57715         CHECK_ACCESS(logger_ptr);
57716         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57717         if (logger_conv.free == LDKLogger_JCalls_free) {
57718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57719                 LDKLogger_JCalls_cloned(&logger_conv);
57720         }
57721         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57722         void* amt_msat_ptr = untag_ptr(amt_msat);
57723         CHECK_ACCESS(amt_msat_ptr);
57724         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57725         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57726         LDKSha256 description_hash_conv;
57727         description_hash_conv.inner = untag_ptr(description_hash);
57728         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57729         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57730         description_hash_conv = Sha256_clone(&description_hash_conv);
57731         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57732         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57733         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57734         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57735         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57736         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
57737         return tag_ptr(ret_conv, true);
57738 }
57739
57740 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 node_signer, int64_t logger, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
57741         LDKChannelManager channelmanager_conv;
57742         channelmanager_conv.inner = untag_ptr(channelmanager);
57743         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57744         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57745         channelmanager_conv.is_owned = false;
57746         void* node_signer_ptr = untag_ptr(node_signer);
57747         CHECK_ACCESS(node_signer_ptr);
57748         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57749         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57751                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57752         }
57753         void* logger_ptr = untag_ptr(logger);
57754         CHECK_ACCESS(logger_ptr);
57755         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57756         if (logger_conv.free == LDKLogger_JCalls_free) {
57757                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57758                 LDKLogger_JCalls_cloned(&logger_conv);
57759         }
57760         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57761         void* amt_msat_ptr = untag_ptr(amt_msat);
57762         CHECK_ACCESS(amt_msat_ptr);
57763         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57764         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57765         LDKStr description_conv = java_to_owned_str(env, description);
57766         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57767         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57768         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57769         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57770         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57771         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
57772         return tag_ptr(ret_conv, true);
57773 }
57774
57775 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 node_signer, 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, int64_t min_final_cltv_expiry_delta) {
57776         LDKChannelManager channelmanager_conv;
57777         channelmanager_conv.inner = untag_ptr(channelmanager);
57778         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57779         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57780         channelmanager_conv.is_owned = false;
57781         void* node_signer_ptr = untag_ptr(node_signer);
57782         CHECK_ACCESS(node_signer_ptr);
57783         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57784         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57785                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57786                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57787         }
57788         void* logger_ptr = untag_ptr(logger);
57789         CHECK_ACCESS(logger_ptr);
57790         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57791         if (logger_conv.free == LDKLogger_JCalls_free) {
57792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57793                 LDKLogger_JCalls_cloned(&logger_conv);
57794         }
57795         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57796         void* amt_msat_ptr = untag_ptr(amt_msat);
57797         CHECK_ACCESS(amt_msat_ptr);
57798         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57799         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57800         LDKStr description_conv = java_to_owned_str(env, description);
57801         LDKThirtyTwoBytes payment_hash_ref;
57802         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57803         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57804         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57805         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57806         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57807         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57808         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57809         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs, payment_hash_ref, min_final_cltv_expiry_delta_conv);
57810         return tag_ptr(ret_conv, true);
57811 }
57812
57813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57814         LDKStr s_conv = java_to_owned_str(env, s);
57815         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
57816         *ret_conv = SiPrefix_from_str(s_conv);
57817         return tag_ptr(ret_conv, true);
57818 }
57819
57820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57821         LDKStr s_conv = java_to_owned_str(env, s);
57822         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
57823         *ret_conv = Invoice_from_str(s_conv);
57824         return tag_ptr(ret_conv, true);
57825 }
57826
57827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57828         LDKStr s_conv = java_to_owned_str(env, s);
57829         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
57830         *ret_conv = SignedRawInvoice_from_str(s_conv);
57831         return tag_ptr(ret_conv, true);
57832 }
57833
57834 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57835         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
57836         LDKStr ret_str = ParseError_to_str(o_conv);
57837         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57838         Str_free(ret_str);
57839         return ret_conv;
57840 }
57841
57842 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57843         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
57844         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
57845         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57846         Str_free(ret_str);
57847         return ret_conv;
57848 }
57849
57850 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57851         LDKInvoice o_conv;
57852         o_conv.inner = untag_ptr(o);
57853         o_conv.is_owned = ptr_is_owned(o);
57854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57855         o_conv.is_owned = false;
57856         LDKStr ret_str = Invoice_to_str(&o_conv);
57857         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57858         Str_free(ret_str);
57859         return ret_conv;
57860 }
57861
57862 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57863         LDKSignedRawInvoice o_conv;
57864         o_conv.inner = untag_ptr(o);
57865         o_conv.is_owned = ptr_is_owned(o);
57866         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57867         o_conv.is_owned = false;
57868         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
57869         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57870         Str_free(ret_str);
57871         return ret_conv;
57872 }
57873
57874 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57875         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
57876         LDKStr ret_str = Currency_to_str(o_conv);
57877         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57878         Str_free(ret_str);
57879         return ret_conv;
57880 }
57881
57882 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57883         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
57884         LDKStr ret_str = SiPrefix_to_str(o_conv);
57885         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57886         Str_free(ret_str);
57887         return ret_conv;
57888 }
57889
57890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
57891         LDKRapidGossipSync this_obj_conv;
57892         this_obj_conv.inner = untag_ptr(this_obj);
57893         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57895         RapidGossipSync_free(this_obj_conv);
57896 }
57897
57898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
57899         LDKNetworkGraph network_graph_conv;
57900         network_graph_conv.inner = untag_ptr(network_graph);
57901         network_graph_conv.is_owned = ptr_is_owned(network_graph);
57902         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
57903         network_graph_conv.is_owned = false;
57904         void* logger_ptr = untag_ptr(logger);
57905         CHECK_ACCESS(logger_ptr);
57906         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57907         if (logger_conv.free == LDKLogger_JCalls_free) {
57908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57909                 LDKLogger_JCalls_cloned(&logger_conv);
57910         }
57911         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
57912         int64_t ret_ref = 0;
57913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57915         return ret_ref;
57916 }
57917
57918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph_1no_1std(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data, int64_t current_time_unix) {
57919         LDKRapidGossipSync this_arg_conv;
57920         this_arg_conv.inner = untag_ptr(this_arg);
57921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57923         this_arg_conv.is_owned = false;
57924         LDKu8slice update_data_ref;
57925         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
57926         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
57927         void* current_time_unix_ptr = untag_ptr(current_time_unix);
57928         CHECK_ACCESS(current_time_unix_ptr);
57929         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
57930         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
57931         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
57932         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
57933         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
57934         return tag_ptr(ret_conv, true);
57935 }
57936
57937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
57938         LDKRapidGossipSync this_arg_conv;
57939         this_arg_conv.inner = untag_ptr(this_arg);
57940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57942         this_arg_conv.is_owned = false;
57943         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
57944         return ret_conv;
57945 }
57946
57947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57948         if (!ptr_is_owned(this_ptr)) return;
57949         void* this_ptr_ptr = untag_ptr(this_ptr);
57950         CHECK_ACCESS(this_ptr_ptr);
57951         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
57952         FREE(untag_ptr(this_ptr));
57953         GraphSyncError_free(this_ptr_conv);
57954 }
57955
57956 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
57957         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57958         *ret_copy = GraphSyncError_clone(arg);
57959         int64_t ret_ref = tag_ptr(ret_copy, true);
57960         return ret_ref;
57961 }
57962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57963         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
57964         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
57965         return ret_conv;
57966 }
57967
57968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57969         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
57970         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57971         *ret_copy = GraphSyncError_clone(orig_conv);
57972         int64_t ret_ref = tag_ptr(ret_copy, true);
57973         return ret_ref;
57974 }
57975
57976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
57977         void* a_ptr = untag_ptr(a);
57978         CHECK_ACCESS(a_ptr);
57979         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
57980         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
57981         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57982         *ret_copy = GraphSyncError_decode_error(a_conv);
57983         int64_t ret_ref = tag_ptr(ret_copy, true);
57984         return ret_ref;
57985 }
57986
57987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
57988         LDKLightningError a_conv;
57989         a_conv.inner = untag_ptr(a);
57990         a_conv.is_owned = ptr_is_owned(a);
57991         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57992         a_conv = LightningError_clone(&a_conv);
57993         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57994         *ret_copy = GraphSyncError_lightning_error(a_conv);
57995         int64_t ret_ref = tag_ptr(ret_copy, true);
57996         return ret_ref;
57997 }
57998