b039192b94b3bc34fa4414a5af1077179e13a18d
[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, "Ljava/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         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20933         LDKThirtyTwoBytes o_ref;
20934         CHECK((*env)->GetArrayLength(env, o) == 32);
20935         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20936         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20937         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20938         return tag_ptr(ret_conv, true);
20939 }
20940
20941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20942         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20943         *ret_conv = CResult_SharedSecretNoneZ_err();
20944         return tag_ptr(ret_conv, true);
20945 }
20946
20947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20948         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20949         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20950         return ret_conv;
20951 }
20952
20953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20954         if (!ptr_is_owned(_res)) return;
20955         void* _res_ptr = untag_ptr(_res);
20956         CHECK_ACCESS(_res_ptr);
20957         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20958         FREE(untag_ptr(_res));
20959         CResult_SharedSecretNoneZ_free(_res_conv);
20960 }
20961
20962 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20963         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20964         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20965         return tag_ptr(ret_conv, true);
20966 }
20967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20968         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20969         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20970         return ret_conv;
20971 }
20972
20973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20974         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20975         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20976         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20977         return tag_ptr(ret_conv, true);
20978 }
20979
20980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20981         LDKCVec_U5Z _res_constr;
20982         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20983         if (_res_constr.datalen > 0)
20984                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
20985         else
20986                 _res_constr.data = NULL;
20987         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
20988         for (size_t h = 0; h < _res_constr.datalen; h++) {
20989                 int8_t _res_conv_7 = _res_vals[h];
20990                 
20991                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
20992         }
20993         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
20994         CVec_U5Z_free(_res_constr);
20995 }
20996
20997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20998         LDKRecoverableSignature o_ref;
20999         CHECK((*env)->GetArrayLength(env, o) == 68);
21000         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
21001         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21002         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
21003         return tag_ptr(ret_conv, true);
21004 }
21005
21006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
21007         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21008         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
21009         return tag_ptr(ret_conv, true);
21010 }
21011
21012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21013         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
21014         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
21015         return ret_conv;
21016 }
21017
21018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21019         if (!ptr_is_owned(_res)) return;
21020         void* _res_ptr = untag_ptr(_res);
21021         CHECK_ACCESS(_res_ptr);
21022         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
21023         FREE(untag_ptr(_res));
21024         CResult_RecoverableSignatureNoneZ_free(_res_conv);
21025 }
21026
21027 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
21028         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21029         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
21030         return tag_ptr(ret_conv, true);
21031 }
21032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21033         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
21034         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
21035         return ret_conv;
21036 }
21037
21038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21039         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
21040         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21041         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
21042         return tag_ptr(ret_conv, true);
21043 }
21044
21045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21046         void* o_ptr = untag_ptr(o);
21047         CHECK_ACCESS(o_ptr);
21048         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
21049         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
21050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21051                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
21052         }
21053         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21054         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
21055         return tag_ptr(ret_conv, true);
21056 }
21057
21058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21059         void* e_ptr = untag_ptr(e);
21060         CHECK_ACCESS(e_ptr);
21061         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21062         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21063         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21064         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
21065         return tag_ptr(ret_conv, true);
21066 }
21067
21068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21069         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
21070         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
21071         return ret_conv;
21072 }
21073
21074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21075         if (!ptr_is_owned(_res)) return;
21076         void* _res_ptr = untag_ptr(_res);
21077         CHECK_ACCESS(_res_ptr);
21078         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
21079         FREE(untag_ptr(_res));
21080         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
21081 }
21082
21083 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
21084         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21085         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
21086         return tag_ptr(ret_conv, true);
21087 }
21088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21089         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
21090         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
21091         return ret_conv;
21092 }
21093
21094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21095         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
21096         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21097         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
21098         return tag_ptr(ret_conv, true);
21099 }
21100
21101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21102         LDKCVec_CVec_u8ZZ _res_constr;
21103         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21104         if (_res_constr.datalen > 0)
21105                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21106         else
21107                 _res_constr.data = NULL;
21108         for (size_t i = 0; i < _res_constr.datalen; i++) {
21109                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21110                 LDKCVec_u8Z _res_conv_8_ref;
21111                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21112                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21113                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21114                 _res_constr.data[i] = _res_conv_8_ref;
21115         }
21116         CVec_CVec_u8ZZ_free(_res_constr);
21117 }
21118
21119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
21120         LDKCVec_CVec_u8ZZ o_constr;
21121         o_constr.datalen = (*env)->GetArrayLength(env, o);
21122         if (o_constr.datalen > 0)
21123                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21124         else
21125                 o_constr.data = NULL;
21126         for (size_t i = 0; i < o_constr.datalen; i++) {
21127                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
21128                 LDKCVec_u8Z o_conv_8_ref;
21129                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
21130                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21131                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
21132                 o_constr.data[i] = o_conv_8_ref;
21133         }
21134         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21135         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
21136         return tag_ptr(ret_conv, true);
21137 }
21138
21139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
21140         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21141         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
21142         return tag_ptr(ret_conv, true);
21143 }
21144
21145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21146         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
21147         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
21148         return ret_conv;
21149 }
21150
21151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21152         if (!ptr_is_owned(_res)) return;
21153         void* _res_ptr = untag_ptr(_res);
21154         CHECK_ACCESS(_res_ptr);
21155         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
21156         FREE(untag_ptr(_res));
21157         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
21158 }
21159
21160 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
21161         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21162         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
21163         return tag_ptr(ret_conv, true);
21164 }
21165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21166         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
21167         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
21168         return ret_conv;
21169 }
21170
21171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21172         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
21173         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21174         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
21175         return tag_ptr(ret_conv, true);
21176 }
21177
21178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21179         LDKInMemorySigner o_conv;
21180         o_conv.inner = untag_ptr(o);
21181         o_conv.is_owned = ptr_is_owned(o);
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21183         o_conv = InMemorySigner_clone(&o_conv);
21184         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21185         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
21186         return tag_ptr(ret_conv, true);
21187 }
21188
21189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21190         void* e_ptr = untag_ptr(e);
21191         CHECK_ACCESS(e_ptr);
21192         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21193         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21194         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21195         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
21196         return tag_ptr(ret_conv, true);
21197 }
21198
21199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21200         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
21201         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
21202         return ret_conv;
21203 }
21204
21205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21206         if (!ptr_is_owned(_res)) return;
21207         void* _res_ptr = untag_ptr(_res);
21208         CHECK_ACCESS(_res_ptr);
21209         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
21210         FREE(untag_ptr(_res));
21211         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
21212 }
21213
21214 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
21215         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21216         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
21217         return tag_ptr(ret_conv, true);
21218 }
21219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21220         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
21221         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
21222         return ret_conv;
21223 }
21224
21225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21226         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
21227         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21228         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
21229         return tag_ptr(ret_conv, true);
21230 }
21231
21232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21233         LDKCVec_TxOutZ _res_constr;
21234         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21235         if (_res_constr.datalen > 0)
21236                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
21237         else
21238                 _res_constr.data = NULL;
21239         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21240         for (size_t h = 0; h < _res_constr.datalen; h++) {
21241                 int64_t _res_conv_7 = _res_vals[h];
21242                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
21243                 CHECK_ACCESS(_res_conv_7_ptr);
21244                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
21245                 FREE(untag_ptr(_res_conv_7));
21246                 _res_constr.data[h] = _res_conv_7_conv;
21247         }
21248         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21249         CVec_TxOutZ_free(_res_constr);
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21253         LDKTransaction o_ref;
21254         o_ref.datalen = (*env)->GetArrayLength(env, o);
21255         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
21256         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21257         o_ref.data_is_owned = true;
21258         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21259         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
21260         return tag_ptr(ret_conv, true);
21261 }
21262
21263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
21264         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21265         *ret_conv = CResult_TransactionNoneZ_err();
21266         return tag_ptr(ret_conv, true);
21267 }
21268
21269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21270         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
21271         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
21272         return ret_conv;
21273 }
21274
21275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21276         if (!ptr_is_owned(_res)) return;
21277         void* _res_ptr = untag_ptr(_res);
21278         CHECK_ACCESS(_res_ptr);
21279         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
21280         FREE(untag_ptr(_res));
21281         CResult_TransactionNoneZ_free(_res_conv);
21282 }
21283
21284 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
21285         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21286         *ret_conv = CResult_TransactionNoneZ_clone(arg);
21287         return tag_ptr(ret_conv, true);
21288 }
21289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21290         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
21291         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
21292         return ret_conv;
21293 }
21294
21295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21296         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
21297         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21298         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
21299         return tag_ptr(ret_conv, true);
21300 }
21301
21302 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
21303         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21304         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
21305         return tag_ptr(ret_conv, true);
21306 }
21307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21308         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
21309         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
21310         return ret_conv;
21311 }
21312
21313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21314         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
21315         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21316         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
21317         return tag_ptr(ret_conv, true);
21318 }
21319
21320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21321         LDKThirtyTwoBytes a_ref;
21322         CHECK((*env)->GetArrayLength(env, a) == 32);
21323         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21324         LDKChannelMonitor b_conv;
21325         b_conv.inner = untag_ptr(b);
21326         b_conv.is_owned = ptr_is_owned(b);
21327         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21328         b_conv = ChannelMonitor_clone(&b_conv);
21329         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21330         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
21331         return tag_ptr(ret_conv, true);
21332 }
21333
21334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21335         if (!ptr_is_owned(_res)) return;
21336         void* _res_ptr = untag_ptr(_res);
21337         CHECK_ACCESS(_res_ptr);
21338         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
21339         FREE(untag_ptr(_res));
21340         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
21341 }
21342
21343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21344         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
21345         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21346         if (_res_constr.datalen > 0)
21347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21348         else
21349                 _res_constr.data = NULL;
21350         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21351         for (size_t j = 0; j < _res_constr.datalen; j++) {
21352                 int64_t _res_conv_35 = _res_vals[j];
21353                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21354                 CHECK_ACCESS(_res_conv_35_ptr);
21355                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
21356                 FREE(untag_ptr(_res_conv_35));
21357                 _res_constr.data[j] = _res_conv_35_conv;
21358         }
21359         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21360         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
21361 }
21362
21363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
21364         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
21365         o_constr.datalen = (*env)->GetArrayLength(env, o);
21366         if (o_constr.datalen > 0)
21367                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21368         else
21369                 o_constr.data = NULL;
21370         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
21371         for (size_t j = 0; j < o_constr.datalen; j++) {
21372                 int64_t o_conv_35 = o_vals[j];
21373                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
21374                 CHECK_ACCESS(o_conv_35_ptr);
21375                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
21376                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
21377                 o_constr.data[j] = o_conv_35_conv;
21378         }
21379         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
21380         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21381         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
21382         return tag_ptr(ret_conv, true);
21383 }
21384
21385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21386         LDKIOError e_conv = LDKIOError_from_java(env, e);
21387         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21388         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
21389         return tag_ptr(ret_conv, true);
21390 }
21391
21392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21393         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
21394         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
21395         return ret_conv;
21396 }
21397
21398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21399         if (!ptr_is_owned(_res)) return;
21400         void* _res_ptr = untag_ptr(_res);
21401         CHECK_ACCESS(_res_ptr);
21402         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
21403         FREE(untag_ptr(_res));
21404         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
21405 }
21406
21407 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
21408         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21409         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
21410         return tag_ptr(ret_conv, true);
21411 }
21412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21413         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
21414         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
21415         return ret_conv;
21416 }
21417
21418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21419         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
21420         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21421         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
21422         return tag_ptr(ret_conv, true);
21423 }
21424
21425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
21426         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21427         *ret_copy = COption_u16Z_some(o);
21428         int64_t ret_ref = tag_ptr(ret_copy, true);
21429         return ret_ref;
21430 }
21431
21432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
21433         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21434         *ret_copy = COption_u16Z_none();
21435         int64_t ret_ref = tag_ptr(ret_copy, true);
21436         return ret_ref;
21437 }
21438
21439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
21440         if (!ptr_is_owned(_res)) return;
21441         void* _res_ptr = untag_ptr(_res);
21442         CHECK_ACCESS(_res_ptr);
21443         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
21444         FREE(untag_ptr(_res));
21445         COption_u16Z_free(_res_conv);
21446 }
21447
21448 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
21449         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21450         *ret_copy = COption_u16Z_clone(arg);
21451         int64_t ret_ref = tag_ptr(ret_copy, true);
21452         return ret_ref;
21453 }
21454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21455         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
21456         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
21457         return ret_conv;
21458 }
21459
21460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21461         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
21462         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21463         *ret_copy = COption_u16Z_clone(orig_conv);
21464         int64_t ret_ref = tag_ptr(ret_copy, true);
21465         return ret_ref;
21466 }
21467
21468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21469         LDKThirtyTwoBytes o_ref;
21470         CHECK((*env)->GetArrayLength(env, o) == 32);
21471         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21472         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21473         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
21474         return tag_ptr(ret_conv, true);
21475 }
21476
21477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21478         void* e_ptr = untag_ptr(e);
21479         CHECK_ACCESS(e_ptr);
21480         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21481         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21482         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21483         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
21484         return tag_ptr(ret_conv, true);
21485 }
21486
21487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21488         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
21489         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
21490         return ret_conv;
21491 }
21492
21493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21494         if (!ptr_is_owned(_res)) return;
21495         void* _res_ptr = untag_ptr(_res);
21496         CHECK_ACCESS(_res_ptr);
21497         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
21498         FREE(untag_ptr(_res));
21499         CResult__u832APIErrorZ_free(_res_conv);
21500 }
21501
21502 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
21503         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21504         *ret_conv = CResult__u832APIErrorZ_clone(arg);
21505         return tag_ptr(ret_conv, true);
21506 }
21507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21508         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
21509         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
21510         return ret_conv;
21511 }
21512
21513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21514         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
21515         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21516         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
21517         return tag_ptr(ret_conv, true);
21518 }
21519
21520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RecentPaymentDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21521         LDKCVec_RecentPaymentDetailsZ _res_constr;
21522         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21523         if (_res_constr.datalen > 0)
21524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
21525         else
21526                 _res_constr.data = NULL;
21527         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21528         for (size_t w = 0; w < _res_constr.datalen; w++) {
21529                 int64_t _res_conv_22 = _res_vals[w];
21530                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
21531                 CHECK_ACCESS(_res_conv_22_ptr);
21532                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
21533                 FREE(untag_ptr(_res_conv_22));
21534                 _res_constr.data[w] = _res_conv_22_conv;
21535         }
21536         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21537         CVec_RecentPaymentDetailsZ_free(_res_constr);
21538 }
21539
21540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21541         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21542         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
21543         return tag_ptr(ret_conv, true);
21544 }
21545
21546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21547         void* e_ptr = untag_ptr(e);
21548         CHECK_ACCESS(e_ptr);
21549         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21550         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21551         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21552         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
21553         return tag_ptr(ret_conv, true);
21554 }
21555
21556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21557         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
21558         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
21559         return ret_conv;
21560 }
21561
21562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21563         if (!ptr_is_owned(_res)) return;
21564         void* _res_ptr = untag_ptr(_res);
21565         CHECK_ACCESS(_res_ptr);
21566         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
21567         FREE(untag_ptr(_res));
21568         CResult_NonePaymentSendFailureZ_free(_res_conv);
21569 }
21570
21571 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
21572         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21573         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
21574         return tag_ptr(ret_conv, true);
21575 }
21576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21577         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
21578         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
21579         return ret_conv;
21580 }
21581
21582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21583         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
21584         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21585         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
21586         return tag_ptr(ret_conv, true);
21587 }
21588
21589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21590         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21591         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
21592         return tag_ptr(ret_conv, true);
21593 }
21594
21595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21596         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21597         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21598         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
21599         return tag_ptr(ret_conv, true);
21600 }
21601
21602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21603         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
21604         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
21605         return ret_conv;
21606 }
21607
21608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21609         if (!ptr_is_owned(_res)) return;
21610         void* _res_ptr = untag_ptr(_res);
21611         CHECK_ACCESS(_res_ptr);
21612         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
21613         FREE(untag_ptr(_res));
21614         CResult_NoneRetryableSendFailureZ_free(_res_conv);
21615 }
21616
21617 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
21618         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21619         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
21620         return tag_ptr(ret_conv, true);
21621 }
21622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21623         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
21624         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
21625         return ret_conv;
21626 }
21627
21628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21629         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
21630         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21631         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
21632         return tag_ptr(ret_conv, true);
21633 }
21634
21635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21636         LDKThirtyTwoBytes o_ref;
21637         CHECK((*env)->GetArrayLength(env, o) == 32);
21638         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21639         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21640         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
21641         return tag_ptr(ret_conv, true);
21642 }
21643
21644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21645         void* e_ptr = untag_ptr(e);
21646         CHECK_ACCESS(e_ptr);
21647         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21648         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21649         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21650         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21651         return tag_ptr(ret_conv, true);
21652 }
21653
21654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21655         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21656         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21657         return ret_conv;
21658 }
21659
21660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21661         if (!ptr_is_owned(_res)) return;
21662         void* _res_ptr = untag_ptr(_res);
21663         CHECK_ACCESS(_res_ptr);
21664         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21665         FREE(untag_ptr(_res));
21666         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21667 }
21668
21669 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21670         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21671         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21672         return tag_ptr(ret_conv, true);
21673 }
21674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21675         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21676         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21677         return ret_conv;
21678 }
21679
21680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21681         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21682         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21683         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21684         return tag_ptr(ret_conv, true);
21685 }
21686
21687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21688         LDKThirtyTwoBytes o_ref;
21689         CHECK((*env)->GetArrayLength(env, o) == 32);
21690         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21691         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21692         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_ok(o_ref);
21693         return tag_ptr(ret_conv, true);
21694 }
21695
21696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21697         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21698         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21699         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_err(e_conv);
21700         return tag_ptr(ret_conv, true);
21701 }
21702
21703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21704         LDKCResult_PaymentHashRetryableSendFailureZ* o_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(o);
21705         jboolean ret_conv = CResult_PaymentHashRetryableSendFailureZ_is_ok(o_conv);
21706         return ret_conv;
21707 }
21708
21709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21710         if (!ptr_is_owned(_res)) return;
21711         void* _res_ptr = untag_ptr(_res);
21712         CHECK_ACCESS(_res_ptr);
21713         LDKCResult_PaymentHashRetryableSendFailureZ _res_conv = *(LDKCResult_PaymentHashRetryableSendFailureZ*)(_res_ptr);
21714         FREE(untag_ptr(_res));
21715         CResult_PaymentHashRetryableSendFailureZ_free(_res_conv);
21716 }
21717
21718 static inline uint64_t CResult_PaymentHashRetryableSendFailureZ_clone_ptr(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR arg) {
21719         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21720         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(arg);
21721         return tag_ptr(ret_conv, true);
21722 }
21723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21724         LDKCResult_PaymentHashRetryableSendFailureZ* arg_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(arg);
21725         int64_t ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone_ptr(arg_conv);
21726         return ret_conv;
21727 }
21728
21729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21730         LDKCResult_PaymentHashRetryableSendFailureZ* orig_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(orig);
21731         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21732         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(orig_conv);
21733         return tag_ptr(ret_conv, true);
21734 }
21735
21736 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21737         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21738         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21739         return tag_ptr(ret_conv, true);
21740 }
21741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21742         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21743         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21744         return ret_conv;
21745 }
21746
21747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21748         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21749         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21750         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21751         return tag_ptr(ret_conv, true);
21752 }
21753
21754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21755         LDKThirtyTwoBytes a_ref;
21756         CHECK((*env)->GetArrayLength(env, a) == 32);
21757         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21758         LDKThirtyTwoBytes b_ref;
21759         CHECK((*env)->GetArrayLength(env, b) == 32);
21760         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21761         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21762         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21763         return tag_ptr(ret_conv, true);
21764 }
21765
21766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21767         if (!ptr_is_owned(_res)) return;
21768         void* _res_ptr = untag_ptr(_res);
21769         CHECK_ACCESS(_res_ptr);
21770         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21771         FREE(untag_ptr(_res));
21772         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21773 }
21774
21775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21776         void* o_ptr = untag_ptr(o);
21777         CHECK_ACCESS(o_ptr);
21778         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21779         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21780         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21781         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21782         return tag_ptr(ret_conv, true);
21783 }
21784
21785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21786         void* e_ptr = untag_ptr(e);
21787         CHECK_ACCESS(e_ptr);
21788         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21789         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21790         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21791         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21792         return tag_ptr(ret_conv, true);
21793 }
21794
21795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21796         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21797         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21798         return ret_conv;
21799 }
21800
21801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21802         if (!ptr_is_owned(_res)) return;
21803         void* _res_ptr = untag_ptr(_res);
21804         CHECK_ACCESS(_res_ptr);
21805         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21806         FREE(untag_ptr(_res));
21807         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21808 }
21809
21810 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21811         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21812         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21813         return tag_ptr(ret_conv, true);
21814 }
21815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21816         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21817         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21818         return ret_conv;
21819 }
21820
21821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21822         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21823         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21824         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21825         return tag_ptr(ret_conv, true);
21826 }
21827
21828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21829         LDKCVec_ThirtyTwoBytesZ _res_constr;
21830         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21831         if (_res_constr.datalen > 0)
21832                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21833         else
21834                 _res_constr.data = NULL;
21835         for (size_t i = 0; i < _res_constr.datalen; i++) {
21836                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21837                 LDKThirtyTwoBytes _res_conv_8_ref;
21838                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21839                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21840                 _res_constr.data[i] = _res_conv_8_ref;
21841         }
21842         CVec_ThirtyTwoBytesZ_free(_res_constr);
21843 }
21844
21845 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21846         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21847         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21848         return tag_ptr(ret_conv, true);
21849 }
21850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21851         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21852         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21853         return ret_conv;
21854 }
21855
21856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21857         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21858         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21859         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21860         return tag_ptr(ret_conv, true);
21861 }
21862
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21864         LDKThirtyTwoBytes a_ref;
21865         CHECK((*env)->GetArrayLength(env, a) == 32);
21866         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21867         LDKThirtyTwoBytes b_ref;
21868         CHECK((*env)->GetArrayLength(env, b) == 32);
21869         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21870         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21871         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21872         return tag_ptr(ret_conv, true);
21873 }
21874
21875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21876         if (!ptr_is_owned(_res)) return;
21877         void* _res_ptr = untag_ptr(_res);
21878         CHECK_ACCESS(_res_ptr);
21879         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21880         FREE(untag_ptr(_res));
21881         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21882 }
21883
21884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21885         void* o_ptr = untag_ptr(o);
21886         CHECK_ACCESS(o_ptr);
21887         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21888         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21889         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21890         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21891         return tag_ptr(ret_conv, true);
21892 }
21893
21894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21895         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21896         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21897         return tag_ptr(ret_conv, true);
21898 }
21899
21900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21901         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21902         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21903         return ret_conv;
21904 }
21905
21906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21907         if (!ptr_is_owned(_res)) return;
21908         void* _res_ptr = untag_ptr(_res);
21909         CHECK_ACCESS(_res_ptr);
21910         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21911         FREE(untag_ptr(_res));
21912         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21913 }
21914
21915 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21916         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21917         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21918         return tag_ptr(ret_conv, true);
21919 }
21920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21921         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21922         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21923         return ret_conv;
21924 }
21925
21926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21927         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21928         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21929         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21930         return tag_ptr(ret_conv, true);
21931 }
21932
21933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21934         void* o_ptr = untag_ptr(o);
21935         CHECK_ACCESS(o_ptr);
21936         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21937         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21938         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21939         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21940         return tag_ptr(ret_conv, true);
21941 }
21942
21943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21944         void* e_ptr = untag_ptr(e);
21945         CHECK_ACCESS(e_ptr);
21946         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21947         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21948         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21949         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21950         return tag_ptr(ret_conv, true);
21951 }
21952
21953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21954         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21955         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21956         return ret_conv;
21957 }
21958
21959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21960         if (!ptr_is_owned(_res)) return;
21961         void* _res_ptr = untag_ptr(_res);
21962         CHECK_ACCESS(_res_ptr);
21963         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21964         FREE(untag_ptr(_res));
21965         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21966 }
21967
21968 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21969         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21970         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21971         return tag_ptr(ret_conv, true);
21972 }
21973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21974         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21975         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21976         return ret_conv;
21977 }
21978
21979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21980         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21981         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21982         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
21983         return tag_ptr(ret_conv, true);
21984 }
21985
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21987         LDKThirtyTwoBytes o_ref;
21988         CHECK((*env)->GetArrayLength(env, o) == 32);
21989         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21990         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21991         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
21992         return tag_ptr(ret_conv, true);
21993 }
21994
21995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
21996         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21997         *ret_conv = CResult_PaymentSecretNoneZ_err();
21998         return tag_ptr(ret_conv, true);
21999 }
22000
22001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22002         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
22003         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
22004         return ret_conv;
22005 }
22006
22007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22008         if (!ptr_is_owned(_res)) return;
22009         void* _res_ptr = untag_ptr(_res);
22010         CHECK_ACCESS(_res_ptr);
22011         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
22012         FREE(untag_ptr(_res));
22013         CResult_PaymentSecretNoneZ_free(_res_conv);
22014 }
22015
22016 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
22017         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22018         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
22019         return tag_ptr(ret_conv, true);
22020 }
22021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22022         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
22023         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
22024         return ret_conv;
22025 }
22026
22027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22028         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
22029         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22030         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
22031         return tag_ptr(ret_conv, true);
22032 }
22033
22034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22035         LDKThirtyTwoBytes o_ref;
22036         CHECK((*env)->GetArrayLength(env, o) == 32);
22037         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22038         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22039         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
22040         return tag_ptr(ret_conv, true);
22041 }
22042
22043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22044         void* e_ptr = untag_ptr(e);
22045         CHECK_ACCESS(e_ptr);
22046         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22047         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22048         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22049         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
22050         return tag_ptr(ret_conv, true);
22051 }
22052
22053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22054         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
22055         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
22056         return ret_conv;
22057 }
22058
22059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22060         if (!ptr_is_owned(_res)) return;
22061         void* _res_ptr = untag_ptr(_res);
22062         CHECK_ACCESS(_res_ptr);
22063         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
22064         FREE(untag_ptr(_res));
22065         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
22066 }
22067
22068 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
22069         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22070         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
22071         return tag_ptr(ret_conv, true);
22072 }
22073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22074         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
22075         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
22076         return ret_conv;
22077 }
22078
22079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22080         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
22081         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22082         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
22083         return tag_ptr(ret_conv, true);
22084 }
22085
22086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22087         LDKThirtyTwoBytes o_ref;
22088         CHECK((*env)->GetArrayLength(env, o) == 32);
22089         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22090         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22091         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
22092         return tag_ptr(ret_conv, true);
22093 }
22094
22095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22096         void* e_ptr = untag_ptr(e);
22097         CHECK_ACCESS(e_ptr);
22098         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22099         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22100         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22101         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
22102         return tag_ptr(ret_conv, true);
22103 }
22104
22105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22106         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
22107         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
22108         return ret_conv;
22109 }
22110
22111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22112         if (!ptr_is_owned(_res)) return;
22113         void* _res_ptr = untag_ptr(_res);
22114         CHECK_ACCESS(_res_ptr);
22115         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
22116         FREE(untag_ptr(_res));
22117         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
22118 }
22119
22120 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
22121         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22122         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
22123         return tag_ptr(ret_conv, true);
22124 }
22125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22126         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
22127         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
22128         return ret_conv;
22129 }
22130
22131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22132         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
22133         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22134         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
22135         return tag_ptr(ret_conv, true);
22136 }
22137
22138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22139         LDKCounterpartyForwardingInfo o_conv;
22140         o_conv.inner = untag_ptr(o);
22141         o_conv.is_owned = ptr_is_owned(o);
22142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22143         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
22144         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22145         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
22146         return tag_ptr(ret_conv, true);
22147 }
22148
22149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22150         void* e_ptr = untag_ptr(e);
22151         CHECK_ACCESS(e_ptr);
22152         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22153         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22154         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22155         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
22156         return tag_ptr(ret_conv, true);
22157 }
22158
22159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22160         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
22161         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
22162         return ret_conv;
22163 }
22164
22165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22166         if (!ptr_is_owned(_res)) return;
22167         void* _res_ptr = untag_ptr(_res);
22168         CHECK_ACCESS(_res_ptr);
22169         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
22170         FREE(untag_ptr(_res));
22171         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
22172 }
22173
22174 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
22175         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22176         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
22177         return tag_ptr(ret_conv, true);
22178 }
22179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22180         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
22181         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
22182         return ret_conv;
22183 }
22184
22185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22186         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
22187         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22188         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
22189         return tag_ptr(ret_conv, true);
22190 }
22191
22192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22193         LDKChannelCounterparty o_conv;
22194         o_conv.inner = untag_ptr(o);
22195         o_conv.is_owned = ptr_is_owned(o);
22196         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22197         o_conv = ChannelCounterparty_clone(&o_conv);
22198         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22199         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
22200         return tag_ptr(ret_conv, true);
22201 }
22202
22203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22204         void* e_ptr = untag_ptr(e);
22205         CHECK_ACCESS(e_ptr);
22206         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22207         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22208         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22209         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
22210         return tag_ptr(ret_conv, true);
22211 }
22212
22213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22214         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
22215         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
22216         return ret_conv;
22217 }
22218
22219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22220         if (!ptr_is_owned(_res)) return;
22221         void* _res_ptr = untag_ptr(_res);
22222         CHECK_ACCESS(_res_ptr);
22223         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
22224         FREE(untag_ptr(_res));
22225         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
22226 }
22227
22228 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
22229         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22230         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
22231         return tag_ptr(ret_conv, true);
22232 }
22233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22234         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
22235         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
22236         return ret_conv;
22237 }
22238
22239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22240         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
22241         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22242         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
22243         return tag_ptr(ret_conv, true);
22244 }
22245
22246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22247         LDKChannelDetails o_conv;
22248         o_conv.inner = untag_ptr(o);
22249         o_conv.is_owned = ptr_is_owned(o);
22250         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22251         o_conv = ChannelDetails_clone(&o_conv);
22252         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22253         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
22254         return tag_ptr(ret_conv, true);
22255 }
22256
22257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22258         void* e_ptr = untag_ptr(e);
22259         CHECK_ACCESS(e_ptr);
22260         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22261         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22262         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22263         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
22264         return tag_ptr(ret_conv, true);
22265 }
22266
22267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22268         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
22269         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
22270         return ret_conv;
22271 }
22272
22273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22274         if (!ptr_is_owned(_res)) return;
22275         void* _res_ptr = untag_ptr(_res);
22276         CHECK_ACCESS(_res_ptr);
22277         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
22278         FREE(untag_ptr(_res));
22279         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
22280 }
22281
22282 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
22283         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22284         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
22285         return tag_ptr(ret_conv, true);
22286 }
22287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22288         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
22289         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
22290         return ret_conv;
22291 }
22292
22293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22294         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
22295         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22296         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
22297         return tag_ptr(ret_conv, true);
22298 }
22299
22300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22301         LDKPhantomRouteHints o_conv;
22302         o_conv.inner = untag_ptr(o);
22303         o_conv.is_owned = ptr_is_owned(o);
22304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22305         o_conv = PhantomRouteHints_clone(&o_conv);
22306         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22307         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
22308         return tag_ptr(ret_conv, true);
22309 }
22310
22311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22312         void* e_ptr = untag_ptr(e);
22313         CHECK_ACCESS(e_ptr);
22314         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22315         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22316         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22317         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
22318         return tag_ptr(ret_conv, true);
22319 }
22320
22321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22322         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
22323         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
22324         return ret_conv;
22325 }
22326
22327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22328         if (!ptr_is_owned(_res)) return;
22329         void* _res_ptr = untag_ptr(_res);
22330         CHECK_ACCESS(_res_ptr);
22331         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
22332         FREE(untag_ptr(_res));
22333         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
22334 }
22335
22336 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
22337         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22338         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
22339         return tag_ptr(ret_conv, true);
22340 }
22341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22342         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
22343         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
22344         return ret_conv;
22345 }
22346
22347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22348         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
22349         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22350         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
22351         return tag_ptr(ret_conv, true);
22352 }
22353
22354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22355         LDKCVec_ChannelMonitorZ _res_constr;
22356         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22357         if (_res_constr.datalen > 0)
22358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22359         else
22360                 _res_constr.data = NULL;
22361         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22362         for (size_t q = 0; q < _res_constr.datalen; q++) {
22363                 int64_t _res_conv_16 = _res_vals[q];
22364                 LDKChannelMonitor _res_conv_16_conv;
22365                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
22366                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
22367                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22368                 _res_constr.data[q] = _res_conv_16_conv;
22369         }
22370         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22371         CVec_ChannelMonitorZ_free(_res_constr);
22372 }
22373
22374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22375         LDKThirtyTwoBytes a_ref;
22376         CHECK((*env)->GetArrayLength(env, a) == 32);
22377         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22378         LDKChannelManager b_conv;
22379         b_conv.inner = untag_ptr(b);
22380         b_conv.is_owned = ptr_is_owned(b);
22381         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22382         // WARNING: we need a move here but no clone is available for LDKChannelManager
22383         
22384         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
22385         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
22386         return tag_ptr(ret_conv, true);
22387 }
22388
22389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22390         if (!ptr_is_owned(_res)) return;
22391         void* _res_ptr = untag_ptr(_res);
22392         CHECK_ACCESS(_res_ptr);
22393         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
22394         FREE(untag_ptr(_res));
22395         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
22396 }
22397
22398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22399         void* o_ptr = untag_ptr(o);
22400         CHECK_ACCESS(o_ptr);
22401         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
22402         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
22403         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22404         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
22405         return tag_ptr(ret_conv, true);
22406 }
22407
22408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22409         void* e_ptr = untag_ptr(e);
22410         CHECK_ACCESS(e_ptr);
22411         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22412         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22413         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22414         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
22415         return tag_ptr(ret_conv, true);
22416 }
22417
22418 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22419         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
22420         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
22421         return ret_conv;
22422 }
22423
22424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22425         if (!ptr_is_owned(_res)) return;
22426         void* _res_ptr = untag_ptr(_res);
22427         CHECK_ACCESS(_res_ptr);
22428         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
22429         FREE(untag_ptr(_res));
22430         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
22431 }
22432
22433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22434         LDKChannelConfig o_conv;
22435         o_conv.inner = untag_ptr(o);
22436         o_conv.is_owned = ptr_is_owned(o);
22437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22438         o_conv = ChannelConfig_clone(&o_conv);
22439         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22440         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
22441         return tag_ptr(ret_conv, true);
22442 }
22443
22444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22445         void* e_ptr = untag_ptr(e);
22446         CHECK_ACCESS(e_ptr);
22447         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22448         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22449         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22450         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
22451         return tag_ptr(ret_conv, true);
22452 }
22453
22454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22455         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
22456         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
22457         return ret_conv;
22458 }
22459
22460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22461         if (!ptr_is_owned(_res)) return;
22462         void* _res_ptr = untag_ptr(_res);
22463         CHECK_ACCESS(_res_ptr);
22464         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
22465         FREE(untag_ptr(_res));
22466         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
22467 }
22468
22469 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
22470         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22471         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
22472         return tag_ptr(ret_conv, true);
22473 }
22474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22475         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
22476         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
22477         return ret_conv;
22478 }
22479
22480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22481         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
22482         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22483         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
22484         return tag_ptr(ret_conv, true);
22485 }
22486
22487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22488         void* o_ptr = untag_ptr(o);
22489         CHECK_ACCESS(o_ptr);
22490         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
22491         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
22492         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22493         *ret_copy = COption_APIErrorZ_some(o_conv);
22494         int64_t ret_ref = tag_ptr(ret_copy, true);
22495         return ret_ref;
22496 }
22497
22498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1none(JNIEnv *env, jclass clz) {
22499         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22500         *ret_copy = COption_APIErrorZ_none();
22501         int64_t ret_ref = tag_ptr(ret_copy, true);
22502         return ret_ref;
22503 }
22504
22505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22506         if (!ptr_is_owned(_res)) return;
22507         void* _res_ptr = untag_ptr(_res);
22508         CHECK_ACCESS(_res_ptr);
22509         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
22510         FREE(untag_ptr(_res));
22511         COption_APIErrorZ_free(_res_conv);
22512 }
22513
22514 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
22515         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22516         *ret_copy = COption_APIErrorZ_clone(arg);
22517         int64_t ret_ref = tag_ptr(ret_copy, true);
22518         return ret_ref;
22519 }
22520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22521         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
22522         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
22523         return ret_conv;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22527         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
22528         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22529         *ret_copy = COption_APIErrorZ_clone(orig_conv);
22530         int64_t ret_ref = tag_ptr(ret_copy, true);
22531         return ret_ref;
22532 }
22533
22534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22535         void* o_ptr = untag_ptr(o);
22536         CHECK_ACCESS(o_ptr);
22537         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
22538         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
22539         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22540         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
22541         return tag_ptr(ret_conv, true);
22542 }
22543
22544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22545         void* e_ptr = untag_ptr(e);
22546         CHECK_ACCESS(e_ptr);
22547         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22548         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22549         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22550         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
22551         return tag_ptr(ret_conv, true);
22552 }
22553
22554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22555         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
22556         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
22557         return ret_conv;
22558 }
22559
22560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22561         if (!ptr_is_owned(_res)) return;
22562         void* _res_ptr = untag_ptr(_res);
22563         CHECK_ACCESS(_res_ptr);
22564         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
22565         FREE(untag_ptr(_res));
22566         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
22567 }
22568
22569 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
22570         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22571         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
22572         return tag_ptr(ret_conv, true);
22573 }
22574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22575         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
22576         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
22577         return ret_conv;
22578 }
22579
22580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22581         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
22582         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22583         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
22584         return tag_ptr(ret_conv, true);
22585 }
22586
22587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22588         LDKUntrustedString o_conv;
22589         o_conv.inner = untag_ptr(o);
22590         o_conv.is_owned = ptr_is_owned(o);
22591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22592         o_conv = UntrustedString_clone(&o_conv);
22593         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22594         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
22595         return tag_ptr(ret_conv, true);
22596 }
22597
22598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22599         void* e_ptr = untag_ptr(e);
22600         CHECK_ACCESS(e_ptr);
22601         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22602         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22603         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22604         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
22605         return tag_ptr(ret_conv, true);
22606 }
22607
22608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22609         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
22610         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
22611         return ret_conv;
22612 }
22613
22614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22615         if (!ptr_is_owned(_res)) return;
22616         void* _res_ptr = untag_ptr(_res);
22617         CHECK_ACCESS(_res_ptr);
22618         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
22619         FREE(untag_ptr(_res));
22620         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
22621 }
22622
22623 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
22624         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22625         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
22626         return tag_ptr(ret_conv, true);
22627 }
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22629         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
22630         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
22631         return ret_conv;
22632 }
22633
22634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22635         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
22636         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22637         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
22638         return tag_ptr(ret_conv, true);
22639 }
22640
22641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22642         LDKOutPoint o_conv;
22643         o_conv.inner = untag_ptr(o);
22644         o_conv.is_owned = ptr_is_owned(o);
22645         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22646         o_conv = OutPoint_clone(&o_conv);
22647         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22648         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
22649         return tag_ptr(ret_conv, true);
22650 }
22651
22652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22653         void* e_ptr = untag_ptr(e);
22654         CHECK_ACCESS(e_ptr);
22655         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22656         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22657         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22658         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
22659         return tag_ptr(ret_conv, true);
22660 }
22661
22662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22663         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
22664         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
22665         return ret_conv;
22666 }
22667
22668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22669         if (!ptr_is_owned(_res)) return;
22670         void* _res_ptr = untag_ptr(_res);
22671         CHECK_ACCESS(_res_ptr);
22672         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
22673         FREE(untag_ptr(_res));
22674         CResult_OutPointDecodeErrorZ_free(_res_conv);
22675 }
22676
22677 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
22678         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22679         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
22680         return tag_ptr(ret_conv, true);
22681 }
22682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22683         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
22684         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
22685         return ret_conv;
22686 }
22687
22688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22689         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
22690         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22691         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
22692         return tag_ptr(ret_conv, true);
22693 }
22694
22695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22696         void* o_ptr = untag_ptr(o);
22697         CHECK_ACCESS(o_ptr);
22698         LDKType o_conv = *(LDKType*)(o_ptr);
22699         if (o_conv.free == LDKType_JCalls_free) {
22700                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22701                 LDKType_JCalls_cloned(&o_conv);
22702         }
22703         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22704         *ret_copy = COption_TypeZ_some(o_conv);
22705         int64_t ret_ref = tag_ptr(ret_copy, true);
22706         return ret_ref;
22707 }
22708
22709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
22710         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22711         *ret_copy = COption_TypeZ_none();
22712         int64_t ret_ref = tag_ptr(ret_copy, true);
22713         return ret_ref;
22714 }
22715
22716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22717         if (!ptr_is_owned(_res)) return;
22718         void* _res_ptr = untag_ptr(_res);
22719         CHECK_ACCESS(_res_ptr);
22720         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22721         FREE(untag_ptr(_res));
22722         COption_TypeZ_free(_res_conv);
22723 }
22724
22725 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22726         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22727         *ret_copy = COption_TypeZ_clone(arg);
22728         int64_t ret_ref = tag_ptr(ret_copy, true);
22729         return ret_ref;
22730 }
22731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22732         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22733         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22734         return ret_conv;
22735 }
22736
22737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22738         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22739         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22740         *ret_copy = COption_TypeZ_clone(orig_conv);
22741         int64_t ret_ref = tag_ptr(ret_copy, true);
22742         return ret_ref;
22743 }
22744
22745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22746         void* o_ptr = untag_ptr(o);
22747         CHECK_ACCESS(o_ptr);
22748         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22749         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22750         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22751         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22752         return tag_ptr(ret_conv, true);
22753 }
22754
22755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22756         void* e_ptr = untag_ptr(e);
22757         CHECK_ACCESS(e_ptr);
22758         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22759         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22760         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22761         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22762         return tag_ptr(ret_conv, true);
22763 }
22764
22765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22766         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22767         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22768         return ret_conv;
22769 }
22770
22771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22772         if (!ptr_is_owned(_res)) return;
22773         void* _res_ptr = untag_ptr(_res);
22774         CHECK_ACCESS(_res_ptr);
22775         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22776         FREE(untag_ptr(_res));
22777         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22778 }
22779
22780 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22781         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22782         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22783         return tag_ptr(ret_conv, true);
22784 }
22785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22786         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22787         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22788         return ret_conv;
22789 }
22790
22791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22792         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22793         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22794         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22795         return tag_ptr(ret_conv, true);
22796 }
22797
22798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22799         LDKThirtyTwoBytes o_ref;
22800         CHECK((*env)->GetArrayLength(env, o) == 32);
22801         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22802         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22803         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
22804         return tag_ptr(ret_conv, true);
22805 }
22806
22807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22808         void* e_ptr = untag_ptr(e);
22809         CHECK_ACCESS(e_ptr);
22810         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22811         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22812         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22813         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
22814         return tag_ptr(ret_conv, true);
22815 }
22816
22817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22818         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
22819         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
22820         return ret_conv;
22821 }
22822
22823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22824         if (!ptr_is_owned(_res)) return;
22825         void* _res_ptr = untag_ptr(_res);
22826         CHECK_ACCESS(_res_ptr);
22827         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
22828         FREE(untag_ptr(_res));
22829         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
22830 }
22831
22832 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
22833         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22834         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
22835         return tag_ptr(ret_conv, true);
22836 }
22837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22838         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
22839         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
22840         return ret_conv;
22841 }
22842
22843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22844         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
22845         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22846         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
22847         return tag_ptr(ret_conv, true);
22848 }
22849
22850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22851         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22852         *ret_conv = CResult_NonePaymentErrorZ_ok();
22853         return tag_ptr(ret_conv, true);
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22857         void* e_ptr = untag_ptr(e);
22858         CHECK_ACCESS(e_ptr);
22859         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22860         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22861         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22862         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22863         return tag_ptr(ret_conv, true);
22864 }
22865
22866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22867         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22868         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22869         return ret_conv;
22870 }
22871
22872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22873         if (!ptr_is_owned(_res)) return;
22874         void* _res_ptr = untag_ptr(_res);
22875         CHECK_ACCESS(_res_ptr);
22876         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22877         FREE(untag_ptr(_res));
22878         CResult_NonePaymentErrorZ_free(_res_conv);
22879 }
22880
22881 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22882         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22883         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22884         return tag_ptr(ret_conv, true);
22885 }
22886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22887         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22888         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22889         return ret_conv;
22890 }
22891
22892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22893         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22894         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22895         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22896         return tag_ptr(ret_conv, true);
22897 }
22898
22899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22900         LDKStr o_conv = java_to_owned_str(env, o);
22901         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22902         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22903         return tag_ptr(ret_conv, true);
22904 }
22905
22906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22907         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22908         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22909         *ret_conv = CResult_StringErrorZ_err(e_conv);
22910         return tag_ptr(ret_conv, true);
22911 }
22912
22913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22914         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22915         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22916         return ret_conv;
22917 }
22918
22919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22920         if (!ptr_is_owned(_res)) return;
22921         void* _res_ptr = untag_ptr(_res);
22922         CHECK_ACCESS(_res_ptr);
22923         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22924         FREE(untag_ptr(_res));
22925         CResult_StringErrorZ_free(_res_conv);
22926 }
22927
22928 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22929         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22930         *ret_conv = CResult_StringErrorZ_clone(arg);
22931         return tag_ptr(ret_conv, true);
22932 }
22933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22934         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22935         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22936         return ret_conv;
22937 }
22938
22939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22940         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22941         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22942         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22943         return tag_ptr(ret_conv, true);
22944 }
22945
22946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22947         LDKChannelMonitorUpdate o_conv;
22948         o_conv.inner = untag_ptr(o);
22949         o_conv.is_owned = ptr_is_owned(o);
22950         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22951         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22952         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22953         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22954         return tag_ptr(ret_conv, true);
22955 }
22956
22957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22958         void* e_ptr = untag_ptr(e);
22959         CHECK_ACCESS(e_ptr);
22960         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22961         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22962         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22963         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22964         return tag_ptr(ret_conv, true);
22965 }
22966
22967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22968         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22969         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22970         return ret_conv;
22971 }
22972
22973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22974         if (!ptr_is_owned(_res)) return;
22975         void* _res_ptr = untag_ptr(_res);
22976         CHECK_ACCESS(_res_ptr);
22977         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22978         FREE(untag_ptr(_res));
22979         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22980 }
22981
22982 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22983         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22984         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22985         return tag_ptr(ret_conv, true);
22986 }
22987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22988         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22989         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22990         return ret_conv;
22991 }
22992
22993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22994         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22995         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22996         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22997         return tag_ptr(ret_conv, true);
22998 }
22999
23000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23001         void* o_ptr = untag_ptr(o);
23002         CHECK_ACCESS(o_ptr);
23003         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
23004         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
23005         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23006         *ret_copy = COption_MonitorEventZ_some(o_conv);
23007         int64_t ret_ref = tag_ptr(ret_copy, true);
23008         return ret_ref;
23009 }
23010
23011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
23012         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23013         *ret_copy = COption_MonitorEventZ_none();
23014         int64_t ret_ref = tag_ptr(ret_copy, true);
23015         return ret_ref;
23016 }
23017
23018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23019         if (!ptr_is_owned(_res)) return;
23020         void* _res_ptr = untag_ptr(_res);
23021         CHECK_ACCESS(_res_ptr);
23022         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
23023         FREE(untag_ptr(_res));
23024         COption_MonitorEventZ_free(_res_conv);
23025 }
23026
23027 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
23028         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23029         *ret_copy = COption_MonitorEventZ_clone(arg);
23030         int64_t ret_ref = tag_ptr(ret_copy, true);
23031         return ret_ref;
23032 }
23033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23034         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
23035         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
23036         return ret_conv;
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23040         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
23041         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23042         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
23043         int64_t ret_ref = tag_ptr(ret_copy, true);
23044         return ret_ref;
23045 }
23046
23047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23048         void* o_ptr = untag_ptr(o);
23049         CHECK_ACCESS(o_ptr);
23050         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
23051         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
23052         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23053         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
23054         return tag_ptr(ret_conv, true);
23055 }
23056
23057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23058         void* e_ptr = untag_ptr(e);
23059         CHECK_ACCESS(e_ptr);
23060         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23061         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23062         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23063         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
23064         return tag_ptr(ret_conv, true);
23065 }
23066
23067 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23068         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
23069         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
23070         return ret_conv;
23071 }
23072
23073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23074         if (!ptr_is_owned(_res)) return;
23075         void* _res_ptr = untag_ptr(_res);
23076         CHECK_ACCESS(_res_ptr);
23077         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
23078         FREE(untag_ptr(_res));
23079         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
23080 }
23081
23082 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
23083         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23084         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
23085         return tag_ptr(ret_conv, true);
23086 }
23087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23088         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
23089         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
23090         return ret_conv;
23091 }
23092
23093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23094         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
23095         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23096         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
23097         return tag_ptr(ret_conv, true);
23098 }
23099
23100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23101         LDKHTLCUpdate o_conv;
23102         o_conv.inner = untag_ptr(o);
23103         o_conv.is_owned = ptr_is_owned(o);
23104         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23105         o_conv = HTLCUpdate_clone(&o_conv);
23106         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23107         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
23108         return tag_ptr(ret_conv, true);
23109 }
23110
23111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23112         void* e_ptr = untag_ptr(e);
23113         CHECK_ACCESS(e_ptr);
23114         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23115         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23116         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23117         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
23118         return tag_ptr(ret_conv, true);
23119 }
23120
23121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23122         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
23123         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
23124         return ret_conv;
23125 }
23126
23127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23128         if (!ptr_is_owned(_res)) return;
23129         void* _res_ptr = untag_ptr(_res);
23130         CHECK_ACCESS(_res_ptr);
23131         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
23132         FREE(untag_ptr(_res));
23133         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
23134 }
23135
23136 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
23137         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23138         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
23139         return tag_ptr(ret_conv, true);
23140 }
23141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23142         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
23143         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
23144         return ret_conv;
23145 }
23146
23147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23148         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
23149         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23150         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
23151         return tag_ptr(ret_conv, true);
23152 }
23153
23154 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
23155         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23156         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
23157         return tag_ptr(ret_conv, true);
23158 }
23159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23160         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
23161         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
23162         return ret_conv;
23163 }
23164
23165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23166         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
23167         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23168         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
23169         return tag_ptr(ret_conv, true);
23170 }
23171
23172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
23173         LDKOutPoint a_conv;
23174         a_conv.inner = untag_ptr(a);
23175         a_conv.is_owned = ptr_is_owned(a);
23176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23177         a_conv = OutPoint_clone(&a_conv);
23178         LDKCVec_u8Z b_ref;
23179         b_ref.datalen = (*env)->GetArrayLength(env, b);
23180         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23181         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23182         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23183         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
23184         return tag_ptr(ret_conv, true);
23185 }
23186
23187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23188         if (!ptr_is_owned(_res)) return;
23189         void* _res_ptr = untag_ptr(_res);
23190         CHECK_ACCESS(_res_ptr);
23191         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
23192         FREE(untag_ptr(_res));
23193         C2Tuple_OutPointScriptZ_free(_res_conv);
23194 }
23195
23196 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
23197         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23198         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
23199         return tag_ptr(ret_conv, true);
23200 }
23201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23202         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
23203         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
23204         return ret_conv;
23205 }
23206
23207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23208         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
23209         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23210         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
23211         return tag_ptr(ret_conv, true);
23212 }
23213
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
23215         LDKCVec_u8Z b_ref;
23216         b_ref.datalen = (*env)->GetArrayLength(env, b);
23217         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23218         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23219         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23220         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
23221         return tag_ptr(ret_conv, true);
23222 }
23223
23224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23225         if (!ptr_is_owned(_res)) return;
23226         void* _res_ptr = untag_ptr(_res);
23227         CHECK_ACCESS(_res_ptr);
23228         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
23229         FREE(untag_ptr(_res));
23230         C2Tuple_u32ScriptZ_free(_res_conv);
23231 }
23232
23233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23234         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
23235         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23236         if (_res_constr.datalen > 0)
23237                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23238         else
23239                 _res_constr.data = NULL;
23240         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23241         for (size_t v = 0; v < _res_constr.datalen; v++) {
23242                 int64_t _res_conv_21 = _res_vals[v];
23243                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
23244                 CHECK_ACCESS(_res_conv_21_ptr);
23245                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
23246                 FREE(untag_ptr(_res_conv_21));
23247                 _res_constr.data[v] = _res_conv_21_conv;
23248         }
23249         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23250         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
23251 }
23252
23253 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
23254         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23255         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
23256         return tag_ptr(ret_conv, true);
23257 }
23258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23259         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
23260         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
23261         return ret_conv;
23262 }
23263
23264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23265         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
23266         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23267         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
23268         return tag_ptr(ret_conv, true);
23269 }
23270
23271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23272         LDKThirtyTwoBytes a_ref;
23273         CHECK((*env)->GetArrayLength(env, a) == 32);
23274         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23275         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
23276         b_constr.datalen = (*env)->GetArrayLength(env, b);
23277         if (b_constr.datalen > 0)
23278                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23279         else
23280                 b_constr.data = NULL;
23281         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23282         for (size_t v = 0; v < b_constr.datalen; v++) {
23283                 int64_t b_conv_21 = b_vals[v];
23284                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
23285                 CHECK_ACCESS(b_conv_21_ptr);
23286                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
23287                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
23288                 b_constr.data[v] = b_conv_21_conv;
23289         }
23290         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23291         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23292         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
23293         return tag_ptr(ret_conv, true);
23294 }
23295
23296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23297         if (!ptr_is_owned(_res)) return;
23298         void* _res_ptr = untag_ptr(_res);
23299         CHECK_ACCESS(_res_ptr);
23300         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
23301         FREE(untag_ptr(_res));
23302         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
23303 }
23304
23305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23306         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
23307         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23308         if (_res_constr.datalen > 0)
23309                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
23310         else
23311                 _res_constr.data = NULL;
23312         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23313         for (size_t o = 0; o < _res_constr.datalen; o++) {
23314                 int64_t _res_conv_40 = _res_vals[o];
23315                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23316                 CHECK_ACCESS(_res_conv_40_ptr);
23317                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
23318                 FREE(untag_ptr(_res_conv_40));
23319                 _res_constr.data[o] = _res_conv_40_conv;
23320         }
23321         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23322         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
23323 }
23324
23325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23326         LDKCVec_EventZ _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(LDKEvent), "LDKCVec_EventZ Elements");
23330         else
23331                 _res_constr.data = NULL;
23332         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23333         for (size_t h = 0; h < _res_constr.datalen; h++) {
23334                 int64_t _res_conv_7 = _res_vals[h];
23335                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
23336                 CHECK_ACCESS(_res_conv_7_ptr);
23337                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
23338                 FREE(untag_ptr(_res_conv_7));
23339                 _res_constr.data[h] = _res_conv_7_conv;
23340         }
23341         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23342         CVec_EventZ_free(_res_constr);
23343 }
23344
23345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
23346         LDKCVec_TransactionZ _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(LDKTransaction), "LDKCVec_TransactionZ Elements");
23350         else
23351                 _res_constr.data = NULL;
23352         for (size_t i = 0; i < _res_constr.datalen; i++) {
23353                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
23354                 LDKTransaction _res_conv_8_ref;
23355                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
23356                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
23357                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
23358                 _res_conv_8_ref.data_is_owned = true;
23359                 _res_constr.data[i] = _res_conv_8_ref;
23360         }
23361         CVec_TransactionZ_free(_res_constr);
23362 }
23363
23364 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
23365         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23366         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
23367         return tag_ptr(ret_conv, true);
23368 }
23369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23370         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
23371         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
23372         return ret_conv;
23373 }
23374
23375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23376         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
23377         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23378         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
23379         return tag_ptr(ret_conv, true);
23380 }
23381
23382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
23383         void* b_ptr = untag_ptr(b);
23384         CHECK_ACCESS(b_ptr);
23385         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
23386         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
23387         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23388         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
23389         return tag_ptr(ret_conv, true);
23390 }
23391
23392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23393         if (!ptr_is_owned(_res)) return;
23394         void* _res_ptr = untag_ptr(_res);
23395         CHECK_ACCESS(_res_ptr);
23396         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
23397         FREE(untag_ptr(_res));
23398         C2Tuple_u32TxOutZ_free(_res_conv);
23399 }
23400
23401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23402         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
23403         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23404         if (_res_constr.datalen > 0)
23405                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23406         else
23407                 _res_constr.data = NULL;
23408         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23409         for (size_t u = 0; u < _res_constr.datalen; u++) {
23410                 int64_t _res_conv_20 = _res_vals[u];
23411                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
23412                 CHECK_ACCESS(_res_conv_20_ptr);
23413                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
23414                 FREE(untag_ptr(_res_conv_20));
23415                 _res_constr.data[u] = _res_conv_20_conv;
23416         }
23417         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23418         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
23419 }
23420
23421 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
23422         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23423         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
23424         return tag_ptr(ret_conv, true);
23425 }
23426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23427         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
23428         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
23429         return ret_conv;
23430 }
23431
23432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23433         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
23434         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23435         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
23436         return tag_ptr(ret_conv, true);
23437 }
23438
23439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23440         LDKThirtyTwoBytes a_ref;
23441         CHECK((*env)->GetArrayLength(env, a) == 32);
23442         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23443         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
23444         b_constr.datalen = (*env)->GetArrayLength(env, b);
23445         if (b_constr.datalen > 0)
23446                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23447         else
23448                 b_constr.data = NULL;
23449         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23450         for (size_t u = 0; u < b_constr.datalen; u++) {
23451                 int64_t b_conv_20 = b_vals[u];
23452                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
23453                 CHECK_ACCESS(b_conv_20_ptr);
23454                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
23455                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
23456                 b_constr.data[u] = b_conv_20_conv;
23457         }
23458         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23459         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23460         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
23461         return tag_ptr(ret_conv, true);
23462 }
23463
23464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23465         if (!ptr_is_owned(_res)) return;
23466         void* _res_ptr = untag_ptr(_res);
23467         CHECK_ACCESS(_res_ptr);
23468         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
23469         FREE(untag_ptr(_res));
23470         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
23471 }
23472
23473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23474         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
23475         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23476         if (_res_constr.datalen > 0)
23477                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
23478         else
23479                 _res_constr.data = NULL;
23480         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23481         for (size_t n = 0; n < _res_constr.datalen; n++) {
23482                 int64_t _res_conv_39 = _res_vals[n];
23483                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
23484                 CHECK_ACCESS(_res_conv_39_ptr);
23485                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
23486                 FREE(untag_ptr(_res_conv_39));
23487                 _res_constr.data[n] = _res_conv_39_conv;
23488         }
23489         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23490         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
23491 }
23492
23493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23494         LDKCVec_BalanceZ _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(LDKBalance), "LDKCVec_BalanceZ Elements");
23498         else
23499                 _res_constr.data = NULL;
23500         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23501         for (size_t j = 0; j < _res_constr.datalen; j++) {
23502                 int64_t _res_conv_9 = _res_vals[j];
23503                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
23504                 CHECK_ACCESS(_res_conv_9_ptr);
23505                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
23506                 FREE(untag_ptr(_res_conv_9));
23507                 _res_constr.data[j] = _res_conv_9_conv;
23508         }
23509         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23510         CVec_BalanceZ_free(_res_constr);
23511 }
23512
23513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23514         void* o_ptr = untag_ptr(o);
23515         CHECK_ACCESS(o_ptr);
23516         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
23517         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
23518         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23519         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
23520         return tag_ptr(ret_conv, true);
23521 }
23522
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23524         void* e_ptr = untag_ptr(e);
23525         CHECK_ACCESS(e_ptr);
23526         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23527         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23528         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23529         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
23530         return tag_ptr(ret_conv, true);
23531 }
23532
23533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23534         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
23535         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
23536         return ret_conv;
23537 }
23538
23539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23540         if (!ptr_is_owned(_res)) return;
23541         void* _res_ptr = untag_ptr(_res);
23542         CHECK_ACCESS(_res_ptr);
23543         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
23544         FREE(untag_ptr(_res));
23545         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
23546 }
23547
23548 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
23549         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23550         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
23551         return tag_ptr(ret_conv, true);
23552 }
23553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23554         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
23555         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
23556         return ret_conv;
23557 }
23558
23559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23560         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
23561         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23562         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
23563         return tag_ptr(ret_conv, true);
23564 }
23565
23566 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
23567         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23568         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
23569         return tag_ptr(ret_conv, true);
23570 }
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23572         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
23573         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
23574         return ret_conv;
23575 }
23576
23577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23578         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
23579         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23580         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
23581         return tag_ptr(ret_conv, true);
23582 }
23583
23584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23585         LDKPublicKey a_ref;
23586         CHECK((*env)->GetArrayLength(env, a) == 33);
23587         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23588         void* b_ptr = untag_ptr(b);
23589         CHECK_ACCESS(b_ptr);
23590         LDKType b_conv = *(LDKType*)(b_ptr);
23591         if (b_conv.free == LDKType_JCalls_free) {
23592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23593                 LDKType_JCalls_cloned(&b_conv);
23594         }
23595         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23596         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
23597         return tag_ptr(ret_conv, true);
23598 }
23599
23600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23601         if (!ptr_is_owned(_res)) return;
23602         void* _res_ptr = untag_ptr(_res);
23603         CHECK_ACCESS(_res_ptr);
23604         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
23605         FREE(untag_ptr(_res));
23606         C2Tuple_PublicKeyTypeZ_free(_res_conv);
23607 }
23608
23609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23610         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
23611         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23612         if (_res_constr.datalen > 0)
23613                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
23614         else
23615                 _res_constr.data = NULL;
23616         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23617         for (size_t z = 0; z < _res_constr.datalen; z++) {
23618                 int64_t _res_conv_25 = _res_vals[z];
23619                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
23620                 CHECK_ACCESS(_res_conv_25_ptr);
23621                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
23622                 FREE(untag_ptr(_res_conv_25));
23623                 _res_constr.data[z] = _res_conv_25_conv;
23624         }
23625         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23626         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
23627 }
23628
23629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23630         void* o_ptr = untag_ptr(o);
23631         CHECK_ACCESS(o_ptr);
23632         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
23633         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
23634                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23635                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
23636         }
23637         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23638         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
23639         int64_t ret_ref = tag_ptr(ret_copy, true);
23640         return ret_ref;
23641 }
23642
23643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
23644         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23645         *ret_copy = COption_CustomOnionMessageContentsZ_none();
23646         int64_t ret_ref = tag_ptr(ret_copy, true);
23647         return ret_ref;
23648 }
23649
23650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23651         if (!ptr_is_owned(_res)) return;
23652         void* _res_ptr = untag_ptr(_res);
23653         CHECK_ACCESS(_res_ptr);
23654         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
23655         FREE(untag_ptr(_res));
23656         COption_CustomOnionMessageContentsZ_free(_res_conv);
23657 }
23658
23659 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
23660         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23661         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
23662         int64_t ret_ref = tag_ptr(ret_copy, true);
23663         return ret_ref;
23664 }
23665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23666         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
23667         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
23668         return ret_conv;
23669 }
23670
23671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23672         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
23673         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23674         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
23675         int64_t ret_ref = tag_ptr(ret_copy, true);
23676         return ret_ref;
23677 }
23678
23679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23680         void* o_ptr = untag_ptr(o);
23681         CHECK_ACCESS(o_ptr);
23682         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
23683         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
23684         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23685         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
23686         return tag_ptr(ret_conv, true);
23687 }
23688
23689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23690         void* e_ptr = untag_ptr(e);
23691         CHECK_ACCESS(e_ptr);
23692         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23693         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23694         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23695         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
23696         return tag_ptr(ret_conv, true);
23697 }
23698
23699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23700         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
23701         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
23702         return ret_conv;
23703 }
23704
23705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23706         if (!ptr_is_owned(_res)) return;
23707         void* _res_ptr = untag_ptr(_res);
23708         CHECK_ACCESS(_res_ptr);
23709         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
23710         FREE(untag_ptr(_res));
23711         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
23712 }
23713
23714 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
23715         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23716         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
23717         return tag_ptr(ret_conv, true);
23718 }
23719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23720         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
23721         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
23722         return ret_conv;
23723 }
23724
23725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23726         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
23727         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23728         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
23729         return tag_ptr(ret_conv, true);
23730 }
23731
23732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23733         void* o_ptr = untag_ptr(o);
23734         CHECK_ACCESS(o_ptr);
23735         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23736         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23737         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23738         *ret_copy = COption_NetAddressZ_some(o_conv);
23739         int64_t ret_ref = tag_ptr(ret_copy, true);
23740         return ret_ref;
23741 }
23742
23743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
23744         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23745         *ret_copy = COption_NetAddressZ_none();
23746         int64_t ret_ref = tag_ptr(ret_copy, true);
23747         return ret_ref;
23748 }
23749
23750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23751         if (!ptr_is_owned(_res)) return;
23752         void* _res_ptr = untag_ptr(_res);
23753         CHECK_ACCESS(_res_ptr);
23754         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
23755         FREE(untag_ptr(_res));
23756         COption_NetAddressZ_free(_res_conv);
23757 }
23758
23759 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
23760         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23761         *ret_copy = COption_NetAddressZ_clone(arg);
23762         int64_t ret_ref = tag_ptr(ret_copy, true);
23763         return ret_ref;
23764 }
23765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23766         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
23767         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
23768         return ret_conv;
23769 }
23770
23771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23772         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
23773         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23774         *ret_copy = COption_NetAddressZ_clone(orig_conv);
23775         int64_t ret_ref = tag_ptr(ret_copy, true);
23776         return ret_ref;
23777 }
23778
23779 static inline uint64_t C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR arg) {
23780         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23781         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(arg);
23782         return tag_ptr(ret_conv, true);
23783 }
23784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23785         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(arg);
23786         int64_t ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(arg_conv);
23787         return ret_conv;
23788 }
23789
23790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23791         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(orig);
23792         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23793         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig_conv);
23794         return tag_ptr(ret_conv, true);
23795 }
23796
23797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23798         LDKPublicKey a_ref;
23799         CHECK((*env)->GetArrayLength(env, a) == 33);
23800         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23801         void* b_ptr = untag_ptr(b);
23802         CHECK_ACCESS(b_ptr);
23803         LDKCOption_NetAddressZ b_conv = *(LDKCOption_NetAddressZ*)(b_ptr);
23804         b_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(b));
23805         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23806         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_new(a_ref, b_conv);
23807         return tag_ptr(ret_conv, true);
23808 }
23809
23810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23811         if (!ptr_is_owned(_res)) return;
23812         void* _res_ptr = untag_ptr(_res);
23813         CHECK_ACCESS(_res_ptr);
23814         LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_ptr);
23815         FREE(untag_ptr(_res));
23816         C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res_conv);
23817 }
23818
23819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyCOption_1NetAddressZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23820         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res_constr;
23821         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23822         if (_res_constr.datalen > 0)
23823                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ Elements");
23824         else
23825                 _res_constr.data = NULL;
23826         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23827         for (size_t o = 0; o < _res_constr.datalen; o++) {
23828                 int64_t _res_conv_40 = _res_vals[o];
23829                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23830                 CHECK_ACCESS(_res_conv_40_ptr);
23831                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv_40_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_conv_40_ptr);
23832                 FREE(untag_ptr(_res_conv_40));
23833                 _res_constr.data[o] = _res_conv_40_conv;
23834         }
23835         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23836         CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res_constr);
23837 }
23838
23839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
23840         LDKCVec_u8Z o_ref;
23841         o_ref.datalen = (*env)->GetArrayLength(env, o);
23842         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23843         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
23844         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23845         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23846         return tag_ptr(ret_conv, true);
23847 }
23848
23849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23850         LDKPeerHandleError e_conv;
23851         e_conv.inner = untag_ptr(e);
23852         e_conv.is_owned = ptr_is_owned(e);
23853         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23854         e_conv = PeerHandleError_clone(&e_conv);
23855         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23856         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23857         return tag_ptr(ret_conv, true);
23858 }
23859
23860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23861         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23862         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23863         return ret_conv;
23864 }
23865
23866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23867         if (!ptr_is_owned(_res)) return;
23868         void* _res_ptr = untag_ptr(_res);
23869         CHECK_ACCESS(_res_ptr);
23870         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23871         FREE(untag_ptr(_res));
23872         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23873 }
23874
23875 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23876         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23877         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23878         return tag_ptr(ret_conv, true);
23879 }
23880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23881         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23882         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23883         return ret_conv;
23884 }
23885
23886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23887         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23888         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23889         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23890         return tag_ptr(ret_conv, true);
23891 }
23892
23893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23894         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23895         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23896         return tag_ptr(ret_conv, true);
23897 }
23898
23899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23900         LDKPeerHandleError e_conv;
23901         e_conv.inner = untag_ptr(e);
23902         e_conv.is_owned = ptr_is_owned(e);
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23904         e_conv = PeerHandleError_clone(&e_conv);
23905         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23906         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23907         return tag_ptr(ret_conv, true);
23908 }
23909
23910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23911         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23912         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23913         return ret_conv;
23914 }
23915
23916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23917         if (!ptr_is_owned(_res)) return;
23918         void* _res_ptr = untag_ptr(_res);
23919         CHECK_ACCESS(_res_ptr);
23920         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23921         FREE(untag_ptr(_res));
23922         CResult_NonePeerHandleErrorZ_free(_res_conv);
23923 }
23924
23925 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23926         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23927         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23928         return tag_ptr(ret_conv, true);
23929 }
23930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23931         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23932         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23933         return ret_conv;
23934 }
23935
23936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23937         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23938         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23939         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23940         return tag_ptr(ret_conv, true);
23941 }
23942
23943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23944         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23945         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23946         return tag_ptr(ret_conv, true);
23947 }
23948
23949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23950         LDKPeerHandleError e_conv;
23951         e_conv.inner = untag_ptr(e);
23952         e_conv.is_owned = ptr_is_owned(e);
23953         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23954         e_conv = PeerHandleError_clone(&e_conv);
23955         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23956         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23957         return tag_ptr(ret_conv, true);
23958 }
23959
23960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23961         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23962         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23963         return ret_conv;
23964 }
23965
23966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23967         if (!ptr_is_owned(_res)) return;
23968         void* _res_ptr = untag_ptr(_res);
23969         CHECK_ACCESS(_res_ptr);
23970         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23971         FREE(untag_ptr(_res));
23972         CResult_boolPeerHandleErrorZ_free(_res_conv);
23973 }
23974
23975 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23976         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23977         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23978         return tag_ptr(ret_conv, true);
23979 }
23980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23981         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23982         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23983         return ret_conv;
23984 }
23985
23986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23987         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23988         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23989         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23990         return tag_ptr(ret_conv, true);
23991 }
23992
23993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23994         void* o_ptr = untag_ptr(o);
23995         CHECK_ACCESS(o_ptr);
23996         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
23997         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
23998         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23999         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
24000         return tag_ptr(ret_conv, true);
24001 }
24002
24003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24004         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_java(env, e);
24005         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24006         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
24007         return tag_ptr(ret_conv, true);
24008 }
24009
24010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24011         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
24012         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
24013         return ret_conv;
24014 }
24015
24016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24017         if (!ptr_is_owned(_res)) return;
24018         void* _res_ptr = untag_ptr(_res);
24019         CHECK_ACCESS(_res_ptr);
24020         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
24021         FREE(untag_ptr(_res));
24022         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
24023 }
24024
24025 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
24026         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24027         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
24028         return tag_ptr(ret_conv, true);
24029 }
24030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24031         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
24032         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
24033         return ret_conv;
24034 }
24035
24036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24037         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
24038         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24039         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
24040         return tag_ptr(ret_conv, true);
24041 }
24042
24043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
24044         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24045         *ret_conv = CResult_NoneSendErrorZ_ok();
24046         return tag_ptr(ret_conv, true);
24047 }
24048
24049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24050         void* e_ptr = untag_ptr(e);
24051         CHECK_ACCESS(e_ptr);
24052         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
24053         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
24054         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24055         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
24056         return tag_ptr(ret_conv, true);
24057 }
24058
24059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24060         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
24061         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
24062         return ret_conv;
24063 }
24064
24065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24066         if (!ptr_is_owned(_res)) return;
24067         void* _res_ptr = untag_ptr(_res);
24068         CHECK_ACCESS(_res_ptr);
24069         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
24070         FREE(untag_ptr(_res));
24071         CResult_NoneSendErrorZ_free(_res_conv);
24072 }
24073
24074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24075         LDKBlindedPath o_conv;
24076         o_conv.inner = untag_ptr(o);
24077         o_conv.is_owned = ptr_is_owned(o);
24078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24079         o_conv = BlindedPath_clone(&o_conv);
24080         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24081         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
24082         return tag_ptr(ret_conv, true);
24083 }
24084
24085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
24086         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24087         *ret_conv = CResult_BlindedPathNoneZ_err();
24088         return tag_ptr(ret_conv, true);
24089 }
24090
24091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24092         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
24093         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
24094         return ret_conv;
24095 }
24096
24097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24098         if (!ptr_is_owned(_res)) return;
24099         void* _res_ptr = untag_ptr(_res);
24100         CHECK_ACCESS(_res_ptr);
24101         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
24102         FREE(untag_ptr(_res));
24103         CResult_BlindedPathNoneZ_free(_res_conv);
24104 }
24105
24106 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
24107         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24108         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
24109         return tag_ptr(ret_conv, true);
24110 }
24111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24112         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
24113         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
24114         return ret_conv;
24115 }
24116
24117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24118         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
24119         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24120         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
24121         return tag_ptr(ret_conv, true);
24122 }
24123
24124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24125         LDKBlindedPath o_conv;
24126         o_conv.inner = untag_ptr(o);
24127         o_conv.is_owned = ptr_is_owned(o);
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24129         o_conv = BlindedPath_clone(&o_conv);
24130         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24131         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
24132         return tag_ptr(ret_conv, true);
24133 }
24134
24135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24136         void* e_ptr = untag_ptr(e);
24137         CHECK_ACCESS(e_ptr);
24138         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24139         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24140         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24141         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
24142         return tag_ptr(ret_conv, true);
24143 }
24144
24145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24146         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
24147         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
24148         return ret_conv;
24149 }
24150
24151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24152         if (!ptr_is_owned(_res)) return;
24153         void* _res_ptr = untag_ptr(_res);
24154         CHECK_ACCESS(_res_ptr);
24155         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
24156         FREE(untag_ptr(_res));
24157         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
24158 }
24159
24160 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
24161         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24162         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
24163         return tag_ptr(ret_conv, true);
24164 }
24165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24166         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
24167         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
24168         return ret_conv;
24169 }
24170
24171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24172         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
24173         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24174         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
24175         return tag_ptr(ret_conv, true);
24176 }
24177
24178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24179         LDKBlindedHop o_conv;
24180         o_conv.inner = untag_ptr(o);
24181         o_conv.is_owned = ptr_is_owned(o);
24182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24183         o_conv = BlindedHop_clone(&o_conv);
24184         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24185         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
24186         return tag_ptr(ret_conv, true);
24187 }
24188
24189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24190         void* e_ptr = untag_ptr(e);
24191         CHECK_ACCESS(e_ptr);
24192         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24193         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24194         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24195         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
24196         return tag_ptr(ret_conv, true);
24197 }
24198
24199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24200         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
24201         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
24202         return ret_conv;
24203 }
24204
24205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24206         if (!ptr_is_owned(_res)) return;
24207         void* _res_ptr = untag_ptr(_res);
24208         CHECK_ACCESS(_res_ptr);
24209         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
24210         FREE(untag_ptr(_res));
24211         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
24212 }
24213
24214 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
24215         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24216         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
24217         return tag_ptr(ret_conv, true);
24218 }
24219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24220         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
24221         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
24222         return ret_conv;
24223 }
24224
24225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24226         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
24227         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24228         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
24229         return tag_ptr(ret_conv, true);
24230 }
24231
24232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
24233         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
24234         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24235         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
24236         return tag_ptr(ret_conv, true);
24237 }
24238
24239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24240         void* e_ptr = untag_ptr(e);
24241         CHECK_ACCESS(e_ptr);
24242         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24243         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24244         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24245         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
24246         return tag_ptr(ret_conv, true);
24247 }
24248
24249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24250         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
24251         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
24252         return ret_conv;
24253 }
24254
24255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24256         if (!ptr_is_owned(_res)) return;
24257         void* _res_ptr = untag_ptr(_res);
24258         CHECK_ACCESS(_res_ptr);
24259         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
24260         FREE(untag_ptr(_res));
24261         CResult_SiPrefixParseErrorZ_free(_res_conv);
24262 }
24263
24264 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
24265         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24266         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
24267         return tag_ptr(ret_conv, true);
24268 }
24269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24270         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
24271         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
24272         return ret_conv;
24273 }
24274
24275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24276         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
24277         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24278         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
24279         return tag_ptr(ret_conv, true);
24280 }
24281
24282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24283         LDKInvoice o_conv;
24284         o_conv.inner = untag_ptr(o);
24285         o_conv.is_owned = ptr_is_owned(o);
24286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24287         o_conv = Invoice_clone(&o_conv);
24288         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24289         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
24290         return tag_ptr(ret_conv, true);
24291 }
24292
24293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24294         void* e_ptr = untag_ptr(e);
24295         CHECK_ACCESS(e_ptr);
24296         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
24297         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
24298         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24299         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
24300         return tag_ptr(ret_conv, true);
24301 }
24302
24303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24304         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
24305         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
24306         return ret_conv;
24307 }
24308
24309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24310         if (!ptr_is_owned(_res)) return;
24311         void* _res_ptr = untag_ptr(_res);
24312         CHECK_ACCESS(_res_ptr);
24313         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
24314         FREE(untag_ptr(_res));
24315         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
24316 }
24317
24318 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
24319         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24320         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
24321         return tag_ptr(ret_conv, true);
24322 }
24323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24324         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
24325         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
24326         return ret_conv;
24327 }
24328
24329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24330         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
24331         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24332         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
24333         return tag_ptr(ret_conv, true);
24334 }
24335
24336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24337         LDKSignedRawInvoice o_conv;
24338         o_conv.inner = untag_ptr(o);
24339         o_conv.is_owned = ptr_is_owned(o);
24340         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24341         o_conv = SignedRawInvoice_clone(&o_conv);
24342         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24343         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
24344         return tag_ptr(ret_conv, true);
24345 }
24346
24347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24348         void* e_ptr = untag_ptr(e);
24349         CHECK_ACCESS(e_ptr);
24350         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24351         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24352         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24353         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
24354         return tag_ptr(ret_conv, true);
24355 }
24356
24357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24358         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
24359         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
24360         return ret_conv;
24361 }
24362
24363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24364         if (!ptr_is_owned(_res)) return;
24365         void* _res_ptr = untag_ptr(_res);
24366         CHECK_ACCESS(_res_ptr);
24367         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
24368         FREE(untag_ptr(_res));
24369         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
24370 }
24371
24372 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
24373         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24374         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
24375         return tag_ptr(ret_conv, true);
24376 }
24377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24378         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
24379         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
24380         return ret_conv;
24381 }
24382
24383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24384         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
24385         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24386         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
24387         return tag_ptr(ret_conv, true);
24388 }
24389
24390 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
24391         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24392         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
24393         return tag_ptr(ret_conv, true);
24394 }
24395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24396         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
24397         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
24398         return ret_conv;
24399 }
24400
24401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24402         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
24403         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24404         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
24405         return tag_ptr(ret_conv, true);
24406 }
24407
24408 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) {
24409         LDKRawInvoice a_conv;
24410         a_conv.inner = untag_ptr(a);
24411         a_conv.is_owned = ptr_is_owned(a);
24412         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24413         a_conv = RawInvoice_clone(&a_conv);
24414         LDKThirtyTwoBytes b_ref;
24415         CHECK((*env)->GetArrayLength(env, b) == 32);
24416         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
24417         LDKInvoiceSignature c_conv;
24418         c_conv.inner = untag_ptr(c);
24419         c_conv.is_owned = ptr_is_owned(c);
24420         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
24421         c_conv = InvoiceSignature_clone(&c_conv);
24422         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24423         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
24424         return tag_ptr(ret_conv, true);
24425 }
24426
24427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24428         if (!ptr_is_owned(_res)) return;
24429         void* _res_ptr = untag_ptr(_res);
24430         CHECK_ACCESS(_res_ptr);
24431         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
24432         FREE(untag_ptr(_res));
24433         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
24434 }
24435
24436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24437         LDKPayeePubKey o_conv;
24438         o_conv.inner = untag_ptr(o);
24439         o_conv.is_owned = ptr_is_owned(o);
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24441         o_conv = PayeePubKey_clone(&o_conv);
24442         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24443         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
24444         return tag_ptr(ret_conv, true);
24445 }
24446
24447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24448         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
24449         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24450         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
24451         return tag_ptr(ret_conv, true);
24452 }
24453
24454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24455         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
24456         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
24457         return ret_conv;
24458 }
24459
24460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24461         if (!ptr_is_owned(_res)) return;
24462         void* _res_ptr = untag_ptr(_res);
24463         CHECK_ACCESS(_res_ptr);
24464         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
24465         FREE(untag_ptr(_res));
24466         CResult_PayeePubKeyErrorZ_free(_res_conv);
24467 }
24468
24469 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
24470         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24471         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
24472         return tag_ptr(ret_conv, true);
24473 }
24474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24475         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
24476         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
24477         return ret_conv;
24478 }
24479
24480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24481         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
24482         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24483         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
24484         return tag_ptr(ret_conv, true);
24485 }
24486
24487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24488         LDKCVec_PrivateRouteZ _res_constr;
24489         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24490         if (_res_constr.datalen > 0)
24491                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
24492         else
24493                 _res_constr.data = NULL;
24494         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24495         for (size_t o = 0; o < _res_constr.datalen; o++) {
24496                 int64_t _res_conv_14 = _res_vals[o];
24497                 LDKPrivateRoute _res_conv_14_conv;
24498                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
24499                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
24500                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
24501                 _res_constr.data[o] = _res_conv_14_conv;
24502         }
24503         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24504         CVec_PrivateRouteZ_free(_res_constr);
24505 }
24506
24507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24508         LDKPositiveTimestamp o_conv;
24509         o_conv.inner = untag_ptr(o);
24510         o_conv.is_owned = ptr_is_owned(o);
24511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24512         o_conv = PositiveTimestamp_clone(&o_conv);
24513         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24514         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
24515         return tag_ptr(ret_conv, true);
24516 }
24517
24518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24519         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24520         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24521         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
24522         return tag_ptr(ret_conv, true);
24523 }
24524
24525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24526         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
24527         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
24528         return ret_conv;
24529 }
24530
24531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24532         if (!ptr_is_owned(_res)) return;
24533         void* _res_ptr = untag_ptr(_res);
24534         CHECK_ACCESS(_res_ptr);
24535         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
24536         FREE(untag_ptr(_res));
24537         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
24538 }
24539
24540 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
24541         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24542         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
24543         return tag_ptr(ret_conv, true);
24544 }
24545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24546         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
24547         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
24548         return ret_conv;
24549 }
24550
24551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24552         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
24553         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24554         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
24555         return tag_ptr(ret_conv, true);
24556 }
24557
24558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
24559         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24560         *ret_conv = CResult_NoneSemanticErrorZ_ok();
24561         return tag_ptr(ret_conv, true);
24562 }
24563
24564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24565         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24566         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24567         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
24568         return tag_ptr(ret_conv, true);
24569 }
24570
24571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24572         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
24573         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
24574         return ret_conv;
24575 }
24576
24577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24578         if (!ptr_is_owned(_res)) return;
24579         void* _res_ptr = untag_ptr(_res);
24580         CHECK_ACCESS(_res_ptr);
24581         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
24582         FREE(untag_ptr(_res));
24583         CResult_NoneSemanticErrorZ_free(_res_conv);
24584 }
24585
24586 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
24587         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24588         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
24589         return tag_ptr(ret_conv, true);
24590 }
24591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24592         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
24593         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
24594         return ret_conv;
24595 }
24596
24597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24598         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
24599         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24600         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
24601         return tag_ptr(ret_conv, true);
24602 }
24603
24604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24605         LDKInvoice o_conv;
24606         o_conv.inner = untag_ptr(o);
24607         o_conv.is_owned = ptr_is_owned(o);
24608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24609         o_conv = Invoice_clone(&o_conv);
24610         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24611         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
24612         return tag_ptr(ret_conv, true);
24613 }
24614
24615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24616         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24617         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24618         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
24619         return tag_ptr(ret_conv, true);
24620 }
24621
24622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24623         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
24624         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
24625         return ret_conv;
24626 }
24627
24628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24629         if (!ptr_is_owned(_res)) return;
24630         void* _res_ptr = untag_ptr(_res);
24631         CHECK_ACCESS(_res_ptr);
24632         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
24633         FREE(untag_ptr(_res));
24634         CResult_InvoiceSemanticErrorZ_free(_res_conv);
24635 }
24636
24637 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
24638         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24639         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
24640         return tag_ptr(ret_conv, true);
24641 }
24642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24643         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
24644         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
24645         return ret_conv;
24646 }
24647
24648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24649         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
24650         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24651         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
24652         return tag_ptr(ret_conv, true);
24653 }
24654
24655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1AddressZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
24656         LDKCVec_AddressZ _res_constr;
24657         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24658         if (_res_constr.datalen > 0)
24659                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_AddressZ Elements");
24660         else
24661                 _res_constr.data = NULL;
24662         for (size_t i = 0; i < _res_constr.datalen; i++) {
24663                 jstring _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
24664                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
24665                 _res_constr.data[i] = dummy;
24666         }
24667         CVec_AddressZ_free(_res_constr);
24668 }
24669
24670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24671         LDKDescription o_conv;
24672         o_conv.inner = untag_ptr(o);
24673         o_conv.is_owned = ptr_is_owned(o);
24674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24675         o_conv = Description_clone(&o_conv);
24676         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24677         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
24678         return tag_ptr(ret_conv, true);
24679 }
24680
24681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24682         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24683         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24684         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
24685         return tag_ptr(ret_conv, true);
24686 }
24687
24688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24689         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
24690         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
24691         return ret_conv;
24692 }
24693
24694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24695         if (!ptr_is_owned(_res)) return;
24696         void* _res_ptr = untag_ptr(_res);
24697         CHECK_ACCESS(_res_ptr);
24698         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
24699         FREE(untag_ptr(_res));
24700         CResult_DescriptionCreationErrorZ_free(_res_conv);
24701 }
24702
24703 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
24704         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24705         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
24706         return tag_ptr(ret_conv, true);
24707 }
24708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24709         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
24710         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
24711         return ret_conv;
24712 }
24713
24714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24715         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
24716         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24717         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
24718         return tag_ptr(ret_conv, true);
24719 }
24720
24721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24722         LDKPrivateRoute o_conv;
24723         o_conv.inner = untag_ptr(o);
24724         o_conv.is_owned = ptr_is_owned(o);
24725         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24726         o_conv = PrivateRoute_clone(&o_conv);
24727         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24728         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
24729         return tag_ptr(ret_conv, true);
24730 }
24731
24732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24733         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24734         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24735         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
24736         return tag_ptr(ret_conv, true);
24737 }
24738
24739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24740         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
24741         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
24742         return ret_conv;
24743 }
24744
24745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24746         if (!ptr_is_owned(_res)) return;
24747         void* _res_ptr = untag_ptr(_res);
24748         CHECK_ACCESS(_res_ptr);
24749         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
24750         FREE(untag_ptr(_res));
24751         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
24752 }
24753
24754 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
24755         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24756         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
24757         return tag_ptr(ret_conv, true);
24758 }
24759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24760         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
24761         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
24762         return ret_conv;
24763 }
24764
24765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24766         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
24767         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24768         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
24769         return tag_ptr(ret_conv, true);
24770 }
24771
24772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24773         void* o_ptr = untag_ptr(o);
24774         CHECK_ACCESS(o_ptr);
24775         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
24776         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
24777         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24778         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
24779         return tag_ptr(ret_conv, true);
24780 }
24781
24782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24783         void* e_ptr = untag_ptr(e);
24784         CHECK_ACCESS(e_ptr);
24785         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24786         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24787         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24788         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
24789         return tag_ptr(ret_conv, true);
24790 }
24791
24792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24793         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
24794         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
24795         return ret_conv;
24796 }
24797
24798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24799         if (!ptr_is_owned(_res)) return;
24800         void* _res_ptr = untag_ptr(_res);
24801         CHECK_ACCESS(_res_ptr);
24802         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
24803         FREE(untag_ptr(_res));
24804         CResult_NetAddressDecodeErrorZ_free(_res_conv);
24805 }
24806
24807 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
24808         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24809         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
24810         return tag_ptr(ret_conv, true);
24811 }
24812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24813         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
24814         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
24815         return ret_conv;
24816 }
24817
24818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24819         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
24820         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24821         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
24822         return tag_ptr(ret_conv, true);
24823 }
24824
24825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24826         LDKCVec_UpdateAddHTLCZ _res_constr;
24827         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24828         if (_res_constr.datalen > 0)
24829                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24830         else
24831                 _res_constr.data = NULL;
24832         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24833         for (size_t p = 0; p < _res_constr.datalen; p++) {
24834                 int64_t _res_conv_15 = _res_vals[p];
24835                 LDKUpdateAddHTLC _res_conv_15_conv;
24836                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
24837                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
24838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
24839                 _res_constr.data[p] = _res_conv_15_conv;
24840         }
24841         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24842         CVec_UpdateAddHTLCZ_free(_res_constr);
24843 }
24844
24845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24846         LDKCVec_UpdateFulfillHTLCZ _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(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24850         else
24851                 _res_constr.data = NULL;
24852         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24853         for (size_t t = 0; t < _res_constr.datalen; t++) {
24854                 int64_t _res_conv_19 = _res_vals[t];
24855                 LDKUpdateFulfillHTLC _res_conv_19_conv;
24856                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24857                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24858                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24859                 _res_constr.data[t] = _res_conv_19_conv;
24860         }
24861         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24862         CVec_UpdateFulfillHTLCZ_free(_res_constr);
24863 }
24864
24865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24866         LDKCVec_UpdateFailHTLCZ _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(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24870         else
24871                 _res_constr.data = NULL;
24872         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24873         for (size_t q = 0; q < _res_constr.datalen; q++) {
24874                 int64_t _res_conv_16 = _res_vals[q];
24875                 LDKUpdateFailHTLC _res_conv_16_conv;
24876                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
24877                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
24878                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
24879                 _res_constr.data[q] = _res_conv_16_conv;
24880         }
24881         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24882         CVec_UpdateFailHTLCZ_free(_res_constr);
24883 }
24884
24885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24886         LDKCVec_UpdateFailMalformedHTLCZ _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(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24890         else
24891                 _res_constr.data = NULL;
24892         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24893         for (size_t z = 0; z < _res_constr.datalen; z++) {
24894                 int64_t _res_conv_25 = _res_vals[z];
24895                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
24896                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
24897                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
24898                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
24899                 _res_constr.data[z] = _res_conv_25_conv;
24900         }
24901         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24902         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
24903 }
24904
24905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24906         LDKAcceptChannel o_conv;
24907         o_conv.inner = untag_ptr(o);
24908         o_conv.is_owned = ptr_is_owned(o);
24909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24910         o_conv = AcceptChannel_clone(&o_conv);
24911         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24912         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
24913         return tag_ptr(ret_conv, true);
24914 }
24915
24916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24917         void* e_ptr = untag_ptr(e);
24918         CHECK_ACCESS(e_ptr);
24919         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24920         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24921         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24922         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
24923         return tag_ptr(ret_conv, true);
24924 }
24925
24926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24927         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
24928         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
24929         return ret_conv;
24930 }
24931
24932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24933         if (!ptr_is_owned(_res)) return;
24934         void* _res_ptr = untag_ptr(_res);
24935         CHECK_ACCESS(_res_ptr);
24936         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
24937         FREE(untag_ptr(_res));
24938         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
24939 }
24940
24941 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
24942         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24943         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
24944         return tag_ptr(ret_conv, true);
24945 }
24946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24947         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
24948         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
24949         return ret_conv;
24950 }
24951
24952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24953         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
24954         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24955         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
24956         return tag_ptr(ret_conv, true);
24957 }
24958
24959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24960         LDKAnnouncementSignatures o_conv;
24961         o_conv.inner = untag_ptr(o);
24962         o_conv.is_owned = ptr_is_owned(o);
24963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24964         o_conv = AnnouncementSignatures_clone(&o_conv);
24965         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24966         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24967         return tag_ptr(ret_conv, true);
24968 }
24969
24970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24971         void* e_ptr = untag_ptr(e);
24972         CHECK_ACCESS(e_ptr);
24973         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24974         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24975         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24976         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24977         return tag_ptr(ret_conv, true);
24978 }
24979
24980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24981         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
24982         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
24983         return ret_conv;
24984 }
24985
24986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24987         if (!ptr_is_owned(_res)) return;
24988         void* _res_ptr = untag_ptr(_res);
24989         CHECK_ACCESS(_res_ptr);
24990         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
24991         FREE(untag_ptr(_res));
24992         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
24993 }
24994
24995 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24996         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24997         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
24998         return tag_ptr(ret_conv, true);
24999 }
25000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25001         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
25002         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
25003         return ret_conv;
25004 }
25005
25006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25007         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
25008         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25009         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
25010         return tag_ptr(ret_conv, true);
25011 }
25012
25013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25014         LDKChannelReestablish o_conv;
25015         o_conv.inner = untag_ptr(o);
25016         o_conv.is_owned = ptr_is_owned(o);
25017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25018         o_conv = ChannelReestablish_clone(&o_conv);
25019         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25020         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
25021         return tag_ptr(ret_conv, true);
25022 }
25023
25024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25025         void* e_ptr = untag_ptr(e);
25026         CHECK_ACCESS(e_ptr);
25027         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25028         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25029         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25030         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
25031         return tag_ptr(ret_conv, true);
25032 }
25033
25034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25035         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
25036         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
25037         return ret_conv;
25038 }
25039
25040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25041         if (!ptr_is_owned(_res)) return;
25042         void* _res_ptr = untag_ptr(_res);
25043         CHECK_ACCESS(_res_ptr);
25044         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
25045         FREE(untag_ptr(_res));
25046         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
25047 }
25048
25049 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
25050         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25051         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
25052         return tag_ptr(ret_conv, true);
25053 }
25054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25055         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
25056         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
25057         return ret_conv;
25058 }
25059
25060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25061         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
25062         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25063         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
25064         return tag_ptr(ret_conv, true);
25065 }
25066
25067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25068         LDKClosingSigned o_conv;
25069         o_conv.inner = untag_ptr(o);
25070         o_conv.is_owned = ptr_is_owned(o);
25071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25072         o_conv = ClosingSigned_clone(&o_conv);
25073         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25074         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
25075         return tag_ptr(ret_conv, true);
25076 }
25077
25078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25079         void* e_ptr = untag_ptr(e);
25080         CHECK_ACCESS(e_ptr);
25081         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25082         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25083         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25084         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
25085         return tag_ptr(ret_conv, true);
25086 }
25087
25088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25089         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
25090         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
25091         return ret_conv;
25092 }
25093
25094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25095         if (!ptr_is_owned(_res)) return;
25096         void* _res_ptr = untag_ptr(_res);
25097         CHECK_ACCESS(_res_ptr);
25098         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
25099         FREE(untag_ptr(_res));
25100         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
25101 }
25102
25103 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
25104         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25105         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
25106         return tag_ptr(ret_conv, true);
25107 }
25108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25109         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
25110         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
25111         return ret_conv;
25112 }
25113
25114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25115         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
25116         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25117         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
25118         return tag_ptr(ret_conv, true);
25119 }
25120
25121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25122         LDKClosingSignedFeeRange o_conv;
25123         o_conv.inner = untag_ptr(o);
25124         o_conv.is_owned = ptr_is_owned(o);
25125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25126         o_conv = ClosingSignedFeeRange_clone(&o_conv);
25127         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25128         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
25129         return tag_ptr(ret_conv, true);
25130 }
25131
25132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25133         void* e_ptr = untag_ptr(e);
25134         CHECK_ACCESS(e_ptr);
25135         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25136         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25137         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25138         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
25139         return tag_ptr(ret_conv, true);
25140 }
25141
25142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25143         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
25144         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
25145         return ret_conv;
25146 }
25147
25148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25149         if (!ptr_is_owned(_res)) return;
25150         void* _res_ptr = untag_ptr(_res);
25151         CHECK_ACCESS(_res_ptr);
25152         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
25153         FREE(untag_ptr(_res));
25154         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
25155 }
25156
25157 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
25158         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25159         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
25160         return tag_ptr(ret_conv, true);
25161 }
25162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25163         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
25164         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
25165         return ret_conv;
25166 }
25167
25168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25169         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
25170         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25171         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
25172         return tag_ptr(ret_conv, true);
25173 }
25174
25175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25176         LDKCommitmentSigned o_conv;
25177         o_conv.inner = untag_ptr(o);
25178         o_conv.is_owned = ptr_is_owned(o);
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25180         o_conv = CommitmentSigned_clone(&o_conv);
25181         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25182         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
25183         return tag_ptr(ret_conv, true);
25184 }
25185
25186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25187         void* e_ptr = untag_ptr(e);
25188         CHECK_ACCESS(e_ptr);
25189         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25190         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25191         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25192         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
25193         return tag_ptr(ret_conv, true);
25194 }
25195
25196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25197         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
25198         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
25199         return ret_conv;
25200 }
25201
25202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25203         if (!ptr_is_owned(_res)) return;
25204         void* _res_ptr = untag_ptr(_res);
25205         CHECK_ACCESS(_res_ptr);
25206         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
25207         FREE(untag_ptr(_res));
25208         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
25209 }
25210
25211 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
25212         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25213         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
25214         return tag_ptr(ret_conv, true);
25215 }
25216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25217         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
25218         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
25219         return ret_conv;
25220 }
25221
25222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25223         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
25224         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25225         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
25226         return tag_ptr(ret_conv, true);
25227 }
25228
25229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25230         LDKFundingCreated o_conv;
25231         o_conv.inner = untag_ptr(o);
25232         o_conv.is_owned = ptr_is_owned(o);
25233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25234         o_conv = FundingCreated_clone(&o_conv);
25235         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25236         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
25237         return tag_ptr(ret_conv, true);
25238 }
25239
25240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25241         void* e_ptr = untag_ptr(e);
25242         CHECK_ACCESS(e_ptr);
25243         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25244         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25245         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25246         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
25247         return tag_ptr(ret_conv, true);
25248 }
25249
25250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25251         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
25252         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
25253         return ret_conv;
25254 }
25255
25256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25257         if (!ptr_is_owned(_res)) return;
25258         void* _res_ptr = untag_ptr(_res);
25259         CHECK_ACCESS(_res_ptr);
25260         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
25261         FREE(untag_ptr(_res));
25262         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
25263 }
25264
25265 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
25266         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25267         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
25268         return tag_ptr(ret_conv, true);
25269 }
25270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25271         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
25272         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
25273         return ret_conv;
25274 }
25275
25276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25277         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
25278         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25279         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
25280         return tag_ptr(ret_conv, true);
25281 }
25282
25283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25284         LDKFundingSigned o_conv;
25285         o_conv.inner = untag_ptr(o);
25286         o_conv.is_owned = ptr_is_owned(o);
25287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25288         o_conv = FundingSigned_clone(&o_conv);
25289         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25290         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
25291         return tag_ptr(ret_conv, true);
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25295         void* e_ptr = untag_ptr(e);
25296         CHECK_ACCESS(e_ptr);
25297         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25298         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25299         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25300         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
25301         return tag_ptr(ret_conv, true);
25302 }
25303
25304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25305         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
25306         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
25307         return ret_conv;
25308 }
25309
25310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25311         if (!ptr_is_owned(_res)) return;
25312         void* _res_ptr = untag_ptr(_res);
25313         CHECK_ACCESS(_res_ptr);
25314         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
25315         FREE(untag_ptr(_res));
25316         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
25317 }
25318
25319 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
25320         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25321         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
25322         return tag_ptr(ret_conv, true);
25323 }
25324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25325         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
25326         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
25327         return ret_conv;
25328 }
25329
25330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25331         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
25332         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25333         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
25334         return tag_ptr(ret_conv, true);
25335 }
25336
25337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25338         LDKChannelReady o_conv;
25339         o_conv.inner = untag_ptr(o);
25340         o_conv.is_owned = ptr_is_owned(o);
25341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25342         o_conv = ChannelReady_clone(&o_conv);
25343         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25344         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
25345         return tag_ptr(ret_conv, true);
25346 }
25347
25348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25349         void* e_ptr = untag_ptr(e);
25350         CHECK_ACCESS(e_ptr);
25351         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25352         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25353         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25354         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
25355         return tag_ptr(ret_conv, true);
25356 }
25357
25358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25359         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
25360         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
25361         return ret_conv;
25362 }
25363
25364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25365         if (!ptr_is_owned(_res)) return;
25366         void* _res_ptr = untag_ptr(_res);
25367         CHECK_ACCESS(_res_ptr);
25368         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
25369         FREE(untag_ptr(_res));
25370         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
25371 }
25372
25373 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
25374         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25375         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
25376         return tag_ptr(ret_conv, true);
25377 }
25378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25379         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
25380         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
25381         return ret_conv;
25382 }
25383
25384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25385         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
25386         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25387         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
25388         return tag_ptr(ret_conv, true);
25389 }
25390
25391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25392         LDKInit o_conv;
25393         o_conv.inner = untag_ptr(o);
25394         o_conv.is_owned = ptr_is_owned(o);
25395         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25396         o_conv = Init_clone(&o_conv);
25397         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25398         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
25399         return tag_ptr(ret_conv, true);
25400 }
25401
25402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25403         void* e_ptr = untag_ptr(e);
25404         CHECK_ACCESS(e_ptr);
25405         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25406         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25407         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25408         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
25409         return tag_ptr(ret_conv, true);
25410 }
25411
25412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25413         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
25414         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
25415         return ret_conv;
25416 }
25417
25418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25419         if (!ptr_is_owned(_res)) return;
25420         void* _res_ptr = untag_ptr(_res);
25421         CHECK_ACCESS(_res_ptr);
25422         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
25423         FREE(untag_ptr(_res));
25424         CResult_InitDecodeErrorZ_free(_res_conv);
25425 }
25426
25427 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
25428         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25429         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
25430         return tag_ptr(ret_conv, true);
25431 }
25432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25433         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
25434         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
25435         return ret_conv;
25436 }
25437
25438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25439         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
25440         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25441         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
25442         return tag_ptr(ret_conv, true);
25443 }
25444
25445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25446         LDKOpenChannel o_conv;
25447         o_conv.inner = untag_ptr(o);
25448         o_conv.is_owned = ptr_is_owned(o);
25449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25450         o_conv = OpenChannel_clone(&o_conv);
25451         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25452         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
25453         return tag_ptr(ret_conv, true);
25454 }
25455
25456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25457         void* e_ptr = untag_ptr(e);
25458         CHECK_ACCESS(e_ptr);
25459         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25460         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25461         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25462         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
25463         return tag_ptr(ret_conv, true);
25464 }
25465
25466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25467         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25468         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25469         return ret_conv;
25470 }
25471
25472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25473         if (!ptr_is_owned(_res)) return;
25474         void* _res_ptr = untag_ptr(_res);
25475         CHECK_ACCESS(_res_ptr);
25476         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25477         FREE(untag_ptr(_res));
25478         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25479 }
25480
25481 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25482         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25483         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25484         return tag_ptr(ret_conv, true);
25485 }
25486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25487         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25488         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25489         return ret_conv;
25490 }
25491
25492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25493         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25494         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25495         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25496         return tag_ptr(ret_conv, true);
25497 }
25498
25499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25500         LDKRevokeAndACK o_conv;
25501         o_conv.inner = untag_ptr(o);
25502         o_conv.is_owned = ptr_is_owned(o);
25503         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25504         o_conv = RevokeAndACK_clone(&o_conv);
25505         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25506         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25507         return tag_ptr(ret_conv, true);
25508 }
25509
25510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25511         void* e_ptr = untag_ptr(e);
25512         CHECK_ACCESS(e_ptr);
25513         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25514         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25515         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25516         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25517         return tag_ptr(ret_conv, true);
25518 }
25519
25520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25521         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25522         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25523         return ret_conv;
25524 }
25525
25526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25527         if (!ptr_is_owned(_res)) return;
25528         void* _res_ptr = untag_ptr(_res);
25529         CHECK_ACCESS(_res_ptr);
25530         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25531         FREE(untag_ptr(_res));
25532         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25533 }
25534
25535 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25536         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25537         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25538         return tag_ptr(ret_conv, true);
25539 }
25540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25541         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25542         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25543         return ret_conv;
25544 }
25545
25546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25547         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25548         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25549         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25550         return tag_ptr(ret_conv, true);
25551 }
25552
25553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25554         LDKShutdown o_conv;
25555         o_conv.inner = untag_ptr(o);
25556         o_conv.is_owned = ptr_is_owned(o);
25557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25558         o_conv = Shutdown_clone(&o_conv);
25559         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25560         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25561         return tag_ptr(ret_conv, true);
25562 }
25563
25564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25565         void* e_ptr = untag_ptr(e);
25566         CHECK_ACCESS(e_ptr);
25567         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25568         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25569         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25570         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25571         return tag_ptr(ret_conv, true);
25572 }
25573
25574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25575         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25576         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25577         return ret_conv;
25578 }
25579
25580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25581         if (!ptr_is_owned(_res)) return;
25582         void* _res_ptr = untag_ptr(_res);
25583         CHECK_ACCESS(_res_ptr);
25584         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25585         FREE(untag_ptr(_res));
25586         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25587 }
25588
25589 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25590         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25591         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25592         return tag_ptr(ret_conv, true);
25593 }
25594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25595         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25596         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25597         return ret_conv;
25598 }
25599
25600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25601         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25602         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25603         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25604         return tag_ptr(ret_conv, true);
25605 }
25606
25607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25608         LDKUpdateFailHTLC o_conv;
25609         o_conv.inner = untag_ptr(o);
25610         o_conv.is_owned = ptr_is_owned(o);
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25612         o_conv = UpdateFailHTLC_clone(&o_conv);
25613         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25614         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25615         return tag_ptr(ret_conv, true);
25616 }
25617
25618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25619         void* e_ptr = untag_ptr(e);
25620         CHECK_ACCESS(e_ptr);
25621         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25622         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25623         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25624         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25625         return tag_ptr(ret_conv, true);
25626 }
25627
25628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25629         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25630         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25631         return ret_conv;
25632 }
25633
25634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25635         if (!ptr_is_owned(_res)) return;
25636         void* _res_ptr = untag_ptr(_res);
25637         CHECK_ACCESS(_res_ptr);
25638         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25639         FREE(untag_ptr(_res));
25640         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25641 }
25642
25643 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25644         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25645         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25646         return tag_ptr(ret_conv, true);
25647 }
25648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25649         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25650         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25651         return ret_conv;
25652 }
25653
25654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25655         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25656         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25657         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25658         return tag_ptr(ret_conv, true);
25659 }
25660
25661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25662         LDKUpdateFailMalformedHTLC o_conv;
25663         o_conv.inner = untag_ptr(o);
25664         o_conv.is_owned = ptr_is_owned(o);
25665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25666         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25667         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25668         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25669         return tag_ptr(ret_conv, true);
25670 }
25671
25672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25673         void* e_ptr = untag_ptr(e);
25674         CHECK_ACCESS(e_ptr);
25675         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25676         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25677         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25678         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25679         return tag_ptr(ret_conv, true);
25680 }
25681
25682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25683         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25684         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25685         return ret_conv;
25686 }
25687
25688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25689         if (!ptr_is_owned(_res)) return;
25690         void* _res_ptr = untag_ptr(_res);
25691         CHECK_ACCESS(_res_ptr);
25692         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25693         FREE(untag_ptr(_res));
25694         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25695 }
25696
25697 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25698         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25699         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25700         return tag_ptr(ret_conv, true);
25701 }
25702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25703         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25704         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25705         return ret_conv;
25706 }
25707
25708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25709         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25710         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25711         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25712         return tag_ptr(ret_conv, true);
25713 }
25714
25715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25716         LDKUpdateFee o_conv;
25717         o_conv.inner = untag_ptr(o);
25718         o_conv.is_owned = ptr_is_owned(o);
25719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25720         o_conv = UpdateFee_clone(&o_conv);
25721         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25722         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25723         return tag_ptr(ret_conv, true);
25724 }
25725
25726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25727         void* e_ptr = untag_ptr(e);
25728         CHECK_ACCESS(e_ptr);
25729         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25730         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25731         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25732         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25733         return tag_ptr(ret_conv, true);
25734 }
25735
25736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25737         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25738         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25739         return ret_conv;
25740 }
25741
25742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25743         if (!ptr_is_owned(_res)) return;
25744         void* _res_ptr = untag_ptr(_res);
25745         CHECK_ACCESS(_res_ptr);
25746         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25747         FREE(untag_ptr(_res));
25748         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25749 }
25750
25751 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25752         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25753         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25754         return tag_ptr(ret_conv, true);
25755 }
25756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25757         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25758         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25759         return ret_conv;
25760 }
25761
25762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25763         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25764         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25765         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25766         return tag_ptr(ret_conv, true);
25767 }
25768
25769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25770         LDKUpdateFulfillHTLC o_conv;
25771         o_conv.inner = untag_ptr(o);
25772         o_conv.is_owned = ptr_is_owned(o);
25773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25774         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25775         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25776         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25777         return tag_ptr(ret_conv, true);
25778 }
25779
25780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25781         void* e_ptr = untag_ptr(e);
25782         CHECK_ACCESS(e_ptr);
25783         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25784         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25785         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25786         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25787         return tag_ptr(ret_conv, true);
25788 }
25789
25790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25791         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25792         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25793         return ret_conv;
25794 }
25795
25796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25797         if (!ptr_is_owned(_res)) return;
25798         void* _res_ptr = untag_ptr(_res);
25799         CHECK_ACCESS(_res_ptr);
25800         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25801         FREE(untag_ptr(_res));
25802         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25803 }
25804
25805 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25806         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25807         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25808         return tag_ptr(ret_conv, true);
25809 }
25810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25811         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25812         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25813         return ret_conv;
25814 }
25815
25816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25817         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25818         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25819         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25820         return tag_ptr(ret_conv, true);
25821 }
25822
25823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25824         LDKUpdateAddHTLC o_conv;
25825         o_conv.inner = untag_ptr(o);
25826         o_conv.is_owned = ptr_is_owned(o);
25827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25828         o_conv = UpdateAddHTLC_clone(&o_conv);
25829         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25830         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25831         return tag_ptr(ret_conv, true);
25832 }
25833
25834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25835         void* e_ptr = untag_ptr(e);
25836         CHECK_ACCESS(e_ptr);
25837         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25838         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25839         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25840         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25841         return tag_ptr(ret_conv, true);
25842 }
25843
25844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25845         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25846         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25847         return ret_conv;
25848 }
25849
25850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25851         if (!ptr_is_owned(_res)) return;
25852         void* _res_ptr = untag_ptr(_res);
25853         CHECK_ACCESS(_res_ptr);
25854         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25855         FREE(untag_ptr(_res));
25856         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25857 }
25858
25859 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25860         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25861         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25862         return tag_ptr(ret_conv, true);
25863 }
25864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25865         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25866         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25867         return ret_conv;
25868 }
25869
25870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25871         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25872         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25873         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25874         return tag_ptr(ret_conv, true);
25875 }
25876
25877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25878         LDKOnionMessage o_conv;
25879         o_conv.inner = untag_ptr(o);
25880         o_conv.is_owned = ptr_is_owned(o);
25881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25882         o_conv = OnionMessage_clone(&o_conv);
25883         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25884         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25885         return tag_ptr(ret_conv, true);
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25889         void* e_ptr = untag_ptr(e);
25890         CHECK_ACCESS(e_ptr);
25891         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25892         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25893         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25894         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25895         return tag_ptr(ret_conv, true);
25896 }
25897
25898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25899         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25900         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25901         return ret_conv;
25902 }
25903
25904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25905         if (!ptr_is_owned(_res)) return;
25906         void* _res_ptr = untag_ptr(_res);
25907         CHECK_ACCESS(_res_ptr);
25908         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25909         FREE(untag_ptr(_res));
25910         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25911 }
25912
25913 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25914         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25915         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25916         return tag_ptr(ret_conv, true);
25917 }
25918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25919         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25920         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25921         return ret_conv;
25922 }
25923
25924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25925         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25926         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25927         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25928         return tag_ptr(ret_conv, true);
25929 }
25930
25931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25932         LDKPing o_conv;
25933         o_conv.inner = untag_ptr(o);
25934         o_conv.is_owned = ptr_is_owned(o);
25935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25936         o_conv = Ping_clone(&o_conv);
25937         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25938         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25939         return tag_ptr(ret_conv, true);
25940 }
25941
25942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25943         void* e_ptr = untag_ptr(e);
25944         CHECK_ACCESS(e_ptr);
25945         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25946         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25947         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25948         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25949         return tag_ptr(ret_conv, true);
25950 }
25951
25952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25953         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25954         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25955         return ret_conv;
25956 }
25957
25958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25959         if (!ptr_is_owned(_res)) return;
25960         void* _res_ptr = untag_ptr(_res);
25961         CHECK_ACCESS(_res_ptr);
25962         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25963         FREE(untag_ptr(_res));
25964         CResult_PingDecodeErrorZ_free(_res_conv);
25965 }
25966
25967 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25968         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25969         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25970         return tag_ptr(ret_conv, true);
25971 }
25972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25973         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25974         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25975         return ret_conv;
25976 }
25977
25978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25979         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25980         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25981         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
25982         return tag_ptr(ret_conv, true);
25983 }
25984
25985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25986         LDKPong o_conv;
25987         o_conv.inner = untag_ptr(o);
25988         o_conv.is_owned = ptr_is_owned(o);
25989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25990         o_conv = Pong_clone(&o_conv);
25991         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25992         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
25993         return tag_ptr(ret_conv, true);
25994 }
25995
25996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25997         void* e_ptr = untag_ptr(e);
25998         CHECK_ACCESS(e_ptr);
25999         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26000         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26001         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26002         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
26003         return tag_ptr(ret_conv, true);
26004 }
26005
26006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26007         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
26008         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
26009         return ret_conv;
26010 }
26011
26012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26013         if (!ptr_is_owned(_res)) return;
26014         void* _res_ptr = untag_ptr(_res);
26015         CHECK_ACCESS(_res_ptr);
26016         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
26017         FREE(untag_ptr(_res));
26018         CResult_PongDecodeErrorZ_free(_res_conv);
26019 }
26020
26021 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
26022         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26023         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
26024         return tag_ptr(ret_conv, true);
26025 }
26026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26027         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
26028         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
26029         return ret_conv;
26030 }
26031
26032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26033         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
26034         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26035         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
26036         return tag_ptr(ret_conv, true);
26037 }
26038
26039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26040         LDKUnsignedChannelAnnouncement o_conv;
26041         o_conv.inner = untag_ptr(o);
26042         o_conv.is_owned = ptr_is_owned(o);
26043         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26044         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
26045         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26046         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
26047         return tag_ptr(ret_conv, true);
26048 }
26049
26050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26051         void* e_ptr = untag_ptr(e);
26052         CHECK_ACCESS(e_ptr);
26053         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26054         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26055         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26056         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
26057         return tag_ptr(ret_conv, true);
26058 }
26059
26060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26061         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26062         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26063         return ret_conv;
26064 }
26065
26066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26067         if (!ptr_is_owned(_res)) return;
26068         void* _res_ptr = untag_ptr(_res);
26069         CHECK_ACCESS(_res_ptr);
26070         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26071         FREE(untag_ptr(_res));
26072         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
26073 }
26074
26075 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26076         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26077         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
26078         return tag_ptr(ret_conv, true);
26079 }
26080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26081         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26082         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26083         return ret_conv;
26084 }
26085
26086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26087         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26088         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26089         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26090         return tag_ptr(ret_conv, true);
26091 }
26092
26093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26094         LDKChannelAnnouncement o_conv;
26095         o_conv.inner = untag_ptr(o);
26096         o_conv.is_owned = ptr_is_owned(o);
26097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26098         o_conv = ChannelAnnouncement_clone(&o_conv);
26099         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26100         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
26101         return tag_ptr(ret_conv, true);
26102 }
26103
26104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26105         void* e_ptr = untag_ptr(e);
26106         CHECK_ACCESS(e_ptr);
26107         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26108         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26109         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26110         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
26111         return tag_ptr(ret_conv, true);
26112 }
26113
26114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26115         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26116         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26117         return ret_conv;
26118 }
26119
26120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26121         if (!ptr_is_owned(_res)) return;
26122         void* _res_ptr = untag_ptr(_res);
26123         CHECK_ACCESS(_res_ptr);
26124         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26125         FREE(untag_ptr(_res));
26126         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
26127 }
26128
26129 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26130         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26131         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
26132         return tag_ptr(ret_conv, true);
26133 }
26134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26135         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26136         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26137         return ret_conv;
26138 }
26139
26140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26141         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26142         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26143         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26144         return tag_ptr(ret_conv, true);
26145 }
26146
26147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26148         LDKUnsignedChannelUpdate o_conv;
26149         o_conv.inner = untag_ptr(o);
26150         o_conv.is_owned = ptr_is_owned(o);
26151         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26152         o_conv = UnsignedChannelUpdate_clone(&o_conv);
26153         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26154         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
26155         return tag_ptr(ret_conv, true);
26156 }
26157
26158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26159         void* e_ptr = untag_ptr(e);
26160         CHECK_ACCESS(e_ptr);
26161         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26162         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26163         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26164         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
26165         return tag_ptr(ret_conv, true);
26166 }
26167
26168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26169         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
26170         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
26171         return ret_conv;
26172 }
26173
26174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26175         if (!ptr_is_owned(_res)) return;
26176         void* _res_ptr = untag_ptr(_res);
26177         CHECK_ACCESS(_res_ptr);
26178         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
26179         FREE(untag_ptr(_res));
26180         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
26181 }
26182
26183 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26184         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26185         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
26186         return tag_ptr(ret_conv, true);
26187 }
26188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26189         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26190         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26191         return ret_conv;
26192 }
26193
26194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26195         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26196         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26197         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
26198         return tag_ptr(ret_conv, true);
26199 }
26200
26201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26202         LDKChannelUpdate o_conv;
26203         o_conv.inner = untag_ptr(o);
26204         o_conv.is_owned = ptr_is_owned(o);
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26206         o_conv = ChannelUpdate_clone(&o_conv);
26207         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26208         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
26209         return tag_ptr(ret_conv, true);
26210 }
26211
26212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26213         void* e_ptr = untag_ptr(e);
26214         CHECK_ACCESS(e_ptr);
26215         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26216         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26217         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26218         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
26219         return tag_ptr(ret_conv, true);
26220 }
26221
26222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26223         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
26224         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
26225         return ret_conv;
26226 }
26227
26228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26229         if (!ptr_is_owned(_res)) return;
26230         void* _res_ptr = untag_ptr(_res);
26231         CHECK_ACCESS(_res_ptr);
26232         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
26233         FREE(untag_ptr(_res));
26234         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
26235 }
26236
26237 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26238         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26239         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
26240         return tag_ptr(ret_conv, true);
26241 }
26242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26243         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26244         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26245         return ret_conv;
26246 }
26247
26248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26249         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26250         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26251         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
26252         return tag_ptr(ret_conv, true);
26253 }
26254
26255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26256         LDKErrorMessage o_conv;
26257         o_conv.inner = untag_ptr(o);
26258         o_conv.is_owned = ptr_is_owned(o);
26259         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26260         o_conv = ErrorMessage_clone(&o_conv);
26261         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26262         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
26263         return tag_ptr(ret_conv, true);
26264 }
26265
26266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26267         void* e_ptr = untag_ptr(e);
26268         CHECK_ACCESS(e_ptr);
26269         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26270         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26271         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26272         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
26273         return tag_ptr(ret_conv, true);
26274 }
26275
26276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26277         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
26278         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
26279         return ret_conv;
26280 }
26281
26282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26283         if (!ptr_is_owned(_res)) return;
26284         void* _res_ptr = untag_ptr(_res);
26285         CHECK_ACCESS(_res_ptr);
26286         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
26287         FREE(untag_ptr(_res));
26288         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
26289 }
26290
26291 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
26292         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26293         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
26294         return tag_ptr(ret_conv, true);
26295 }
26296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26297         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
26298         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
26299         return ret_conv;
26300 }
26301
26302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26303         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
26304         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26305         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
26306         return tag_ptr(ret_conv, true);
26307 }
26308
26309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26310         LDKWarningMessage o_conv;
26311         o_conv.inner = untag_ptr(o);
26312         o_conv.is_owned = ptr_is_owned(o);
26313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26314         o_conv = WarningMessage_clone(&o_conv);
26315         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26316         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
26317         return tag_ptr(ret_conv, true);
26318 }
26319
26320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26321         void* e_ptr = untag_ptr(e);
26322         CHECK_ACCESS(e_ptr);
26323         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26324         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26325         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26326         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
26327         return tag_ptr(ret_conv, true);
26328 }
26329
26330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26331         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
26332         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
26333         return ret_conv;
26334 }
26335
26336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26337         if (!ptr_is_owned(_res)) return;
26338         void* _res_ptr = untag_ptr(_res);
26339         CHECK_ACCESS(_res_ptr);
26340         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
26341         FREE(untag_ptr(_res));
26342         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
26343 }
26344
26345 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
26346         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26347         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
26348         return tag_ptr(ret_conv, true);
26349 }
26350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26351         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
26352         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
26353         return ret_conv;
26354 }
26355
26356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26357         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
26358         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26359         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
26360         return tag_ptr(ret_conv, true);
26361 }
26362
26363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26364         LDKUnsignedNodeAnnouncement o_conv;
26365         o_conv.inner = untag_ptr(o);
26366         o_conv.is_owned = ptr_is_owned(o);
26367         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26368         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
26369         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26370         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
26371         return tag_ptr(ret_conv, true);
26372 }
26373
26374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26375         void* e_ptr = untag_ptr(e);
26376         CHECK_ACCESS(e_ptr);
26377         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26378         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26379         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26380         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
26381         return tag_ptr(ret_conv, true);
26382 }
26383
26384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26385         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26386         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26387         return ret_conv;
26388 }
26389
26390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26391         if (!ptr_is_owned(_res)) return;
26392         void* _res_ptr = untag_ptr(_res);
26393         CHECK_ACCESS(_res_ptr);
26394         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
26395         FREE(untag_ptr(_res));
26396         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
26397 }
26398
26399 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26400         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26401         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
26402         return tag_ptr(ret_conv, true);
26403 }
26404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26405         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26406         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26407         return ret_conv;
26408 }
26409
26410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26411         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26412         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26413         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26414         return tag_ptr(ret_conv, true);
26415 }
26416
26417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26418         LDKNodeAnnouncement o_conv;
26419         o_conv.inner = untag_ptr(o);
26420         o_conv.is_owned = ptr_is_owned(o);
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26422         o_conv = NodeAnnouncement_clone(&o_conv);
26423         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26424         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26425         return tag_ptr(ret_conv, true);
26426 }
26427
26428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26429         void* e_ptr = untag_ptr(e);
26430         CHECK_ACCESS(e_ptr);
26431         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26432         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26433         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26434         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26435         return tag_ptr(ret_conv, true);
26436 }
26437
26438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26439         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26440         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26441         return ret_conv;
26442 }
26443
26444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26445         if (!ptr_is_owned(_res)) return;
26446         void* _res_ptr = untag_ptr(_res);
26447         CHECK_ACCESS(_res_ptr);
26448         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26449         FREE(untag_ptr(_res));
26450         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26451 }
26452
26453 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26454         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26455         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26456         return tag_ptr(ret_conv, true);
26457 }
26458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26459         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26460         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26461         return ret_conv;
26462 }
26463
26464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26465         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26466         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26467         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26468         return tag_ptr(ret_conv, true);
26469 }
26470
26471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26472         LDKQueryShortChannelIds o_conv;
26473         o_conv.inner = untag_ptr(o);
26474         o_conv.is_owned = ptr_is_owned(o);
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26476         o_conv = QueryShortChannelIds_clone(&o_conv);
26477         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26478         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26479         return tag_ptr(ret_conv, true);
26480 }
26481
26482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26483         void* e_ptr = untag_ptr(e);
26484         CHECK_ACCESS(e_ptr);
26485         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26486         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26487         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26488         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26489         return tag_ptr(ret_conv, true);
26490 }
26491
26492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26493         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26494         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26495         return ret_conv;
26496 }
26497
26498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26499         if (!ptr_is_owned(_res)) return;
26500         void* _res_ptr = untag_ptr(_res);
26501         CHECK_ACCESS(_res_ptr);
26502         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26503         FREE(untag_ptr(_res));
26504         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26505 }
26506
26507 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26508         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26509         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26510         return tag_ptr(ret_conv, true);
26511 }
26512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26513         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26514         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26515         return ret_conv;
26516 }
26517
26518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26519         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26520         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26521         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26522         return tag_ptr(ret_conv, true);
26523 }
26524
26525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26526         LDKReplyShortChannelIdsEnd o_conv;
26527         o_conv.inner = untag_ptr(o);
26528         o_conv.is_owned = ptr_is_owned(o);
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26530         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26531         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26532         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26533         return tag_ptr(ret_conv, true);
26534 }
26535
26536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26537         void* e_ptr = untag_ptr(e);
26538         CHECK_ACCESS(e_ptr);
26539         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26540         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26541         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26542         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26543         return tag_ptr(ret_conv, true);
26544 }
26545
26546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26547         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26548         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26549         return ret_conv;
26550 }
26551
26552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26553         if (!ptr_is_owned(_res)) return;
26554         void* _res_ptr = untag_ptr(_res);
26555         CHECK_ACCESS(_res_ptr);
26556         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26557         FREE(untag_ptr(_res));
26558         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26559 }
26560
26561 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26562         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26563         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26564         return tag_ptr(ret_conv, true);
26565 }
26566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26567         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26568         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26569         return ret_conv;
26570 }
26571
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26573         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26574         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26575         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26576         return tag_ptr(ret_conv, true);
26577 }
26578
26579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26580         LDKQueryChannelRange o_conv;
26581         o_conv.inner = untag_ptr(o);
26582         o_conv.is_owned = ptr_is_owned(o);
26583         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26584         o_conv = QueryChannelRange_clone(&o_conv);
26585         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26586         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26587         return tag_ptr(ret_conv, true);
26588 }
26589
26590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26591         void* e_ptr = untag_ptr(e);
26592         CHECK_ACCESS(e_ptr);
26593         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26594         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26595         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26596         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26597         return tag_ptr(ret_conv, true);
26598 }
26599
26600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26601         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26602         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26603         return ret_conv;
26604 }
26605
26606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26607         if (!ptr_is_owned(_res)) return;
26608         void* _res_ptr = untag_ptr(_res);
26609         CHECK_ACCESS(_res_ptr);
26610         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26611         FREE(untag_ptr(_res));
26612         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26613 }
26614
26615 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26616         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26617         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26618         return tag_ptr(ret_conv, true);
26619 }
26620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26621         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26622         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26623         return ret_conv;
26624 }
26625
26626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26627         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26628         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26629         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26630         return tag_ptr(ret_conv, true);
26631 }
26632
26633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26634         LDKReplyChannelRange o_conv;
26635         o_conv.inner = untag_ptr(o);
26636         o_conv.is_owned = ptr_is_owned(o);
26637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26638         o_conv = ReplyChannelRange_clone(&o_conv);
26639         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26640         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26641         return tag_ptr(ret_conv, true);
26642 }
26643
26644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26645         void* e_ptr = untag_ptr(e);
26646         CHECK_ACCESS(e_ptr);
26647         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26648         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26649         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26650         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26651         return tag_ptr(ret_conv, true);
26652 }
26653
26654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26655         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26656         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26657         return ret_conv;
26658 }
26659
26660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26661         if (!ptr_is_owned(_res)) return;
26662         void* _res_ptr = untag_ptr(_res);
26663         CHECK_ACCESS(_res_ptr);
26664         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26665         FREE(untag_ptr(_res));
26666         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26667 }
26668
26669 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26670         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26671         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26672         return tag_ptr(ret_conv, true);
26673 }
26674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26675         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26676         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26677         return ret_conv;
26678 }
26679
26680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26681         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26682         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26683         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26684         return tag_ptr(ret_conv, true);
26685 }
26686
26687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26688         LDKGossipTimestampFilter o_conv;
26689         o_conv.inner = untag_ptr(o);
26690         o_conv.is_owned = ptr_is_owned(o);
26691         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26692         o_conv = GossipTimestampFilter_clone(&o_conv);
26693         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26694         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26695         return tag_ptr(ret_conv, true);
26696 }
26697
26698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26699         void* e_ptr = untag_ptr(e);
26700         CHECK_ACCESS(e_ptr);
26701         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26702         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26703         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26704         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26705         return tag_ptr(ret_conv, true);
26706 }
26707
26708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26709         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26710         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26711         return ret_conv;
26712 }
26713
26714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26715         if (!ptr_is_owned(_res)) return;
26716         void* _res_ptr = untag_ptr(_res);
26717         CHECK_ACCESS(_res_ptr);
26718         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26719         FREE(untag_ptr(_res));
26720         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26721 }
26722
26723 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26724         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26725         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26726         return tag_ptr(ret_conv, true);
26727 }
26728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26729         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26730         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26731         return ret_conv;
26732 }
26733
26734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26735         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26736         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26737         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26738         return tag_ptr(ret_conv, true);
26739 }
26740
26741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26742         LDKCVec_PhantomRouteHintsZ _res_constr;
26743         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26744         if (_res_constr.datalen > 0)
26745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26746         else
26747                 _res_constr.data = NULL;
26748         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26749         for (size_t t = 0; t < _res_constr.datalen; t++) {
26750                 int64_t _res_conv_19 = _res_vals[t];
26751                 LDKPhantomRouteHints _res_conv_19_conv;
26752                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26753                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26755                 _res_constr.data[t] = _res_conv_19_conv;
26756         }
26757         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26758         CVec_PhantomRouteHintsZ_free(_res_constr);
26759 }
26760
26761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26762         LDKInvoice o_conv;
26763         o_conv.inner = untag_ptr(o);
26764         o_conv.is_owned = ptr_is_owned(o);
26765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26766         o_conv = Invoice_clone(&o_conv);
26767         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26768         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
26769         return tag_ptr(ret_conv, true);
26770 }
26771
26772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26773         void* e_ptr = untag_ptr(e);
26774         CHECK_ACCESS(e_ptr);
26775         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26776         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26777         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26778         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
26779         return tag_ptr(ret_conv, true);
26780 }
26781
26782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26783         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26784         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26785         return ret_conv;
26786 }
26787
26788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26789         if (!ptr_is_owned(_res)) return;
26790         void* _res_ptr = untag_ptr(_res);
26791         CHECK_ACCESS(_res_ptr);
26792         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
26793         FREE(untag_ptr(_res));
26794         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
26795 }
26796
26797 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26798         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26799         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
26800         return tag_ptr(ret_conv, true);
26801 }
26802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26803         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26804         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26805         return ret_conv;
26806 }
26807
26808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26809         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26810         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26811         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
26812         return tag_ptr(ret_conv, true);
26813 }
26814
26815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1FutureZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26816         LDKCVec_FutureZ _res_constr;
26817         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26818         if (_res_constr.datalen > 0)
26819                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26820         else
26821                 _res_constr.data = NULL;
26822         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26823         for (size_t i = 0; i < _res_constr.datalen; i++) {
26824                 int64_t _res_conv_8 = _res_vals[i];
26825                 LDKFuture _res_conv_8_conv;
26826                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26827                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26828                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26829                 _res_constr.data[i] = _res_conv_8_conv;
26830         }
26831         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26832         CVec_FutureZ_free(_res_constr);
26833 }
26834
26835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
26836         void* o_ptr = untag_ptr(o);
26837         CHECK_ACCESS(o_ptr);
26838         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
26839         if (o_conv.free == LDKFilter_JCalls_free) {
26840                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26841                 LDKFilter_JCalls_cloned(&o_conv);
26842         }
26843         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26844         *ret_copy = COption_FilterZ_some(o_conv);
26845         int64_t ret_ref = tag_ptr(ret_copy, true);
26846         return ret_ref;
26847 }
26848
26849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
26850         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26851         *ret_copy = COption_FilterZ_none();
26852         int64_t ret_ref = tag_ptr(ret_copy, true);
26853         return ret_ref;
26854 }
26855
26856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26857         if (!ptr_is_owned(_res)) return;
26858         void* _res_ptr = untag_ptr(_res);
26859         CHECK_ACCESS(_res_ptr);
26860         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
26861         FREE(untag_ptr(_res));
26862         COption_FilterZ_free(_res_conv);
26863 }
26864
26865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26866         LDKLockedChannelMonitor o_conv;
26867         o_conv.inner = untag_ptr(o);
26868         o_conv.is_owned = ptr_is_owned(o);
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26870         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
26871         
26872         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26873         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
26874         return tag_ptr(ret_conv, true);
26875 }
26876
26877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
26878         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26879         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
26880         return tag_ptr(ret_conv, true);
26881 }
26882
26883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26884         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
26885         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
26886         return ret_conv;
26887 }
26888
26889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26890         if (!ptr_is_owned(_res)) return;
26891         void* _res_ptr = untag_ptr(_res);
26892         CHECK_ACCESS(_res_ptr);
26893         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
26894         FREE(untag_ptr(_res));
26895         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
26896 }
26897
26898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26899         LDKCVec_OutPointZ _res_constr;
26900         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26901         if (_res_constr.datalen > 0)
26902                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
26903         else
26904                 _res_constr.data = NULL;
26905         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26906         for (size_t k = 0; k < _res_constr.datalen; k++) {
26907                 int64_t _res_conv_10 = _res_vals[k];
26908                 LDKOutPoint _res_conv_10_conv;
26909                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
26910                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
26911                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
26912                 _res_constr.data[k] = _res_conv_10_conv;
26913         }
26914         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26915         CVec_OutPointZ_free(_res_constr);
26916 }
26917
26918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26919         LDKCVec_MonitorUpdateIdZ _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(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26923         else
26924                 _res_constr.data = NULL;
26925         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26926         for (size_t r = 0; r < _res_constr.datalen; r++) {
26927                 int64_t _res_conv_17 = _res_vals[r];
26928                 LDKMonitorUpdateId _res_conv_17_conv;
26929                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
26930                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
26931                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
26932                 _res_constr.data[r] = _res_conv_17_conv;
26933         }
26934         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26935         CVec_MonitorUpdateIdZ_free(_res_constr);
26936 }
26937
26938 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
26939         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26940         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
26941         return tag_ptr(ret_conv, true);
26942 }
26943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26944         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
26945         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
26946         return ret_conv;
26947 }
26948
26949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26950         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
26951         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26952         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
26953         return tag_ptr(ret_conv, true);
26954 }
26955
26956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
26957         LDKOutPoint a_conv;
26958         a_conv.inner = untag_ptr(a);
26959         a_conv.is_owned = ptr_is_owned(a);
26960         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26961         a_conv = OutPoint_clone(&a_conv);
26962         LDKCVec_MonitorUpdateIdZ b_constr;
26963         b_constr.datalen = (*env)->GetArrayLength(env, b);
26964         if (b_constr.datalen > 0)
26965                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26966         else
26967                 b_constr.data = NULL;
26968         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
26969         for (size_t r = 0; r < b_constr.datalen; r++) {
26970                 int64_t b_conv_17 = b_vals[r];
26971                 LDKMonitorUpdateId b_conv_17_conv;
26972                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
26973                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
26974                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
26975                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
26976                 b_constr.data[r] = b_conv_17_conv;
26977         }
26978         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
26979         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26980         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
26981         return tag_ptr(ret_conv, true);
26982 }
26983
26984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26985         if (!ptr_is_owned(_res)) return;
26986         void* _res_ptr = untag_ptr(_res);
26987         CHECK_ACCESS(_res_ptr);
26988         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
26989         FREE(untag_ptr(_res));
26990         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
26991 }
26992
26993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26994         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
26995         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26996         if (_res_constr.datalen > 0)
26997                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
26998         else
26999                 _res_constr.data = NULL;
27000         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
27001         for (size_t p = 0; p < _res_constr.datalen; p++) {
27002                 int64_t _res_conv_41 = _res_vals[p];
27003                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
27004                 CHECK_ACCESS(_res_conv_41_ptr);
27005                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
27006                 FREE(untag_ptr(_res_conv_41));
27007                 _res_constr.data[p] = _res_conv_41_conv;
27008         }
27009         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
27010         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
27011 }
27012
27013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
27014         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27015         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
27016         return tag_ptr(ret_conv, true);
27017 }
27018
27019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
27020         void* e_ptr = untag_ptr(e);
27021         CHECK_ACCESS(e_ptr);
27022         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
27023         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
27024         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27025         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
27026         return tag_ptr(ret_conv, true);
27027 }
27028
27029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
27030         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
27031         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
27032         return ret_conv;
27033 }
27034
27035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27036         if (!ptr_is_owned(_res)) return;
27037         void* _res_ptr = untag_ptr(_res);
27038         CHECK_ACCESS(_res_ptr);
27039         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
27040         FREE(untag_ptr(_res));
27041         CResult_u32GraphSyncErrorZ_free(_res_conv);
27042 }
27043
27044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27045         if (!ptr_is_owned(this_ptr)) return;
27046         void* this_ptr_ptr = untag_ptr(this_ptr);
27047         CHECK_ACCESS(this_ptr_ptr);
27048         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27049         FREE(untag_ptr(this_ptr));
27050         APIError_free(this_ptr_conv);
27051 }
27052
27053 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27054         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27055         *ret_copy = APIError_clone(arg);
27056         int64_t ret_ref = tag_ptr(ret_copy, true);
27057         return ret_ref;
27058 }
27059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27060         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27061         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27062         return ret_conv;
27063 }
27064
27065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27066         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27067         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27068         *ret_copy = APIError_clone(orig_conv);
27069         int64_t ret_ref = tag_ptr(ret_copy, true);
27070         return ret_ref;
27071 }
27072
27073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27074         LDKStr err_conv = java_to_owned_str(env, err);
27075         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27076         *ret_copy = APIError_apimisuse_error(err_conv);
27077         int64_t ret_ref = tag_ptr(ret_copy, true);
27078         return ret_ref;
27079 }
27080
27081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27082         LDKStr err_conv = java_to_owned_str(env, err);
27083         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27084         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27085         int64_t ret_ref = tag_ptr(ret_copy, true);
27086         return ret_ref;
27087 }
27088
27089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27090         LDKStr err_conv = java_to_owned_str(env, err);
27091         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27092         *ret_copy = APIError_invalid_route(err_conv);
27093         int64_t ret_ref = tag_ptr(ret_copy, true);
27094         return ret_ref;
27095 }
27096
27097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27098         LDKStr err_conv = java_to_owned_str(env, err);
27099         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27100         *ret_copy = APIError_channel_unavailable(err_conv);
27101         int64_t ret_ref = tag_ptr(ret_copy, true);
27102         return ret_ref;
27103 }
27104
27105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27106         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27107         *ret_copy = APIError_monitor_update_in_progress();
27108         int64_t ret_ref = tag_ptr(ret_copy, true);
27109         return ret_ref;
27110 }
27111
27112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27113         LDKShutdownScript script_conv;
27114         script_conv.inner = untag_ptr(script);
27115         script_conv.is_owned = ptr_is_owned(script);
27116         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27117         script_conv = ShutdownScript_clone(&script_conv);
27118         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27119         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27120         int64_t ret_ref = tag_ptr(ret_copy, true);
27121         return ret_ref;
27122 }
27123
27124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27125         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27126         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27127         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27128         return ret_conv;
27129 }
27130
27131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_APIError_1write(JNIEnv *env, jclass clz, int64_t obj) {
27132         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
27133         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
27134         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27135         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27136         CVec_u8Z_free(ret_var);
27137         return ret_arr;
27138 }
27139
27140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27141         LDKu8slice ser_ref;
27142         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27143         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27144         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
27145         *ret_conv = APIError_read(ser_ref);
27146         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27147         return tag_ptr(ret_conv, true);
27148 }
27149
27150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27151         LDKBigSize this_obj_conv;
27152         this_obj_conv.inner = untag_ptr(this_obj);
27153         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27155         BigSize_free(this_obj_conv);
27156 }
27157
27158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27159         LDKBigSize this_ptr_conv;
27160         this_ptr_conv.inner = untag_ptr(this_ptr);
27161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27163         this_ptr_conv.is_owned = false;
27164         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27165         return ret_conv;
27166 }
27167
27168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27169         LDKBigSize this_ptr_conv;
27170         this_ptr_conv.inner = untag_ptr(this_ptr);
27171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27173         this_ptr_conv.is_owned = false;
27174         BigSize_set_a(&this_ptr_conv, val);
27175 }
27176
27177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27178         LDKBigSize ret_var = BigSize_new(a_arg);
27179         int64_t ret_ref = 0;
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27182         return ret_ref;
27183 }
27184
27185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27186         LDKHostname this_obj_conv;
27187         this_obj_conv.inner = untag_ptr(this_obj);
27188         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27190         Hostname_free(this_obj_conv);
27191 }
27192
27193 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27194         LDKHostname ret_var = Hostname_clone(arg);
27195         int64_t ret_ref = 0;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27198         return ret_ref;
27199 }
27200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27201         LDKHostname arg_conv;
27202         arg_conv.inner = untag_ptr(arg);
27203         arg_conv.is_owned = ptr_is_owned(arg);
27204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27205         arg_conv.is_owned = false;
27206         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27207         return ret_conv;
27208 }
27209
27210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27211         LDKHostname orig_conv;
27212         orig_conv.inner = untag_ptr(orig);
27213         orig_conv.is_owned = ptr_is_owned(orig);
27214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27215         orig_conv.is_owned = false;
27216         LDKHostname ret_var = Hostname_clone(&orig_conv);
27217         int64_t ret_ref = 0;
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27220         return ret_ref;
27221 }
27222
27223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27224         LDKHostname a_conv;
27225         a_conv.inner = untag_ptr(a);
27226         a_conv.is_owned = ptr_is_owned(a);
27227         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27228         a_conv.is_owned = false;
27229         LDKHostname b_conv;
27230         b_conv.inner = untag_ptr(b);
27231         b_conv.is_owned = ptr_is_owned(b);
27232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27233         b_conv.is_owned = false;
27234         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27235         return ret_conv;
27236 }
27237
27238 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27239         LDKHostname this_arg_conv;
27240         this_arg_conv.inner = untag_ptr(this_arg);
27241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27243         this_arg_conv.is_owned = false;
27244         int8_t ret_conv = Hostname_len(&this_arg_conv);
27245         return ret_conv;
27246 }
27247
27248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27249         LDKu8slice msg_ref;
27250         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27251         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27252         uint8_t sk_arr[32];
27253         CHECK((*env)->GetArrayLength(env, sk) == 32);
27254         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27255         uint8_t (*sk_ref)[32] = &sk_arr;
27256         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27257         *ret_conv = sign(msg_ref, sk_ref);
27258         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27259         return tag_ptr(ret_conv, true);
27260 }
27261
27262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27263         LDKu8slice msg_ref;
27264         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27265         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27266         LDKStr sig_conv = java_to_owned_str(env, sig);
27267         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27268         *ret_conv = recover_pk(msg_ref, sig_conv);
27269         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27270         return tag_ptr(ret_conv, true);
27271 }
27272
27273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27274         LDKu8slice msg_ref;
27275         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27276         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27277         LDKStr sig_conv = java_to_owned_str(env, sig);
27278         LDKPublicKey pk_ref;
27279         CHECK((*env)->GetArrayLength(env, pk) == 33);
27280         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27281         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27282         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27283         return ret_conv;
27284 }
27285
27286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27287         LDKu8slice hrp_bytes_ref;
27288         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27289         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27290         LDKCVec_U5Z data_without_signature_constr;
27291         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27292         if (data_without_signature_constr.datalen > 0)
27293                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27294         else
27295                 data_without_signature_constr.data = NULL;
27296         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27297         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27298                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27299                 
27300                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27301         }
27302         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27303         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27306         CVec_u8Z_free(ret_var);
27307         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27308         return ret_arr;
27309 }
27310
27311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27312         if (!ptr_is_owned(this_ptr)) return;
27313         void* this_ptr_ptr = untag_ptr(this_ptr);
27314         CHECK_ACCESS(this_ptr_ptr);
27315         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27316         FREE(untag_ptr(this_ptr));
27317         Persister_free(this_ptr_conv);
27318 }
27319
27320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27321         LDKUntrustedString this_obj_conv;
27322         this_obj_conv.inner = untag_ptr(this_obj);
27323         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27325         UntrustedString_free(this_obj_conv);
27326 }
27327
27328 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_UntrustedString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27329         LDKUntrustedString this_ptr_conv;
27330         this_ptr_conv.inner = untag_ptr(this_ptr);
27331         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27333         this_ptr_conv.is_owned = false;
27334         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
27335         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27336         Str_free(ret_str);
27337         return ret_conv;
27338 }
27339
27340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27341         LDKUntrustedString this_ptr_conv;
27342         this_ptr_conv.inner = untag_ptr(this_ptr);
27343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27345         this_ptr_conv.is_owned = false;
27346         LDKStr val_conv = java_to_owned_str(env, val);
27347         UntrustedString_set_a(&this_ptr_conv, val_conv);
27348 }
27349
27350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27351         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27352         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
27353         int64_t ret_ref = 0;
27354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27356         return ret_ref;
27357 }
27358
27359 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
27360         LDKUntrustedString ret_var = UntrustedString_clone(arg);
27361         int64_t ret_ref = 0;
27362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27364         return ret_ref;
27365 }
27366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27367         LDKUntrustedString arg_conv;
27368         arg_conv.inner = untag_ptr(arg);
27369         arg_conv.is_owned = ptr_is_owned(arg);
27370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27371         arg_conv.is_owned = false;
27372         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
27373         return ret_conv;
27374 }
27375
27376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27377         LDKUntrustedString orig_conv;
27378         orig_conv.inner = untag_ptr(orig);
27379         orig_conv.is_owned = ptr_is_owned(orig);
27380         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27381         orig_conv.is_owned = false;
27382         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
27383         int64_t ret_ref = 0;
27384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27386         return ret_ref;
27387 }
27388
27389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UntrustedString_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27390         LDKUntrustedString a_conv;
27391         a_conv.inner = untag_ptr(a);
27392         a_conv.is_owned = ptr_is_owned(a);
27393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27394         a_conv.is_owned = false;
27395         LDKUntrustedString b_conv;
27396         b_conv.inner = untag_ptr(b);
27397         b_conv.is_owned = ptr_is_owned(b);
27398         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27399         b_conv.is_owned = false;
27400         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
27401         return ret_conv;
27402 }
27403
27404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UntrustedString_1write(JNIEnv *env, jclass clz, int64_t obj) {
27405         LDKUntrustedString obj_conv;
27406         obj_conv.inner = untag_ptr(obj);
27407         obj_conv.is_owned = ptr_is_owned(obj);
27408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27409         obj_conv.is_owned = false;
27410         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
27411         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27412         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27413         CVec_u8Z_free(ret_var);
27414         return ret_arr;
27415 }
27416
27417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27418         LDKu8slice ser_ref;
27419         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27420         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27421         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
27422         *ret_conv = UntrustedString_read(ser_ref);
27423         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27424         return tag_ptr(ret_conv, true);
27425 }
27426
27427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27428         LDKPrintableString this_obj_conv;
27429         this_obj_conv.inner = untag_ptr(this_obj);
27430         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27432         PrintableString_free(this_obj_conv);
27433 }
27434
27435 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27436         LDKPrintableString this_ptr_conv;
27437         this_ptr_conv.inner = untag_ptr(this_ptr);
27438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27440         this_ptr_conv.is_owned = false;
27441         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27442         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27443         Str_free(ret_str);
27444         return ret_conv;
27445 }
27446
27447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27448         LDKPrintableString this_ptr_conv;
27449         this_ptr_conv.inner = untag_ptr(this_ptr);
27450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27452         this_ptr_conv.is_owned = false;
27453         LDKStr val_conv = java_to_owned_str(env, val);
27454         PrintableString_set_a(&this_ptr_conv, val_conv);
27455 }
27456
27457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27458         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27459         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27460         int64_t ret_ref = 0;
27461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27463         return ret_ref;
27464 }
27465
27466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27467         if (!ptr_is_owned(this_ptr)) return;
27468         void* this_ptr_ptr = untag_ptr(this_ptr);
27469         CHECK_ACCESS(this_ptr_ptr);
27470         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27471         FREE(untag_ptr(this_ptr));
27472         FutureCallback_free(this_ptr_conv);
27473 }
27474
27475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27476         LDKFuture this_obj_conv;
27477         this_obj_conv.inner = untag_ptr(this_obj);
27478         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27480         Future_free(this_obj_conv);
27481 }
27482
27483 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
27484         LDKFuture ret_var = Future_clone(arg);
27485         int64_t ret_ref = 0;
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27488         return ret_ref;
27489 }
27490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27491         LDKFuture arg_conv;
27492         arg_conv.inner = untag_ptr(arg);
27493         arg_conv.is_owned = ptr_is_owned(arg);
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27495         arg_conv.is_owned = false;
27496         int64_t ret_conv = Future_clone_ptr(&arg_conv);
27497         return ret_conv;
27498 }
27499
27500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27501         LDKFuture orig_conv;
27502         orig_conv.inner = untag_ptr(orig);
27503         orig_conv.is_owned = ptr_is_owned(orig);
27504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27505         orig_conv.is_owned = false;
27506         LDKFuture ret_var = Future_clone(&orig_conv);
27507         int64_t ret_ref = 0;
27508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27510         return ret_ref;
27511 }
27512
27513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27514         LDKFuture this_arg_conv;
27515         this_arg_conv.inner = untag_ptr(this_arg);
27516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27518         this_arg_conv.is_owned = false;
27519         void* callback_ptr = untag_ptr(callback);
27520         CHECK_ACCESS(callback_ptr);
27521         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27522         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27523                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27524                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27525         }
27526         Future_register_callback_fn(&this_arg_conv, callback_conv);
27527 }
27528
27529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27530         LDKFuture this_arg_conv;
27531         this_arg_conv.inner = untag_ptr(this_arg);
27532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27534         this_arg_conv = Future_clone(&this_arg_conv);
27535         Future_wait(this_arg_conv);
27536 }
27537
27538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Future_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27539         LDKFuture this_arg_conv;
27540         this_arg_conv.inner = untag_ptr(this_arg);
27541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27543         this_arg_conv = Future_clone(&this_arg_conv);
27544         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
27545         return ret_conv;
27546 }
27547
27548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27549         LDKSleeper this_obj_conv;
27550         this_obj_conv.inner = untag_ptr(this_obj);
27551         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27553         Sleeper_free(this_obj_conv);
27554 }
27555
27556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1single_1future(JNIEnv *env, jclass clz, int64_t future) {
27557         LDKFuture future_conv;
27558         future_conv.inner = untag_ptr(future);
27559         future_conv.is_owned = ptr_is_owned(future);
27560         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
27561         future_conv = Future_clone(&future_conv);
27562         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
27563         int64_t ret_ref = 0;
27564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27566         return ret_ref;
27567 }
27568
27569 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) {
27570         LDKFuture fut_a_conv;
27571         fut_a_conv.inner = untag_ptr(fut_a);
27572         fut_a_conv.is_owned = ptr_is_owned(fut_a);
27573         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
27574         fut_a_conv = Future_clone(&fut_a_conv);
27575         LDKFuture fut_b_conv;
27576         fut_b_conv.inner = untag_ptr(fut_b);
27577         fut_b_conv.is_owned = ptr_is_owned(fut_b);
27578         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
27579         fut_b_conv = Future_clone(&fut_b_conv);
27580         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
27581         int64_t ret_ref = 0;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27584         return ret_ref;
27585 }
27586
27587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1new(JNIEnv *env, jclass clz, int64_tArray futures) {
27588         LDKCVec_FutureZ futures_constr;
27589         futures_constr.datalen = (*env)->GetArrayLength(env, futures);
27590         if (futures_constr.datalen > 0)
27591                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
27592         else
27593                 futures_constr.data = NULL;
27594         int64_t* futures_vals = (*env)->GetLongArrayElements (env, futures, NULL);
27595         for (size_t i = 0; i < futures_constr.datalen; i++) {
27596                 int64_t futures_conv_8 = futures_vals[i];
27597                 LDKFuture futures_conv_8_conv;
27598                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
27599                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
27600                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
27601                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
27602                 futures_constr.data[i] = futures_conv_8_conv;
27603         }
27604         (*env)->ReleaseLongArrayElements(env, futures, futures_vals, 0);
27605         LDKSleeper ret_var = Sleeper_new(futures_constr);
27606         int64_t ret_ref = 0;
27607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27609         return ret_ref;
27610 }
27611
27612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27613         LDKSleeper this_arg_conv;
27614         this_arg_conv.inner = untag_ptr(this_arg);
27615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27617         this_arg_conv.is_owned = false;
27618         Sleeper_wait(&this_arg_conv);
27619 }
27620
27621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27622         LDKSleeper this_arg_conv;
27623         this_arg_conv.inner = untag_ptr(this_arg);
27624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27626         this_arg_conv.is_owned = false;
27627         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
27628         return ret_conv;
27629 }
27630
27631 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27632         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27633         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27634         return ret_conv;
27635 }
27636
27637 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27638         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27639         return ret_conv;
27640 }
27641
27642 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27643         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27644         return ret_conv;
27645 }
27646
27647 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27648         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27649         return ret_conv;
27650 }
27651
27652 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27653         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27654         return ret_conv;
27655 }
27656
27657 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27658         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27659         return ret_conv;
27660 }
27661
27662 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27663         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27664         return ret_conv;
27665 }
27666
27667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27668         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27669         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27670         jboolean ret_conv = Level_eq(a_conv, b_conv);
27671         return ret_conv;
27672 }
27673
27674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27675         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27676         int64_t ret_conv = Level_hash(o_conv);
27677         return ret_conv;
27678 }
27679
27680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27681         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27682         return ret_conv;
27683 }
27684
27685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27686         LDKRecord this_obj_conv;
27687         this_obj_conv.inner = untag_ptr(this_obj);
27688         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27690         Record_free(this_obj_conv);
27691 }
27692
27693 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27694         LDKRecord this_ptr_conv;
27695         this_ptr_conv.inner = untag_ptr(this_ptr);
27696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27698         this_ptr_conv.is_owned = false;
27699         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27700         return ret_conv;
27701 }
27702
27703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27704         LDKRecord this_ptr_conv;
27705         this_ptr_conv.inner = untag_ptr(this_ptr);
27706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27708         this_ptr_conv.is_owned = false;
27709         LDKLevel val_conv = LDKLevel_from_java(env, val);
27710         Record_set_level(&this_ptr_conv, val_conv);
27711 }
27712
27713 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(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         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27720         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27721         Str_free(ret_str);
27722         return ret_conv;
27723 }
27724
27725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27726         LDKRecord this_ptr_conv;
27727         this_ptr_conv.inner = untag_ptr(this_ptr);
27728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27730         this_ptr_conv.is_owned = false;
27731         LDKStr val_conv = java_to_owned_str(env, val);
27732         Record_set_args(&this_ptr_conv, val_conv);
27733 }
27734
27735 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27736         LDKRecord this_ptr_conv;
27737         this_ptr_conv.inner = untag_ptr(this_ptr);
27738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27740         this_ptr_conv.is_owned = false;
27741         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27742         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27743         Str_free(ret_str);
27744         return ret_conv;
27745 }
27746
27747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27748         LDKRecord this_ptr_conv;
27749         this_ptr_conv.inner = untag_ptr(this_ptr);
27750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27752         this_ptr_conv.is_owned = false;
27753         LDKStr val_conv = java_to_owned_str(env, val);
27754         Record_set_module_path(&this_ptr_conv, val_conv);
27755 }
27756
27757 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27758         LDKRecord this_ptr_conv;
27759         this_ptr_conv.inner = untag_ptr(this_ptr);
27760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27762         this_ptr_conv.is_owned = false;
27763         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27764         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27765         Str_free(ret_str);
27766         return ret_conv;
27767 }
27768
27769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27770         LDKRecord this_ptr_conv;
27771         this_ptr_conv.inner = untag_ptr(this_ptr);
27772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27774         this_ptr_conv.is_owned = false;
27775         LDKStr val_conv = java_to_owned_str(env, val);
27776         Record_set_file(&this_ptr_conv, val_conv);
27777 }
27778
27779 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27780         LDKRecord this_ptr_conv;
27781         this_ptr_conv.inner = untag_ptr(this_ptr);
27782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27784         this_ptr_conv.is_owned = false;
27785         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27786         return ret_conv;
27787 }
27788
27789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t 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         Record_set_line(&this_ptr_conv, val);
27796 }
27797
27798 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27799         LDKRecord ret_var = Record_clone(arg);
27800         int64_t ret_ref = 0;
27801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27803         return ret_ref;
27804 }
27805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27806         LDKRecord arg_conv;
27807         arg_conv.inner = untag_ptr(arg);
27808         arg_conv.is_owned = ptr_is_owned(arg);
27809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27810         arg_conv.is_owned = false;
27811         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27812         return ret_conv;
27813 }
27814
27815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27816         LDKRecord orig_conv;
27817         orig_conv.inner = untag_ptr(orig);
27818         orig_conv.is_owned = ptr_is_owned(orig);
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27820         orig_conv.is_owned = false;
27821         LDKRecord ret_var = Record_clone(&orig_conv);
27822         int64_t ret_ref = 0;
27823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27825         return ret_ref;
27826 }
27827
27828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27829         if (!ptr_is_owned(this_ptr)) return;
27830         void* this_ptr_ptr = untag_ptr(this_ptr);
27831         CHECK_ACCESS(this_ptr_ptr);
27832         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27833         FREE(untag_ptr(this_ptr));
27834         Logger_free(this_ptr_conv);
27835 }
27836
27837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27838         LDKChannelHandshakeConfig this_obj_conv;
27839         this_obj_conv.inner = untag_ptr(this_obj);
27840         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27842         ChannelHandshakeConfig_free(this_obj_conv);
27843 }
27844
27845 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27846         LDKChannelHandshakeConfig this_ptr_conv;
27847         this_ptr_conv.inner = untag_ptr(this_ptr);
27848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27850         this_ptr_conv.is_owned = false;
27851         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27852         return ret_conv;
27853 }
27854
27855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27856         LDKChannelHandshakeConfig this_ptr_conv;
27857         this_ptr_conv.inner = untag_ptr(this_ptr);
27858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27860         this_ptr_conv.is_owned = false;
27861         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27862 }
27863
27864 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27865         LDKChannelHandshakeConfig this_ptr_conv;
27866         this_ptr_conv.inner = untag_ptr(this_ptr);
27867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27869         this_ptr_conv.is_owned = false;
27870         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27871         return ret_conv;
27872 }
27873
27874 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) {
27875         LDKChannelHandshakeConfig this_ptr_conv;
27876         this_ptr_conv.inner = untag_ptr(this_ptr);
27877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27879         this_ptr_conv.is_owned = false;
27880         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27881 }
27882
27883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27884         LDKChannelHandshakeConfig this_ptr_conv;
27885         this_ptr_conv.inner = untag_ptr(this_ptr);
27886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27888         this_ptr_conv.is_owned = false;
27889         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27890         return ret_conv;
27891 }
27892
27893 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) {
27894         LDKChannelHandshakeConfig this_ptr_conv;
27895         this_ptr_conv.inner = untag_ptr(this_ptr);
27896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27898         this_ptr_conv.is_owned = false;
27899         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27900 }
27901
27902 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) {
27903         LDKChannelHandshakeConfig this_ptr_conv;
27904         this_ptr_conv.inner = untag_ptr(this_ptr);
27905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27907         this_ptr_conv.is_owned = false;
27908         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27909         return ret_conv;
27910 }
27911
27912 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) {
27913         LDKChannelHandshakeConfig this_ptr_conv;
27914         this_ptr_conv.inner = untag_ptr(this_ptr);
27915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27917         this_ptr_conv.is_owned = false;
27918         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27919 }
27920
27921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27922         LDKChannelHandshakeConfig this_ptr_conv;
27923         this_ptr_conv.inner = untag_ptr(this_ptr);
27924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27926         this_ptr_conv.is_owned = false;
27927         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27928         return ret_conv;
27929 }
27930
27931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27932         LDKChannelHandshakeConfig this_ptr_conv;
27933         this_ptr_conv.inner = untag_ptr(this_ptr);
27934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27936         this_ptr_conv.is_owned = false;
27937         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27938 }
27939
27940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27941         LDKChannelHandshakeConfig this_ptr_conv;
27942         this_ptr_conv.inner = untag_ptr(this_ptr);
27943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27945         this_ptr_conv.is_owned = false;
27946         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27947         return ret_conv;
27948 }
27949
27950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27951         LDKChannelHandshakeConfig this_ptr_conv;
27952         this_ptr_conv.inner = untag_ptr(this_ptr);
27953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27955         this_ptr_conv.is_owned = false;
27956         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27957 }
27958
27959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27960         LDKChannelHandshakeConfig this_ptr_conv;
27961         this_ptr_conv.inner = untag_ptr(this_ptr);
27962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27964         this_ptr_conv.is_owned = false;
27965         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27966         return ret_conv;
27967 }
27968
27969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27970         LDKChannelHandshakeConfig this_ptr_conv;
27971         this_ptr_conv.inner = untag_ptr(this_ptr);
27972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27974         this_ptr_conv.is_owned = false;
27975         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27976 }
27977
27978 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27979         LDKChannelHandshakeConfig this_ptr_conv;
27980         this_ptr_conv.inner = untag_ptr(this_ptr);
27981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27983         this_ptr_conv.is_owned = false;
27984         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
27985         return ret_conv;
27986 }
27987
27988 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) {
27989         LDKChannelHandshakeConfig this_ptr_conv;
27990         this_ptr_conv.inner = untag_ptr(this_ptr);
27991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27993         this_ptr_conv.is_owned = false;
27994         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
27995 }
27996
27997 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
27998         LDKChannelHandshakeConfig this_ptr_conv;
27999         this_ptr_conv.inner = untag_ptr(this_ptr);
28000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28002         this_ptr_conv.is_owned = false;
28003         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
28004         return ret_conv;
28005 }
28006
28007 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) {
28008         LDKChannelHandshakeConfig this_ptr_conv;
28009         this_ptr_conv.inner = untag_ptr(this_ptr);
28010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28012         this_ptr_conv.is_owned = false;
28013         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
28014 }
28015
28016 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) {
28017         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);
28018         int64_t ret_ref = 0;
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28021         return ret_ref;
28022 }
28023
28024 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
28025         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
28026         int64_t ret_ref = 0;
28027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28029         return ret_ref;
28030 }
28031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28032         LDKChannelHandshakeConfig arg_conv;
28033         arg_conv.inner = untag_ptr(arg);
28034         arg_conv.is_owned = ptr_is_owned(arg);
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28036         arg_conv.is_owned = false;
28037         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
28038         return ret_conv;
28039 }
28040
28041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28042         LDKChannelHandshakeConfig orig_conv;
28043         orig_conv.inner = untag_ptr(orig);
28044         orig_conv.is_owned = ptr_is_owned(orig);
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28046         orig_conv.is_owned = false;
28047         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
28048         int64_t ret_ref = 0;
28049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28050         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28051         return ret_ref;
28052 }
28053
28054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
28055         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
28056         int64_t ret_ref = 0;
28057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28058         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28059         return ret_ref;
28060 }
28061
28062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28063         LDKChannelHandshakeLimits this_obj_conv;
28064         this_obj_conv.inner = untag_ptr(this_obj);
28065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28067         ChannelHandshakeLimits_free(this_obj_conv);
28068 }
28069
28070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28071         LDKChannelHandshakeLimits this_ptr_conv;
28072         this_ptr_conv.inner = untag_ptr(this_ptr);
28073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28075         this_ptr_conv.is_owned = false;
28076         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
28077         return ret_conv;
28078 }
28079
28080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28081         LDKChannelHandshakeLimits this_ptr_conv;
28082         this_ptr_conv.inner = untag_ptr(this_ptr);
28083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28085         this_ptr_conv.is_owned = false;
28086         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
28087 }
28088
28089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28090         LDKChannelHandshakeLimits this_ptr_conv;
28091         this_ptr_conv.inner = untag_ptr(this_ptr);
28092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28094         this_ptr_conv.is_owned = false;
28095         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
28096         return ret_conv;
28097 }
28098
28099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28100         LDKChannelHandshakeLimits this_ptr_conv;
28101         this_ptr_conv.inner = untag_ptr(this_ptr);
28102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28104         this_ptr_conv.is_owned = false;
28105         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
28106 }
28107
28108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28109         LDKChannelHandshakeLimits this_ptr_conv;
28110         this_ptr_conv.inner = untag_ptr(this_ptr);
28111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28113         this_ptr_conv.is_owned = false;
28114         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
28115         return ret_conv;
28116 }
28117
28118 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) {
28119         LDKChannelHandshakeLimits this_ptr_conv;
28120         this_ptr_conv.inner = untag_ptr(this_ptr);
28121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28123         this_ptr_conv.is_owned = false;
28124         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
28125 }
28126
28127 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) {
28128         LDKChannelHandshakeLimits this_ptr_conv;
28129         this_ptr_conv.inner = untag_ptr(this_ptr);
28130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28132         this_ptr_conv.is_owned = false;
28133         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
28134         return ret_conv;
28135 }
28136
28137 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) {
28138         LDKChannelHandshakeLimits this_ptr_conv;
28139         this_ptr_conv.inner = untag_ptr(this_ptr);
28140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28142         this_ptr_conv.is_owned = false;
28143         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28144 }
28145
28146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28147         LDKChannelHandshakeLimits this_ptr_conv;
28148         this_ptr_conv.inner = untag_ptr(this_ptr);
28149         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28151         this_ptr_conv.is_owned = false;
28152         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
28153         return ret_conv;
28154 }
28155
28156 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) {
28157         LDKChannelHandshakeLimits this_ptr_conv;
28158         this_ptr_conv.inner = untag_ptr(this_ptr);
28159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28161         this_ptr_conv.is_owned = false;
28162         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
28163 }
28164
28165 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28166         LDKChannelHandshakeLimits this_ptr_conv;
28167         this_ptr_conv.inner = untag_ptr(this_ptr);
28168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28170         this_ptr_conv.is_owned = false;
28171         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
28172         return ret_conv;
28173 }
28174
28175 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) {
28176         LDKChannelHandshakeLimits this_ptr_conv;
28177         this_ptr_conv.inner = untag_ptr(this_ptr);
28178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28180         this_ptr_conv.is_owned = false;
28181         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
28182 }
28183
28184 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28185         LDKChannelHandshakeLimits this_ptr_conv;
28186         this_ptr_conv.inner = untag_ptr(this_ptr);
28187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28189         this_ptr_conv.is_owned = false;
28190         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
28191         return ret_conv;
28192 }
28193
28194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28195         LDKChannelHandshakeLimits this_ptr_conv;
28196         this_ptr_conv.inner = untag_ptr(this_ptr);
28197         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28199         this_ptr_conv.is_owned = false;
28200         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
28201 }
28202
28203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
28204         LDKChannelHandshakeLimits this_ptr_conv;
28205         this_ptr_conv.inner = untag_ptr(this_ptr);
28206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28208         this_ptr_conv.is_owned = false;
28209         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
28210         return ret_conv;
28211 }
28212
28213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28214         LDKChannelHandshakeLimits this_ptr_conv;
28215         this_ptr_conv.inner = untag_ptr(this_ptr);
28216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28218         this_ptr_conv.is_owned = false;
28219         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
28220 }
28221
28222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
28223         LDKChannelHandshakeLimits this_ptr_conv;
28224         this_ptr_conv.inner = untag_ptr(this_ptr);
28225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28227         this_ptr_conv.is_owned = false;
28228         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
28229         return ret_conv;
28230 }
28231
28232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28233         LDKChannelHandshakeLimits this_ptr_conv;
28234         this_ptr_conv.inner = untag_ptr(this_ptr);
28235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28237         this_ptr_conv.is_owned = false;
28238         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
28239 }
28240
28241 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28242         LDKChannelHandshakeLimits this_ptr_conv;
28243         this_ptr_conv.inner = untag_ptr(this_ptr);
28244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28246         this_ptr_conv.is_owned = false;
28247         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
28248         return ret_conv;
28249 }
28250
28251 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) {
28252         LDKChannelHandshakeLimits this_ptr_conv;
28253         this_ptr_conv.inner = untag_ptr(this_ptr);
28254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28256         this_ptr_conv.is_owned = false;
28257         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
28258 }
28259
28260 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) {
28261         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);
28262         int64_t ret_ref = 0;
28263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28265         return ret_ref;
28266 }
28267
28268 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
28269         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
28270         int64_t ret_ref = 0;
28271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28273         return ret_ref;
28274 }
28275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28276         LDKChannelHandshakeLimits arg_conv;
28277         arg_conv.inner = untag_ptr(arg);
28278         arg_conv.is_owned = ptr_is_owned(arg);
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28280         arg_conv.is_owned = false;
28281         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
28282         return ret_conv;
28283 }
28284
28285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28286         LDKChannelHandshakeLimits orig_conv;
28287         orig_conv.inner = untag_ptr(orig);
28288         orig_conv.is_owned = ptr_is_owned(orig);
28289         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28290         orig_conv.is_owned = false;
28291         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
28292         int64_t ret_ref = 0;
28293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28295         return ret_ref;
28296 }
28297
28298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
28299         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
28300         int64_t ret_ref = 0;
28301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28303         return ret_ref;
28304 }
28305
28306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28307         LDKChannelConfig this_obj_conv;
28308         this_obj_conv.inner = untag_ptr(this_obj);
28309         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28311         ChannelConfig_free(this_obj_conv);
28312 }
28313
28314 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28315         LDKChannelConfig this_ptr_conv;
28316         this_ptr_conv.inner = untag_ptr(this_ptr);
28317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28319         this_ptr_conv.is_owned = false;
28320         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28321         return ret_conv;
28322 }
28323
28324 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) {
28325         LDKChannelConfig this_ptr_conv;
28326         this_ptr_conv.inner = untag_ptr(this_ptr);
28327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28329         this_ptr_conv.is_owned = false;
28330         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28331 }
28332
28333 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28334         LDKChannelConfig this_ptr_conv;
28335         this_ptr_conv.inner = untag_ptr(this_ptr);
28336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28338         this_ptr_conv.is_owned = false;
28339         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28340         return ret_conv;
28341 }
28342
28343 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) {
28344         LDKChannelConfig this_ptr_conv;
28345         this_ptr_conv.inner = untag_ptr(this_ptr);
28346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28348         this_ptr_conv.is_owned = false;
28349         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28350 }
28351
28352 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28353         LDKChannelConfig this_ptr_conv;
28354         this_ptr_conv.inner = untag_ptr(this_ptr);
28355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28357         this_ptr_conv.is_owned = false;
28358         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28359         return ret_conv;
28360 }
28361
28362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28363         LDKChannelConfig this_ptr_conv;
28364         this_ptr_conv.inner = untag_ptr(this_ptr);
28365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28367         this_ptr_conv.is_owned = false;
28368         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28369 }
28370
28371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28372         LDKChannelConfig this_ptr_conv;
28373         this_ptr_conv.inner = untag_ptr(this_ptr);
28374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28376         this_ptr_conv.is_owned = false;
28377         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28378         return ret_conv;
28379 }
28380
28381 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) {
28382         LDKChannelConfig this_ptr_conv;
28383         this_ptr_conv.inner = untag_ptr(this_ptr);
28384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28386         this_ptr_conv.is_owned = false;
28387         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28388 }
28389
28390 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) {
28391         LDKChannelConfig this_ptr_conv;
28392         this_ptr_conv.inner = untag_ptr(this_ptr);
28393         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28395         this_ptr_conv.is_owned = false;
28396         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28397         return ret_conv;
28398 }
28399
28400 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) {
28401         LDKChannelConfig this_ptr_conv;
28402         this_ptr_conv.inner = untag_ptr(this_ptr);
28403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28405         this_ptr_conv.is_owned = false;
28406         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28407 }
28408
28409 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) {
28410         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);
28411         int64_t ret_ref = 0;
28412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28413         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28414         return ret_ref;
28415 }
28416
28417 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28418         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28419         int64_t ret_ref = 0;
28420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28422         return ret_ref;
28423 }
28424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28425         LDKChannelConfig arg_conv;
28426         arg_conv.inner = untag_ptr(arg);
28427         arg_conv.is_owned = ptr_is_owned(arg);
28428         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28429         arg_conv.is_owned = false;
28430         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28431         return ret_conv;
28432 }
28433
28434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28435         LDKChannelConfig orig_conv;
28436         orig_conv.inner = untag_ptr(orig);
28437         orig_conv.is_owned = ptr_is_owned(orig);
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28439         orig_conv.is_owned = false;
28440         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28441         int64_t ret_ref = 0;
28442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28444         return ret_ref;
28445 }
28446
28447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28448         LDKChannelConfig a_conv;
28449         a_conv.inner = untag_ptr(a);
28450         a_conv.is_owned = ptr_is_owned(a);
28451         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28452         a_conv.is_owned = false;
28453         LDKChannelConfig b_conv;
28454         b_conv.inner = untag_ptr(b);
28455         b_conv.is_owned = ptr_is_owned(b);
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28457         b_conv.is_owned = false;
28458         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28459         return ret_conv;
28460 }
28461
28462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28463         LDKChannelConfig ret_var = ChannelConfig_default();
28464         int64_t ret_ref = 0;
28465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28467         return ret_ref;
28468 }
28469
28470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28471         LDKChannelConfig obj_conv;
28472         obj_conv.inner = untag_ptr(obj);
28473         obj_conv.is_owned = ptr_is_owned(obj);
28474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28475         obj_conv.is_owned = false;
28476         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28479         CVec_u8Z_free(ret_var);
28480         return ret_arr;
28481 }
28482
28483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28484         LDKu8slice ser_ref;
28485         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28486         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28487         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28488         *ret_conv = ChannelConfig_read(ser_ref);
28489         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28490         return tag_ptr(ret_conv, true);
28491 }
28492
28493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28494         LDKUserConfig this_obj_conv;
28495         this_obj_conv.inner = untag_ptr(this_obj);
28496         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28498         UserConfig_free(this_obj_conv);
28499 }
28500
28501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28502         LDKUserConfig this_ptr_conv;
28503         this_ptr_conv.inner = untag_ptr(this_ptr);
28504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28506         this_ptr_conv.is_owned = false;
28507         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28508         int64_t ret_ref = 0;
28509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28511         return ret_ref;
28512 }
28513
28514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28515         LDKUserConfig this_ptr_conv;
28516         this_ptr_conv.inner = untag_ptr(this_ptr);
28517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28519         this_ptr_conv.is_owned = false;
28520         LDKChannelHandshakeConfig val_conv;
28521         val_conv.inner = untag_ptr(val);
28522         val_conv.is_owned = ptr_is_owned(val);
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28524         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28525         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28526 }
28527
28528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28529         LDKUserConfig this_ptr_conv;
28530         this_ptr_conv.inner = untag_ptr(this_ptr);
28531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28533         this_ptr_conv.is_owned = false;
28534         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28535         int64_t ret_ref = 0;
28536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28538         return ret_ref;
28539 }
28540
28541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28542         LDKUserConfig this_ptr_conv;
28543         this_ptr_conv.inner = untag_ptr(this_ptr);
28544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28546         this_ptr_conv.is_owned = false;
28547         LDKChannelHandshakeLimits val_conv;
28548         val_conv.inner = untag_ptr(val);
28549         val_conv.is_owned = ptr_is_owned(val);
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28551         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28552         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28553 }
28554
28555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28556         LDKUserConfig this_ptr_conv;
28557         this_ptr_conv.inner = untag_ptr(this_ptr);
28558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28560         this_ptr_conv.is_owned = false;
28561         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28562         int64_t ret_ref = 0;
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28565         return ret_ref;
28566 }
28567
28568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28569         LDKUserConfig this_ptr_conv;
28570         this_ptr_conv.inner = untag_ptr(this_ptr);
28571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28573         this_ptr_conv.is_owned = false;
28574         LDKChannelConfig val_conv;
28575         val_conv.inner = untag_ptr(val);
28576         val_conv.is_owned = ptr_is_owned(val);
28577         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28578         val_conv = ChannelConfig_clone(&val_conv);
28579         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28580 }
28581
28582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28583         LDKUserConfig this_ptr_conv;
28584         this_ptr_conv.inner = untag_ptr(this_ptr);
28585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28587         this_ptr_conv.is_owned = false;
28588         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28589         return ret_conv;
28590 }
28591
28592 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) {
28593         LDKUserConfig this_ptr_conv;
28594         this_ptr_conv.inner = untag_ptr(this_ptr);
28595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28597         this_ptr_conv.is_owned = false;
28598         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28599 }
28600
28601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28602         LDKUserConfig this_ptr_conv;
28603         this_ptr_conv.inner = untag_ptr(this_ptr);
28604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28606         this_ptr_conv.is_owned = false;
28607         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28608         return ret_conv;
28609 }
28610
28611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28612         LDKUserConfig this_ptr_conv;
28613         this_ptr_conv.inner = untag_ptr(this_ptr);
28614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28616         this_ptr_conv.is_owned = false;
28617         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28618 }
28619
28620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28621         LDKUserConfig this_ptr_conv;
28622         this_ptr_conv.inner = untag_ptr(this_ptr);
28623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28625         this_ptr_conv.is_owned = false;
28626         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28627         return ret_conv;
28628 }
28629
28630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28631         LDKUserConfig this_ptr_conv;
28632         this_ptr_conv.inner = untag_ptr(this_ptr);
28633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28635         this_ptr_conv.is_owned = false;
28636         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28637 }
28638
28639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28640         LDKUserConfig this_ptr_conv;
28641         this_ptr_conv.inner = untag_ptr(this_ptr);
28642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28644         this_ptr_conv.is_owned = false;
28645         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28646         return ret_conv;
28647 }
28648
28649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28650         LDKUserConfig this_ptr_conv;
28651         this_ptr_conv.inner = untag_ptr(this_ptr);
28652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28654         this_ptr_conv.is_owned = false;
28655         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28656 }
28657
28658 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) {
28659         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28660         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28661         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28663         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28664         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28665         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28666         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28667         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28668         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28669         LDKChannelConfig channel_config_arg_conv;
28670         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28671         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28672         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28673         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28674         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);
28675         int64_t ret_ref = 0;
28676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28678         return ret_ref;
28679 }
28680
28681 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28682         LDKUserConfig ret_var = UserConfig_clone(arg);
28683         int64_t ret_ref = 0;
28684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28686         return ret_ref;
28687 }
28688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28689         LDKUserConfig arg_conv;
28690         arg_conv.inner = untag_ptr(arg);
28691         arg_conv.is_owned = ptr_is_owned(arg);
28692         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28693         arg_conv.is_owned = false;
28694         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28695         return ret_conv;
28696 }
28697
28698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28699         LDKUserConfig orig_conv;
28700         orig_conv.inner = untag_ptr(orig);
28701         orig_conv.is_owned = ptr_is_owned(orig);
28702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28703         orig_conv.is_owned = false;
28704         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28705         int64_t ret_ref = 0;
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28708         return ret_ref;
28709 }
28710
28711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28712         LDKUserConfig ret_var = UserConfig_default();
28713         int64_t ret_ref = 0;
28714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28716         return ret_ref;
28717 }
28718
28719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28720         LDKBestBlock this_obj_conv;
28721         this_obj_conv.inner = untag_ptr(this_obj);
28722         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28724         BestBlock_free(this_obj_conv);
28725 }
28726
28727 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28728         LDKBestBlock ret_var = BestBlock_clone(arg);
28729         int64_t ret_ref = 0;
28730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28732         return ret_ref;
28733 }
28734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28735         LDKBestBlock arg_conv;
28736         arg_conv.inner = untag_ptr(arg);
28737         arg_conv.is_owned = ptr_is_owned(arg);
28738         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28739         arg_conv.is_owned = false;
28740         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28741         return ret_conv;
28742 }
28743
28744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28745         LDKBestBlock orig_conv;
28746         orig_conv.inner = untag_ptr(orig);
28747         orig_conv.is_owned = ptr_is_owned(orig);
28748         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28749         orig_conv.is_owned = false;
28750         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28751         int64_t ret_ref = 0;
28752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28754         return ret_ref;
28755 }
28756
28757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28758         LDKBestBlock a_conv;
28759         a_conv.inner = untag_ptr(a);
28760         a_conv.is_owned = ptr_is_owned(a);
28761         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28762         a_conv.is_owned = false;
28763         LDKBestBlock b_conv;
28764         b_conv.inner = untag_ptr(b);
28765         b_conv.is_owned = ptr_is_owned(b);
28766         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28767         b_conv.is_owned = false;
28768         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28769         return ret_conv;
28770 }
28771
28772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1network(JNIEnv *env, jclass clz, jclass network) {
28773         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28774         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
28775         int64_t ret_ref = 0;
28776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28778         return ret_ref;
28779 }
28780
28781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28782         LDKThirtyTwoBytes block_hash_ref;
28783         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28784         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28785         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28786         int64_t ret_ref = 0;
28787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28788         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28789         return ret_ref;
28790 }
28791
28792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28793         LDKBestBlock this_arg_conv;
28794         this_arg_conv.inner = untag_ptr(this_arg);
28795         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28797         this_arg_conv.is_owned = false;
28798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28800         return ret_arr;
28801 }
28802
28803 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28804         LDKBestBlock this_arg_conv;
28805         this_arg_conv.inner = untag_ptr(this_arg);
28806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28808         this_arg_conv.is_owned = false;
28809         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28810         return ret_conv;
28811 }
28812
28813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28814         if (!ptr_is_owned(this_ptr)) return;
28815         void* this_ptr_ptr = untag_ptr(this_ptr);
28816         CHECK_ACCESS(this_ptr_ptr);
28817         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28818         FREE(untag_ptr(this_ptr));
28819         Listen_free(this_ptr_conv);
28820 }
28821
28822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28823         if (!ptr_is_owned(this_ptr)) return;
28824         void* this_ptr_ptr = untag_ptr(this_ptr);
28825         CHECK_ACCESS(this_ptr_ptr);
28826         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28827         FREE(untag_ptr(this_ptr));
28828         Confirm_free(this_ptr_conv);
28829 }
28830
28831 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28832         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28833         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28834         return ret_conv;
28835 }
28836
28837 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28838         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28839         return ret_conv;
28840 }
28841
28842 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28843         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28844         return ret_conv;
28845 }
28846
28847 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28848         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28849         return ret_conv;
28850 }
28851
28852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28853         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28854         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28855         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28856         return ret_conv;
28857 }
28858
28859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28860         if (!ptr_is_owned(this_ptr)) return;
28861         void* this_ptr_ptr = untag_ptr(this_ptr);
28862         CHECK_ACCESS(this_ptr_ptr);
28863         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28864         FREE(untag_ptr(this_ptr));
28865         Watch_free(this_ptr_conv);
28866 }
28867
28868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28869         if (!ptr_is_owned(this_ptr)) return;
28870         void* this_ptr_ptr = untag_ptr(this_ptr);
28871         CHECK_ACCESS(this_ptr_ptr);
28872         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28873         FREE(untag_ptr(this_ptr));
28874         Filter_free(this_ptr_conv);
28875 }
28876
28877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28878         LDKWatchedOutput this_obj_conv;
28879         this_obj_conv.inner = untag_ptr(this_obj);
28880         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28882         WatchedOutput_free(this_obj_conv);
28883 }
28884
28885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28886         LDKWatchedOutput this_ptr_conv;
28887         this_ptr_conv.inner = untag_ptr(this_ptr);
28888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28890         this_ptr_conv.is_owned = false;
28891         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28893         return ret_arr;
28894 }
28895
28896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28897         LDKWatchedOutput this_ptr_conv;
28898         this_ptr_conv.inner = untag_ptr(this_ptr);
28899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28901         this_ptr_conv.is_owned = false;
28902         LDKThirtyTwoBytes val_ref;
28903         CHECK((*env)->GetArrayLength(env, val) == 32);
28904         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28905         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28906 }
28907
28908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28909         LDKWatchedOutput this_ptr_conv;
28910         this_ptr_conv.inner = untag_ptr(this_ptr);
28911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28913         this_ptr_conv.is_owned = false;
28914         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28915         int64_t ret_ref = 0;
28916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28918         return ret_ref;
28919 }
28920
28921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28922         LDKWatchedOutput this_ptr_conv;
28923         this_ptr_conv.inner = untag_ptr(this_ptr);
28924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28926         this_ptr_conv.is_owned = false;
28927         LDKOutPoint val_conv;
28928         val_conv.inner = untag_ptr(val);
28929         val_conv.is_owned = ptr_is_owned(val);
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28931         val_conv = OutPoint_clone(&val_conv);
28932         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28933 }
28934
28935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28936         LDKWatchedOutput this_ptr_conv;
28937         this_ptr_conv.inner = untag_ptr(this_ptr);
28938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28940         this_ptr_conv.is_owned = false;
28941         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28944         return ret_arr;
28945 }
28946
28947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28948         LDKWatchedOutput this_ptr_conv;
28949         this_ptr_conv.inner = untag_ptr(this_ptr);
28950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28952         this_ptr_conv.is_owned = false;
28953         LDKCVec_u8Z val_ref;
28954         val_ref.datalen = (*env)->GetArrayLength(env, val);
28955         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28956         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28957         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28958 }
28959
28960 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) {
28961         LDKThirtyTwoBytes block_hash_arg_ref;
28962         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28963         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28964         LDKOutPoint outpoint_arg_conv;
28965         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28966         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28968         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28969         LDKCVec_u8Z script_pubkey_arg_ref;
28970         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28971         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28972         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28973         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28974         int64_t ret_ref = 0;
28975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28977         return ret_ref;
28978 }
28979
28980 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
28981         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
28982         int64_t ret_ref = 0;
28983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28985         return ret_ref;
28986 }
28987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28988         LDKWatchedOutput arg_conv;
28989         arg_conv.inner = untag_ptr(arg);
28990         arg_conv.is_owned = ptr_is_owned(arg);
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28992         arg_conv.is_owned = false;
28993         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
28994         return ret_conv;
28995 }
28996
28997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28998         LDKWatchedOutput orig_conv;
28999         orig_conv.inner = untag_ptr(orig);
29000         orig_conv.is_owned = ptr_is_owned(orig);
29001         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29002         orig_conv.is_owned = false;
29003         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
29004         int64_t ret_ref = 0;
29005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29006         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29007         return ret_ref;
29008 }
29009
29010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29011         LDKWatchedOutput a_conv;
29012         a_conv.inner = untag_ptr(a);
29013         a_conv.is_owned = ptr_is_owned(a);
29014         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29015         a_conv.is_owned = false;
29016         LDKWatchedOutput b_conv;
29017         b_conv.inner = untag_ptr(b);
29018         b_conv.is_owned = ptr_is_owned(b);
29019         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29020         b_conv.is_owned = false;
29021         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
29022         return ret_conv;
29023 }
29024
29025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
29026         LDKWatchedOutput o_conv;
29027         o_conv.inner = untag_ptr(o);
29028         o_conv.is_owned = ptr_is_owned(o);
29029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29030         o_conv.is_owned = false;
29031         int64_t ret_conv = WatchedOutput_hash(&o_conv);
29032         return ret_conv;
29033 }
29034
29035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29036         if (!ptr_is_owned(this_ptr)) return;
29037         void* this_ptr_ptr = untag_ptr(this_ptr);
29038         CHECK_ACCESS(this_ptr_ptr);
29039         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
29040         FREE(untag_ptr(this_ptr));
29041         BroadcasterInterface_free(this_ptr_conv);
29042 }
29043
29044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29045         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
29046         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
29047         return ret_conv;
29048 }
29049
29050 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
29051         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
29052         return ret_conv;
29053 }
29054
29055 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
29056         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
29057         return ret_conv;
29058 }
29059
29060 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
29061         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
29062         return ret_conv;
29063 }
29064
29065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
29066         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
29067         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
29068         return ret_conv;
29069 }
29070
29071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29072         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
29073         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
29074         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
29075         return ret_conv;
29076 }
29077
29078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29079         if (!ptr_is_owned(this_ptr)) return;
29080         void* this_ptr_ptr = untag_ptr(this_ptr);
29081         CHECK_ACCESS(this_ptr_ptr);
29082         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
29083         FREE(untag_ptr(this_ptr));
29084         FeeEstimator_free(this_ptr_conv);
29085 }
29086
29087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29088         LDKMonitorUpdateId this_obj_conv;
29089         this_obj_conv.inner = untag_ptr(this_obj);
29090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29092         MonitorUpdateId_free(this_obj_conv);
29093 }
29094
29095 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
29096         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
29097         int64_t ret_ref = 0;
29098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29100         return ret_ref;
29101 }
29102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29103         LDKMonitorUpdateId arg_conv;
29104         arg_conv.inner = untag_ptr(arg);
29105         arg_conv.is_owned = ptr_is_owned(arg);
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29107         arg_conv.is_owned = false;
29108         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
29109         return ret_conv;
29110 }
29111
29112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29113         LDKMonitorUpdateId orig_conv;
29114         orig_conv.inner = untag_ptr(orig);
29115         orig_conv.is_owned = ptr_is_owned(orig);
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29117         orig_conv.is_owned = false;
29118         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
29119         int64_t ret_ref = 0;
29120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29122         return ret_ref;
29123 }
29124
29125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29126         LDKMonitorUpdateId o_conv;
29127         o_conv.inner = untag_ptr(o);
29128         o_conv.is_owned = ptr_is_owned(o);
29129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29130         o_conv.is_owned = false;
29131         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
29132         return ret_conv;
29133 }
29134
29135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29136         LDKMonitorUpdateId a_conv;
29137         a_conv.inner = untag_ptr(a);
29138         a_conv.is_owned = ptr_is_owned(a);
29139         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29140         a_conv.is_owned = false;
29141         LDKMonitorUpdateId b_conv;
29142         b_conv.inner = untag_ptr(b);
29143         b_conv.is_owned = ptr_is_owned(b);
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29145         b_conv.is_owned = false;
29146         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
29147         return ret_conv;
29148 }
29149
29150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29151         if (!ptr_is_owned(this_ptr)) return;
29152         void* this_ptr_ptr = untag_ptr(this_ptr);
29153         CHECK_ACCESS(this_ptr_ptr);
29154         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
29155         FREE(untag_ptr(this_ptr));
29156         Persist_free(this_ptr_conv);
29157 }
29158
29159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29160         LDKLockedChannelMonitor this_obj_conv;
29161         this_obj_conv.inner = untag_ptr(this_obj);
29162         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29164         LockedChannelMonitor_free(this_obj_conv);
29165 }
29166
29167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29168         LDKChainMonitor this_obj_conv;
29169         this_obj_conv.inner = untag_ptr(this_obj);
29170         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29172         ChainMonitor_free(this_obj_conv);
29173 }
29174
29175 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) {
29176         void* chain_source_ptr = untag_ptr(chain_source);
29177         CHECK_ACCESS(chain_source_ptr);
29178         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
29179         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
29180         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
29181                 // Manually implement clone for Java trait instances
29182                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
29183                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29184                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
29185                 }
29186         }
29187         void* broadcaster_ptr = untag_ptr(broadcaster);
29188         CHECK_ACCESS(broadcaster_ptr);
29189         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29190         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29192                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29193         }
29194         void* logger_ptr = untag_ptr(logger);
29195         CHECK_ACCESS(logger_ptr);
29196         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29197         if (logger_conv.free == LDKLogger_JCalls_free) {
29198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29199                 LDKLogger_JCalls_cloned(&logger_conv);
29200         }
29201         void* feeest_ptr = untag_ptr(feeest);
29202         CHECK_ACCESS(feeest_ptr);
29203         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
29204         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
29205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29206                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
29207         }
29208         void* persister_ptr = untag_ptr(persister);
29209         CHECK_ACCESS(persister_ptr);
29210         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
29211         if (persister_conv.free == LDKPersist_JCalls_free) {
29212                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29213                 LDKPersist_JCalls_cloned(&persister_conv);
29214         }
29215         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
29216         int64_t ret_ref = 0;
29217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29219         return ret_ref;
29220 }
29221
29222 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) {
29223         LDKChainMonitor this_arg_conv;
29224         this_arg_conv.inner = untag_ptr(this_arg);
29225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29227         this_arg_conv.is_owned = false;
29228         LDKCVec_ChannelDetailsZ ignored_channels_constr;
29229         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
29230         if (ignored_channels_constr.datalen > 0)
29231                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29232         else
29233                 ignored_channels_constr.data = NULL;
29234         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
29235         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
29236                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
29237                 LDKChannelDetails ignored_channels_conv_16_conv;
29238                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
29239                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
29240                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
29241                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
29242                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
29243         }
29244         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
29245         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
29246         int64_tArray ret_arr = NULL;
29247         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29248         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29249         for (size_t j = 0; j < ret_var.datalen; j++) {
29250                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29251                 *ret_conv_9_copy = ret_var.data[j];
29252                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29253                 ret_arr_ptr[j] = ret_conv_9_ref;
29254         }
29255         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29256         FREE(ret_var.data);
29257         return ret_arr;
29258 }
29259
29260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
29261         LDKChainMonitor this_arg_conv;
29262         this_arg_conv.inner = untag_ptr(this_arg);
29263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29265         this_arg_conv.is_owned = false;
29266         LDKOutPoint funding_txo_conv;
29267         funding_txo_conv.inner = untag_ptr(funding_txo);
29268         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29269         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29270         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29271         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29272         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
29273         return tag_ptr(ret_conv, true);
29274 }
29275
29276 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
29277         LDKChainMonitor this_arg_conv;
29278         this_arg_conv.inner = untag_ptr(this_arg);
29279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29281         this_arg_conv.is_owned = false;
29282         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
29283         int64_tArray ret_arr = NULL;
29284         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29285         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29286         for (size_t k = 0; k < ret_var.datalen; k++) {
29287                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29288                 int64_t ret_conv_10_ref = 0;
29289                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29290                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29291                 ret_arr_ptr[k] = ret_conv_10_ref;
29292         }
29293         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29294         FREE(ret_var.data);
29295         return ret_arr;
29296 }
29297
29298 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29299         LDKChainMonitor this_arg_conv;
29300         this_arg_conv.inner = untag_ptr(this_arg);
29301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29303         this_arg_conv.is_owned = false;
29304         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29305         int64_tArray ret_arr = NULL;
29306         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29307         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29308         for (size_t p = 0; p < ret_var.datalen; p++) {
29309                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29310                 *ret_conv_41_conv = ret_var.data[p];
29311                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
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_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) {
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         LDKOutPoint funding_txo_conv;
29325         funding_txo_conv.inner = untag_ptr(funding_txo);
29326         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29327         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29328         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29329         LDKMonitorUpdateId completed_update_id_conv;
29330         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29331         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29333         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29334         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29335         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29336         return tag_ptr(ret_conv, true);
29337 }
29338
29339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
29340         LDKChainMonitor this_arg_conv;
29341         this_arg_conv.inner = untag_ptr(this_arg);
29342         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29344         this_arg_conv.is_owned = false;
29345         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
29346         int64_t ret_ref = 0;
29347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29349         return ret_ref;
29350 }
29351
29352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg) {
29353         LDKChainMonitor this_arg_conv;
29354         this_arg_conv.inner = untag_ptr(this_arg);
29355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29357         this_arg_conv.is_owned = false;
29358         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
29359 }
29360
29361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29362         LDKChainMonitor this_arg_conv;
29363         this_arg_conv.inner = untag_ptr(this_arg);
29364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29366         this_arg_conv.is_owned = false;
29367         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29368         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29369         return tag_ptr(ret_ret, true);
29370 }
29371
29372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(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         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29379         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29380         return tag_ptr(ret_ret, true);
29381 }
29382
29383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29384         LDKChainMonitor this_arg_conv;
29385         this_arg_conv.inner = untag_ptr(this_arg);
29386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29388         this_arg_conv.is_owned = false;
29389         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29390         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29391         return tag_ptr(ret_ret, true);
29392 }
29393
29394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29395         LDKChainMonitor this_arg_conv;
29396         this_arg_conv.inner = untag_ptr(this_arg);
29397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29399         this_arg_conv.is_owned = false;
29400         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29401         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29402         return tag_ptr(ret_ret, true);
29403 }
29404
29405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29406         LDKChannelMonitorUpdate this_obj_conv;
29407         this_obj_conv.inner = untag_ptr(this_obj);
29408         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29410         ChannelMonitorUpdate_free(this_obj_conv);
29411 }
29412
29413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29414         LDKChannelMonitorUpdate this_ptr_conv;
29415         this_ptr_conv.inner = untag_ptr(this_ptr);
29416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29418         this_ptr_conv.is_owned = false;
29419         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29420         return ret_conv;
29421 }
29422
29423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29424         LDKChannelMonitorUpdate this_ptr_conv;
29425         this_ptr_conv.inner = untag_ptr(this_ptr);
29426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29428         this_ptr_conv.is_owned = false;
29429         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29430 }
29431
29432 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29433         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29434         int64_t ret_ref = 0;
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29437         return ret_ref;
29438 }
29439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29440         LDKChannelMonitorUpdate arg_conv;
29441         arg_conv.inner = untag_ptr(arg);
29442         arg_conv.is_owned = ptr_is_owned(arg);
29443         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29444         arg_conv.is_owned = false;
29445         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29446         return ret_conv;
29447 }
29448
29449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29450         LDKChannelMonitorUpdate orig_conv;
29451         orig_conv.inner = untag_ptr(orig);
29452         orig_conv.is_owned = ptr_is_owned(orig);
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29454         orig_conv.is_owned = false;
29455         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29456         int64_t ret_ref = 0;
29457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29458         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29459         return ret_ref;
29460 }
29461
29462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29463         LDKChannelMonitorUpdate a_conv;
29464         a_conv.inner = untag_ptr(a);
29465         a_conv.is_owned = ptr_is_owned(a);
29466         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29467         a_conv.is_owned = false;
29468         LDKChannelMonitorUpdate b_conv;
29469         b_conv.inner = untag_ptr(b);
29470         b_conv.is_owned = ptr_is_owned(b);
29471         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29472         b_conv.is_owned = false;
29473         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
29474         return ret_conv;
29475 }
29476
29477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29478         LDKChannelMonitorUpdate obj_conv;
29479         obj_conv.inner = untag_ptr(obj);
29480         obj_conv.is_owned = ptr_is_owned(obj);
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29482         obj_conv.is_owned = false;
29483         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29486         CVec_u8Z_free(ret_var);
29487         return ret_arr;
29488 }
29489
29490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29491         LDKu8slice ser_ref;
29492         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29493         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29494         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29495         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29496         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29497         return tag_ptr(ret_conv, true);
29498 }
29499
29500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29501         if (!ptr_is_owned(this_ptr)) return;
29502         void* this_ptr_ptr = untag_ptr(this_ptr);
29503         CHECK_ACCESS(this_ptr_ptr);
29504         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29505         FREE(untag_ptr(this_ptr));
29506         MonitorEvent_free(this_ptr_conv);
29507 }
29508
29509 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29510         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29511         *ret_copy = MonitorEvent_clone(arg);
29512         int64_t ret_ref = tag_ptr(ret_copy, true);
29513         return ret_ref;
29514 }
29515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29516         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29517         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29518         return ret_conv;
29519 }
29520
29521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29522         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29523         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29524         *ret_copy = MonitorEvent_clone(orig_conv);
29525         int64_t ret_ref = tag_ptr(ret_copy, true);
29526         return ret_ref;
29527 }
29528
29529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29530         LDKHTLCUpdate a_conv;
29531         a_conv.inner = untag_ptr(a);
29532         a_conv.is_owned = ptr_is_owned(a);
29533         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29534         a_conv = HTLCUpdate_clone(&a_conv);
29535         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29536         *ret_copy = MonitorEvent_htlcevent(a_conv);
29537         int64_t ret_ref = tag_ptr(ret_copy, true);
29538         return ret_ref;
29539 }
29540
29541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29542         LDKOutPoint a_conv;
29543         a_conv.inner = untag_ptr(a);
29544         a_conv.is_owned = ptr_is_owned(a);
29545         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29546         a_conv = OutPoint_clone(&a_conv);
29547         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29548         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29549         int64_t ret_ref = tag_ptr(ret_copy, true);
29550         return ret_ref;
29551 }
29552
29553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29554         LDKOutPoint funding_txo_conv;
29555         funding_txo_conv.inner = untag_ptr(funding_txo);
29556         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29558         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29559         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29560         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29561         int64_t ret_ref = tag_ptr(ret_copy, true);
29562         return ret_ref;
29563 }
29564
29565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29566         LDKOutPoint a_conv;
29567         a_conv.inner = untag_ptr(a);
29568         a_conv.is_owned = ptr_is_owned(a);
29569         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29570         a_conv = OutPoint_clone(&a_conv);
29571         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29572         *ret_copy = MonitorEvent_update_failed(a_conv);
29573         int64_t ret_ref = tag_ptr(ret_copy, true);
29574         return ret_ref;
29575 }
29576
29577 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29578         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29579         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29580         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29581         return ret_conv;
29582 }
29583
29584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29585         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29586         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29589         CVec_u8Z_free(ret_var);
29590         return ret_arr;
29591 }
29592
29593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29594         LDKu8slice ser_ref;
29595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29597         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29598         *ret_conv = MonitorEvent_read(ser_ref);
29599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29600         return tag_ptr(ret_conv, true);
29601 }
29602
29603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29604         LDKHTLCUpdate this_obj_conv;
29605         this_obj_conv.inner = untag_ptr(this_obj);
29606         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29608         HTLCUpdate_free(this_obj_conv);
29609 }
29610
29611 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29612         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29613         int64_t ret_ref = 0;
29614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29616         return ret_ref;
29617 }
29618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29619         LDKHTLCUpdate arg_conv;
29620         arg_conv.inner = untag_ptr(arg);
29621         arg_conv.is_owned = ptr_is_owned(arg);
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29623         arg_conv.is_owned = false;
29624         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29625         return ret_conv;
29626 }
29627
29628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29629         LDKHTLCUpdate orig_conv;
29630         orig_conv.inner = untag_ptr(orig);
29631         orig_conv.is_owned = ptr_is_owned(orig);
29632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29633         orig_conv.is_owned = false;
29634         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29635         int64_t ret_ref = 0;
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29638         return ret_ref;
29639 }
29640
29641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29642         LDKHTLCUpdate a_conv;
29643         a_conv.inner = untag_ptr(a);
29644         a_conv.is_owned = ptr_is_owned(a);
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29646         a_conv.is_owned = false;
29647         LDKHTLCUpdate b_conv;
29648         b_conv.inner = untag_ptr(b);
29649         b_conv.is_owned = ptr_is_owned(b);
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29651         b_conv.is_owned = false;
29652         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29653         return ret_conv;
29654 }
29655
29656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29657         LDKHTLCUpdate obj_conv;
29658         obj_conv.inner = untag_ptr(obj);
29659         obj_conv.is_owned = ptr_is_owned(obj);
29660         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29661         obj_conv.is_owned = false;
29662         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29663         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29664         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29665         CVec_u8Z_free(ret_var);
29666         return ret_arr;
29667 }
29668
29669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29670         LDKu8slice ser_ref;
29671         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29672         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29673         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29674         *ret_conv = HTLCUpdate_read(ser_ref);
29675         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29676         return tag_ptr(ret_conv, true);
29677 }
29678
29679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29680         if (!ptr_is_owned(this_ptr)) return;
29681         void* this_ptr_ptr = untag_ptr(this_ptr);
29682         CHECK_ACCESS(this_ptr_ptr);
29683         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29684         FREE(untag_ptr(this_ptr));
29685         Balance_free(this_ptr_conv);
29686 }
29687
29688 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29689         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29690         *ret_copy = Balance_clone(arg);
29691         int64_t ret_ref = tag_ptr(ret_copy, true);
29692         return ret_ref;
29693 }
29694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29695         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29696         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29697         return ret_conv;
29698 }
29699
29700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29701         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29702         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29703         *ret_copy = Balance_clone(orig_conv);
29704         int64_t ret_ref = tag_ptr(ret_copy, true);
29705         return ret_ref;
29706 }
29707
29708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29709         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29710         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29711         int64_t ret_ref = tag_ptr(ret_copy, true);
29712         return ret_ref;
29713 }
29714
29715 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) {
29716         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29717         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29718         int64_t ret_ref = tag_ptr(ret_copy, true);
29719         return ret_ref;
29720 }
29721
29722 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) {
29723         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29724         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29725         int64_t ret_ref = tag_ptr(ret_copy, true);
29726         return ret_ref;
29727 }
29728
29729 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) {
29730         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29731         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29732         int64_t ret_ref = tag_ptr(ret_copy, true);
29733         return ret_ref;
29734 }
29735
29736 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) {
29737         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29738         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29739         int64_t ret_ref = tag_ptr(ret_copy, true);
29740         return ret_ref;
29741 }
29742
29743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29744         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29745         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29746         int64_t ret_ref = tag_ptr(ret_copy, true);
29747         return ret_ref;
29748 }
29749
29750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29751         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29752         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29753         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29754         return ret_conv;
29755 }
29756
29757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29758         LDKChannelMonitor this_obj_conv;
29759         this_obj_conv.inner = untag_ptr(this_obj);
29760         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29762         ChannelMonitor_free(this_obj_conv);
29763 }
29764
29765 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29766         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29767         int64_t ret_ref = 0;
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29770         return ret_ref;
29771 }
29772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29773         LDKChannelMonitor arg_conv;
29774         arg_conv.inner = untag_ptr(arg);
29775         arg_conv.is_owned = ptr_is_owned(arg);
29776         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29777         arg_conv.is_owned = false;
29778         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29779         return ret_conv;
29780 }
29781
29782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29783         LDKChannelMonitor orig_conv;
29784         orig_conv.inner = untag_ptr(orig);
29785         orig_conv.is_owned = ptr_is_owned(orig);
29786         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29787         orig_conv.is_owned = false;
29788         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29789         int64_t ret_ref = 0;
29790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29792         return ret_ref;
29793 }
29794
29795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29796         LDKChannelMonitor obj_conv;
29797         obj_conv.inner = untag_ptr(obj);
29798         obj_conv.is_owned = ptr_is_owned(obj);
29799         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29800         obj_conv.is_owned = false;
29801         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29802         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29803         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29804         CVec_u8Z_free(ret_var);
29805         return ret_arr;
29806 }
29807
29808 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) {
29809         LDKChannelMonitor this_arg_conv;
29810         this_arg_conv.inner = untag_ptr(this_arg);
29811         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29813         this_arg_conv.is_owned = false;
29814         LDKChannelMonitorUpdate updates_conv;
29815         updates_conv.inner = untag_ptr(updates);
29816         updates_conv.is_owned = ptr_is_owned(updates);
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29818         updates_conv.is_owned = false;
29819         void* broadcaster_ptr = untag_ptr(broadcaster);
29820         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29821         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29822         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29823         CHECK_ACCESS(fee_estimator_ptr);
29824         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29825         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29827                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29828         }
29829         void* logger_ptr = untag_ptr(logger);
29830         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29831         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29832         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29833         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29834         return tag_ptr(ret_conv, true);
29835 }
29836
29837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29838         LDKChannelMonitor this_arg_conv;
29839         this_arg_conv.inner = untag_ptr(this_arg);
29840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29842         this_arg_conv.is_owned = false;
29843         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29844         return ret_conv;
29845 }
29846
29847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29848         LDKChannelMonitor this_arg_conv;
29849         this_arg_conv.inner = untag_ptr(this_arg);
29850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29852         this_arg_conv.is_owned = false;
29853         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29854         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29855         return tag_ptr(ret_conv, true);
29856 }
29857
29858 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29859         LDKChannelMonitor this_arg_conv;
29860         this_arg_conv.inner = untag_ptr(this_arg);
29861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29863         this_arg_conv.is_owned = false;
29864         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29865         int64_tArray ret_arr = NULL;
29866         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29867         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29868         for (size_t o = 0; o < ret_var.datalen; o++) {
29869                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29870                 *ret_conv_40_conv = ret_var.data[o];
29871                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29872         }
29873         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29874         FREE(ret_var.data);
29875         return ret_arr;
29876 }
29877
29878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
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         void* filter_ptr = untag_ptr(filter);
29885         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29886         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29887         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29888 }
29889
29890 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29891         LDKChannelMonitor this_arg_conv;
29892         this_arg_conv.inner = untag_ptr(this_arg);
29893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29895         this_arg_conv.is_owned = false;
29896         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29897         int64_tArray ret_arr = NULL;
29898         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29899         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29900         for (size_t o = 0; o < ret_var.datalen; o++) {
29901                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29902                 *ret_conv_14_copy = ret_var.data[o];
29903                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29904                 ret_arr_ptr[o] = ret_conv_14_ref;
29905         }
29906         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29907         FREE(ret_var.data);
29908         return ret_arr;
29909 }
29910
29911 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29912         LDKChannelMonitor this_arg_conv;
29913         this_arg_conv.inner = untag_ptr(this_arg);
29914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29916         this_arg_conv.is_owned = false;
29917         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29918         int64_tArray ret_arr = NULL;
29919         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29920         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29921         for (size_t h = 0; h < ret_var.datalen; h++) {
29922                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29923                 *ret_conv_7_copy = ret_var.data[h];
29924                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29925                 ret_arr_ptr[h] = ret_conv_7_ref;
29926         }
29927         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29928         FREE(ret_var.data);
29929         return ret_arr;
29930 }
29931
29932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29933         LDKChannelMonitor this_arg_conv;
29934         this_arg_conv.inner = untag_ptr(this_arg);
29935         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29937         this_arg_conv.is_owned = false;
29938         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29940         return ret_arr;
29941 }
29942
29943 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) {
29944         LDKChannelMonitor this_arg_conv;
29945         this_arg_conv.inner = untag_ptr(this_arg);
29946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29948         this_arg_conv.is_owned = false;
29949         void* logger_ptr = untag_ptr(logger);
29950         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29951         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29952         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29953         jobjectArray ret_arr = NULL;
29954         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29955         ;
29956         for (size_t i = 0; i < ret_var.datalen; i++) {
29957                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29958                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29959                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29960                 Transaction_free(ret_conv_8_var);
29961                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29962         }
29963         
29964         FREE(ret_var.data);
29965         return ret_arr;
29966 }
29967
29968 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) {
29969         LDKChannelMonitor this_arg_conv;
29970         this_arg_conv.inner = untag_ptr(this_arg);
29971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29973         this_arg_conv.is_owned = false;
29974         uint8_t header_arr[80];
29975         CHECK((*env)->GetArrayLength(env, header) == 80);
29976         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29977         uint8_t (*header_ref)[80] = &header_arr;
29978         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29979         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29980         if (txdata_constr.datalen > 0)
29981                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29982         else
29983                 txdata_constr.data = NULL;
29984         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29985         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29986                 int64_t txdata_conv_28 = txdata_vals[c];
29987                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29988                 CHECK_ACCESS(txdata_conv_28_ptr);
29989                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29990                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29991                 txdata_constr.data[c] = txdata_conv_28_conv;
29992         }
29993         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29994         void* broadcaster_ptr = untag_ptr(broadcaster);
29995         CHECK_ACCESS(broadcaster_ptr);
29996         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29997         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29998                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29999                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30000         }
30001         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30002         CHECK_ACCESS(fee_estimator_ptr);
30003         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30004         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30005                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30006                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30007         }
30008         void* logger_ptr = untag_ptr(logger);
30009         CHECK_ACCESS(logger_ptr);
30010         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30011         if (logger_conv.free == LDKLogger_JCalls_free) {
30012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30013                 LDKLogger_JCalls_cloned(&logger_conv);
30014         }
30015         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);
30016         int64_tArray ret_arr = NULL;
30017         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30018         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30019         for (size_t n = 0; n < ret_var.datalen; n++) {
30020                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30021                 *ret_conv_39_conv = ret_var.data[n];
30022                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30023         }
30024         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30025         FREE(ret_var.data);
30026         return ret_arr;
30027 }
30028
30029 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) {
30030         LDKChannelMonitor this_arg_conv;
30031         this_arg_conv.inner = untag_ptr(this_arg);
30032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30034         this_arg_conv.is_owned = false;
30035         uint8_t header_arr[80];
30036         CHECK((*env)->GetArrayLength(env, header) == 80);
30037         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30038         uint8_t (*header_ref)[80] = &header_arr;
30039         void* broadcaster_ptr = untag_ptr(broadcaster);
30040         CHECK_ACCESS(broadcaster_ptr);
30041         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30042         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30043                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30044                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30045         }
30046         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30047         CHECK_ACCESS(fee_estimator_ptr);
30048         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30049         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30051                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30052         }
30053         void* logger_ptr = untag_ptr(logger);
30054         CHECK_ACCESS(logger_ptr);
30055         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30056         if (logger_conv.free == LDKLogger_JCalls_free) {
30057                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30058                 LDKLogger_JCalls_cloned(&logger_conv);
30059         }
30060         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30061 }
30062
30063 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) {
30064         LDKChannelMonitor this_arg_conv;
30065         this_arg_conv.inner = untag_ptr(this_arg);
30066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30068         this_arg_conv.is_owned = false;
30069         uint8_t header_arr[80];
30070         CHECK((*env)->GetArrayLength(env, header) == 80);
30071         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30072         uint8_t (*header_ref)[80] = &header_arr;
30073         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30074         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30075         if (txdata_constr.datalen > 0)
30076                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30077         else
30078                 txdata_constr.data = NULL;
30079         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30080         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30081                 int64_t txdata_conv_28 = txdata_vals[c];
30082                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30083                 CHECK_ACCESS(txdata_conv_28_ptr);
30084                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30085                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30086                 txdata_constr.data[c] = txdata_conv_28_conv;
30087         }
30088         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30089         void* broadcaster_ptr = untag_ptr(broadcaster);
30090         CHECK_ACCESS(broadcaster_ptr);
30091         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30092         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30094                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30095         }
30096         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30097         CHECK_ACCESS(fee_estimator_ptr);
30098         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30099         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30101                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30102         }
30103         void* logger_ptr = untag_ptr(logger);
30104         CHECK_ACCESS(logger_ptr);
30105         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30106         if (logger_conv.free == LDKLogger_JCalls_free) {
30107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30108                 LDKLogger_JCalls_cloned(&logger_conv);
30109         }
30110         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);
30111         int64_tArray ret_arr = NULL;
30112         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30113         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30114         for (size_t n = 0; n < ret_var.datalen; n++) {
30115                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30116                 *ret_conv_39_conv = ret_var.data[n];
30117                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30118         }
30119         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30120         FREE(ret_var.data);
30121         return ret_arr;
30122 }
30123
30124 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) {
30125         LDKChannelMonitor this_arg_conv;
30126         this_arg_conv.inner = untag_ptr(this_arg);
30127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30129         this_arg_conv.is_owned = false;
30130         uint8_t txid_arr[32];
30131         CHECK((*env)->GetArrayLength(env, txid) == 32);
30132         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
30133         uint8_t (*txid_ref)[32] = &txid_arr;
30134         void* broadcaster_ptr = untag_ptr(broadcaster);
30135         CHECK_ACCESS(broadcaster_ptr);
30136         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30137         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30138                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30139                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30140         }
30141         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30142         CHECK_ACCESS(fee_estimator_ptr);
30143         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30144         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30145                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30146                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30147         }
30148         void* logger_ptr = untag_ptr(logger);
30149         CHECK_ACCESS(logger_ptr);
30150         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30151         if (logger_conv.free == LDKLogger_JCalls_free) {
30152                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30153                 LDKLogger_JCalls_cloned(&logger_conv);
30154         }
30155         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
30156 }
30157
30158 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) {
30159         LDKChannelMonitor this_arg_conv;
30160         this_arg_conv.inner = untag_ptr(this_arg);
30161         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30163         this_arg_conv.is_owned = false;
30164         uint8_t header_arr[80];
30165         CHECK((*env)->GetArrayLength(env, header) == 80);
30166         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30167         uint8_t (*header_ref)[80] = &header_arr;
30168         void* broadcaster_ptr = untag_ptr(broadcaster);
30169         CHECK_ACCESS(broadcaster_ptr);
30170         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30171         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30173                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30174         }
30175         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30176         CHECK_ACCESS(fee_estimator_ptr);
30177         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30178         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30180                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30181         }
30182         void* logger_ptr = untag_ptr(logger);
30183         CHECK_ACCESS(logger_ptr);
30184         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30185         if (logger_conv.free == LDKLogger_JCalls_free) {
30186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30187                 LDKLogger_JCalls_cloned(&logger_conv);
30188         }
30189         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30190         int64_tArray ret_arr = NULL;
30191         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30192         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30193         for (size_t n = 0; n < ret_var.datalen; n++) {
30194                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30195                 *ret_conv_39_conv = ret_var.data[n];
30196                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30197         }
30198         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30199         FREE(ret_var.data);
30200         return ret_arr;
30201 }
30202
30203 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
30204         LDKChannelMonitor this_arg_conv;
30205         this_arg_conv.inner = untag_ptr(this_arg);
30206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30208         this_arg_conv.is_owned = false;
30209         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_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 z = 0; z < ret_var.datalen; z++) {
30214                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
30215                 *ret_conv_25_conv = ret_var.data[z];
30216                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_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_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(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         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
30230         int64_t ret_ref = 0;
30231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30233         return ret_ref;
30234 }
30235
30236 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) {
30237         LDKChannelMonitor this_arg_conv;
30238         this_arg_conv.inner = untag_ptr(this_arg);
30239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30241         this_arg_conv.is_owned = false;
30242         void* broadcaster_ptr = untag_ptr(broadcaster);
30243         CHECK_ACCESS(broadcaster_ptr);
30244         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30245         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30247                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30248         }
30249         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30250         CHECK_ACCESS(fee_estimator_ptr);
30251         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30252         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30254                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30255         }
30256         void* logger_ptr = untag_ptr(logger);
30257         CHECK_ACCESS(logger_ptr);
30258         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30259         if (logger_conv.free == LDKLogger_JCalls_free) {
30260                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30261                 LDKLogger_JCalls_cloned(&logger_conv);
30262         }
30263         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
30264 }
30265
30266 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
30267         LDKChannelMonitor this_arg_conv;
30268         this_arg_conv.inner = untag_ptr(this_arg);
30269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30271         this_arg_conv.is_owned = false;
30272         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
30273         int64_tArray ret_arr = NULL;
30274         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30275         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30276         for (size_t j = 0; j < ret_var.datalen; j++) {
30277                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
30278                 *ret_conv_9_copy = ret_var.data[j];
30279                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
30280                 ret_arr_ptr[j] = ret_conv_9_ref;
30281         }
30282         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30283         FREE(ret_var.data);
30284         return ret_arr;
30285 }
30286
30287 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) {
30288         LDKu8slice ser_ref;
30289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30291         void* arg_a_ptr = untag_ptr(arg_a);
30292         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
30293         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
30294         void* arg_b_ptr = untag_ptr(arg_b);
30295         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
30296         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
30297         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
30298         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
30299         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30300         return tag_ptr(ret_conv, true);
30301 }
30302
30303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30304         LDKOutPoint this_obj_conv;
30305         this_obj_conv.inner = untag_ptr(this_obj);
30306         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30308         OutPoint_free(this_obj_conv);
30309 }
30310
30311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30312         LDKOutPoint this_ptr_conv;
30313         this_ptr_conv.inner = untag_ptr(this_ptr);
30314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30316         this_ptr_conv.is_owned = false;
30317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
30319         return ret_arr;
30320 }
30321
30322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30323         LDKOutPoint this_ptr_conv;
30324         this_ptr_conv.inner = untag_ptr(this_ptr);
30325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30327         this_ptr_conv.is_owned = false;
30328         LDKThirtyTwoBytes val_ref;
30329         CHECK((*env)->GetArrayLength(env, val) == 32);
30330         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30331         OutPoint_set_txid(&this_ptr_conv, val_ref);
30332 }
30333
30334 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30335         LDKOutPoint this_ptr_conv;
30336         this_ptr_conv.inner = untag_ptr(this_ptr);
30337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30339         this_ptr_conv.is_owned = false;
30340         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
30341         return ret_conv;
30342 }
30343
30344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30345         LDKOutPoint this_ptr_conv;
30346         this_ptr_conv.inner = untag_ptr(this_ptr);
30347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30349         this_ptr_conv.is_owned = false;
30350         OutPoint_set_index(&this_ptr_conv, val);
30351 }
30352
30353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
30354         LDKThirtyTwoBytes txid_arg_ref;
30355         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
30356         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30357         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30358         int64_t ret_ref = 0;
30359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30361         return ret_ref;
30362 }
30363
30364 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30365         LDKOutPoint ret_var = OutPoint_clone(arg);
30366         int64_t ret_ref = 0;
30367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30369         return ret_ref;
30370 }
30371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30372         LDKOutPoint arg_conv;
30373         arg_conv.inner = untag_ptr(arg);
30374         arg_conv.is_owned = ptr_is_owned(arg);
30375         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30376         arg_conv.is_owned = false;
30377         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30378         return ret_conv;
30379 }
30380
30381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30382         LDKOutPoint orig_conv;
30383         orig_conv.inner = untag_ptr(orig);
30384         orig_conv.is_owned = ptr_is_owned(orig);
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30386         orig_conv.is_owned = false;
30387         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30388         int64_t ret_ref = 0;
30389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30391         return ret_ref;
30392 }
30393
30394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30395         LDKOutPoint a_conv;
30396         a_conv.inner = untag_ptr(a);
30397         a_conv.is_owned = ptr_is_owned(a);
30398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30399         a_conv.is_owned = false;
30400         LDKOutPoint b_conv;
30401         b_conv.inner = untag_ptr(b);
30402         b_conv.is_owned = ptr_is_owned(b);
30403         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30404         b_conv.is_owned = false;
30405         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30406         return ret_conv;
30407 }
30408
30409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30410         LDKOutPoint o_conv;
30411         o_conv.inner = untag_ptr(o);
30412         o_conv.is_owned = ptr_is_owned(o);
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30414         o_conv.is_owned = false;
30415         int64_t ret_conv = OutPoint_hash(&o_conv);
30416         return ret_conv;
30417 }
30418
30419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30420         LDKOutPoint this_arg_conv;
30421         this_arg_conv.inner = untag_ptr(this_arg);
30422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30424         this_arg_conv.is_owned = false;
30425         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30426         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30427         return ret_arr;
30428 }
30429
30430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30431         LDKOutPoint obj_conv;
30432         obj_conv.inner = untag_ptr(obj);
30433         obj_conv.is_owned = ptr_is_owned(obj);
30434         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30435         obj_conv.is_owned = false;
30436         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30437         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30438         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30439         CVec_u8Z_free(ret_var);
30440         return ret_arr;
30441 }
30442
30443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30444         LDKu8slice ser_ref;
30445         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30446         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30447         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30448         *ret_conv = OutPoint_read(ser_ref);
30449         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30450         return tag_ptr(ret_conv, true);
30451 }
30452
30453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30454         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30455         this_obj_conv.inner = untag_ptr(this_obj);
30456         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30458         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30459 }
30460
30461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30462         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30463         this_ptr_conv.inner = untag_ptr(this_ptr);
30464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30466         this_ptr_conv.is_owned = false;
30467         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30468         int64_t ret_ref = 0;
30469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30471         return ret_ref;
30472 }
30473
30474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30475         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30476         this_ptr_conv.inner = untag_ptr(this_ptr);
30477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30479         this_ptr_conv.is_owned = false;
30480         LDKOutPoint val_conv;
30481         val_conv.inner = untag_ptr(val);
30482         val_conv.is_owned = ptr_is_owned(val);
30483         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30484         val_conv = OutPoint_clone(&val_conv);
30485         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30486 }
30487
30488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30489         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30490         this_ptr_conv.inner = untag_ptr(this_ptr);
30491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30493         this_ptr_conv.is_owned = false;
30494         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30496         return ret_arr;
30497 }
30498
30499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30500         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30501         this_ptr_conv.inner = untag_ptr(this_ptr);
30502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30504         this_ptr_conv.is_owned = false;
30505         LDKPublicKey val_ref;
30506         CHECK((*env)->GetArrayLength(env, val) == 33);
30507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30508         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30509 }
30510
30511 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30512         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30513         this_ptr_conv.inner = untag_ptr(this_ptr);
30514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30516         this_ptr_conv.is_owned = false;
30517         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30518         return ret_conv;
30519 }
30520
30521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30522         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30523         this_ptr_conv.inner = untag_ptr(this_ptr);
30524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30526         this_ptr_conv.is_owned = false;
30527         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30528 }
30529
30530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30531         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30532         this_ptr_conv.inner = untag_ptr(this_ptr);
30533         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30535         this_ptr_conv.is_owned = false;
30536         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30537         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30538         return tag_ptr(ret_ref, true);
30539 }
30540
30541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_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         void* val_ptr = untag_ptr(val);
30548         CHECK_ACCESS(val_ptr);
30549         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30550         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30551         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30552 }
30553
30554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30555         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30556         this_ptr_conv.inner = untag_ptr(this_ptr);
30557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30559         this_ptr_conv.is_owned = false;
30560         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30562         return ret_arr;
30563 }
30564
30565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30566         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30567         this_ptr_conv.inner = untag_ptr(this_ptr);
30568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30570         this_ptr_conv.is_owned = false;
30571         LDKPublicKey val_ref;
30572         CHECK((*env)->GetArrayLength(env, val) == 33);
30573         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30574         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30575 }
30576
30577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30578         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30579         this_ptr_conv.inner = untag_ptr(this_ptr);
30580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30582         this_ptr_conv.is_owned = false;
30583         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30584         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30585         return ret_arr;
30586 }
30587
30588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30589         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30590         this_ptr_conv.inner = untag_ptr(this_ptr);
30591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30593         this_ptr_conv.is_owned = false;
30594         LDKThirtyTwoBytes val_ref;
30595         CHECK((*env)->GetArrayLength(env, val) == 32);
30596         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30597         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30598 }
30599
30600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30601         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30602         this_ptr_conv.inner = untag_ptr(this_ptr);
30603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30605         this_ptr_conv.is_owned = false;
30606         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30607         return ret_conv;
30608 }
30609
30610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30611         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30612         this_ptr_conv.inner = untag_ptr(this_ptr);
30613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30615         this_ptr_conv.is_owned = false;
30616         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30617 }
30618
30619 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) {
30620         LDKOutPoint outpoint_arg_conv;
30621         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30622         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30623         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30624         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30625         LDKPublicKey per_commitment_point_arg_ref;
30626         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30627         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30628         void* output_arg_ptr = untag_ptr(output_arg);
30629         CHECK_ACCESS(output_arg_ptr);
30630         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30631         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30632         LDKPublicKey revocation_pubkey_arg_ref;
30633         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30634         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30635         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30636         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30637         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30638         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);
30639         int64_t ret_ref = 0;
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30642         return ret_ref;
30643 }
30644
30645 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30646         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30647         int64_t ret_ref = 0;
30648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30650         return ret_ref;
30651 }
30652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30653         LDKDelayedPaymentOutputDescriptor arg_conv;
30654         arg_conv.inner = untag_ptr(arg);
30655         arg_conv.is_owned = ptr_is_owned(arg);
30656         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30657         arg_conv.is_owned = false;
30658         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30659         return ret_conv;
30660 }
30661
30662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30663         LDKDelayedPaymentOutputDescriptor orig_conv;
30664         orig_conv.inner = untag_ptr(orig);
30665         orig_conv.is_owned = ptr_is_owned(orig);
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30667         orig_conv.is_owned = false;
30668         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30669         int64_t ret_ref = 0;
30670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30672         return ret_ref;
30673 }
30674
30675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30676         LDKDelayedPaymentOutputDescriptor a_conv;
30677         a_conv.inner = untag_ptr(a);
30678         a_conv.is_owned = ptr_is_owned(a);
30679         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30680         a_conv.is_owned = false;
30681         LDKDelayedPaymentOutputDescriptor b_conv;
30682         b_conv.inner = untag_ptr(b);
30683         b_conv.is_owned = ptr_is_owned(b);
30684         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30685         b_conv.is_owned = false;
30686         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30687         return ret_conv;
30688 }
30689
30690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30691         LDKDelayedPaymentOutputDescriptor obj_conv;
30692         obj_conv.inner = untag_ptr(obj);
30693         obj_conv.is_owned = ptr_is_owned(obj);
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30695         obj_conv.is_owned = false;
30696         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30699         CVec_u8Z_free(ret_var);
30700         return ret_arr;
30701 }
30702
30703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30704         LDKu8slice ser_ref;
30705         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30706         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30707         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30708         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30709         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30710         return tag_ptr(ret_conv, true);
30711 }
30712
30713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30714         LDKStaticPaymentOutputDescriptor this_obj_conv;
30715         this_obj_conv.inner = untag_ptr(this_obj);
30716         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30718         StaticPaymentOutputDescriptor_free(this_obj_conv);
30719 }
30720
30721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30722         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30723         this_ptr_conv.inner = untag_ptr(this_ptr);
30724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30726         this_ptr_conv.is_owned = false;
30727         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30728         int64_t ret_ref = 0;
30729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30731         return ret_ref;
30732 }
30733
30734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30735         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30736         this_ptr_conv.inner = untag_ptr(this_ptr);
30737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30739         this_ptr_conv.is_owned = false;
30740         LDKOutPoint val_conv;
30741         val_conv.inner = untag_ptr(val);
30742         val_conv.is_owned = ptr_is_owned(val);
30743         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30744         val_conv = OutPoint_clone(&val_conv);
30745         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30746 }
30747
30748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30749         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30750         this_ptr_conv.inner = untag_ptr(this_ptr);
30751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30753         this_ptr_conv.is_owned = false;
30754         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30755         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30756         return tag_ptr(ret_ref, true);
30757 }
30758
30759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30760         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30761         this_ptr_conv.inner = untag_ptr(this_ptr);
30762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30764         this_ptr_conv.is_owned = false;
30765         void* val_ptr = untag_ptr(val);
30766         CHECK_ACCESS(val_ptr);
30767         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30768         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30769         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30770 }
30771
30772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30773         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30774         this_ptr_conv.inner = untag_ptr(this_ptr);
30775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30777         this_ptr_conv.is_owned = false;
30778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30780         return ret_arr;
30781 }
30782
30783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30784         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30785         this_ptr_conv.inner = untag_ptr(this_ptr);
30786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30788         this_ptr_conv.is_owned = false;
30789         LDKThirtyTwoBytes val_ref;
30790         CHECK((*env)->GetArrayLength(env, val) == 32);
30791         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30792         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30793 }
30794
30795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30796         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30797         this_ptr_conv.inner = untag_ptr(this_ptr);
30798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30800         this_ptr_conv.is_owned = false;
30801         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30802         return ret_conv;
30803 }
30804
30805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30806         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30807         this_ptr_conv.inner = untag_ptr(this_ptr);
30808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30810         this_ptr_conv.is_owned = false;
30811         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30812 }
30813
30814 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) {
30815         LDKOutPoint outpoint_arg_conv;
30816         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30817         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30818         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30819         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30820         void* output_arg_ptr = untag_ptr(output_arg);
30821         CHECK_ACCESS(output_arg_ptr);
30822         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30823         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30824         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30825         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30826         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30827         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30828         int64_t ret_ref = 0;
30829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30830         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30831         return ret_ref;
30832 }
30833
30834 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30835         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30836         int64_t ret_ref = 0;
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30839         return ret_ref;
30840 }
30841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30842         LDKStaticPaymentOutputDescriptor arg_conv;
30843         arg_conv.inner = untag_ptr(arg);
30844         arg_conv.is_owned = ptr_is_owned(arg);
30845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30846         arg_conv.is_owned = false;
30847         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30848         return ret_conv;
30849 }
30850
30851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30852         LDKStaticPaymentOutputDescriptor orig_conv;
30853         orig_conv.inner = untag_ptr(orig);
30854         orig_conv.is_owned = ptr_is_owned(orig);
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30856         orig_conv.is_owned = false;
30857         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30858         int64_t ret_ref = 0;
30859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30861         return ret_ref;
30862 }
30863
30864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30865         LDKStaticPaymentOutputDescriptor a_conv;
30866         a_conv.inner = untag_ptr(a);
30867         a_conv.is_owned = ptr_is_owned(a);
30868         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30869         a_conv.is_owned = false;
30870         LDKStaticPaymentOutputDescriptor b_conv;
30871         b_conv.inner = untag_ptr(b);
30872         b_conv.is_owned = ptr_is_owned(b);
30873         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30874         b_conv.is_owned = false;
30875         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30876         return ret_conv;
30877 }
30878
30879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30880         LDKStaticPaymentOutputDescriptor obj_conv;
30881         obj_conv.inner = untag_ptr(obj);
30882         obj_conv.is_owned = ptr_is_owned(obj);
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30884         obj_conv.is_owned = false;
30885         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30888         CVec_u8Z_free(ret_var);
30889         return ret_arr;
30890 }
30891
30892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30893         LDKu8slice ser_ref;
30894         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30895         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30896         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30897         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30898         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30899         return tag_ptr(ret_conv, true);
30900 }
30901
30902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30903         if (!ptr_is_owned(this_ptr)) return;
30904         void* this_ptr_ptr = untag_ptr(this_ptr);
30905         CHECK_ACCESS(this_ptr_ptr);
30906         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30907         FREE(untag_ptr(this_ptr));
30908         SpendableOutputDescriptor_free(this_ptr_conv);
30909 }
30910
30911 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30912         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30913         *ret_copy = SpendableOutputDescriptor_clone(arg);
30914         int64_t ret_ref = tag_ptr(ret_copy, true);
30915         return ret_ref;
30916 }
30917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30918         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30919         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30920         return ret_conv;
30921 }
30922
30923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30924         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30925         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30926         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30927         int64_t ret_ref = tag_ptr(ret_copy, true);
30928         return ret_ref;
30929 }
30930
30931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30932         LDKOutPoint outpoint_conv;
30933         outpoint_conv.inner = untag_ptr(outpoint);
30934         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30935         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30936         outpoint_conv = OutPoint_clone(&outpoint_conv);
30937         void* output_ptr = untag_ptr(output);
30938         CHECK_ACCESS(output_ptr);
30939         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30940         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30941         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30942         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30943         int64_t ret_ref = tag_ptr(ret_copy, true);
30944         return ret_ref;
30945 }
30946
30947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30948         LDKDelayedPaymentOutputDescriptor a_conv;
30949         a_conv.inner = untag_ptr(a);
30950         a_conv.is_owned = ptr_is_owned(a);
30951         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30952         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30953         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30954         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30955         int64_t ret_ref = tag_ptr(ret_copy, true);
30956         return ret_ref;
30957 }
30958
30959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30960         LDKStaticPaymentOutputDescriptor a_conv;
30961         a_conv.inner = untag_ptr(a);
30962         a_conv.is_owned = ptr_is_owned(a);
30963         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30964         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30965         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30966         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30967         int64_t ret_ref = tag_ptr(ret_copy, true);
30968         return ret_ref;
30969 }
30970
30971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30972         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30973         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30974         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30975         return ret_conv;
30976 }
30977
30978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30979         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30980         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30983         CVec_u8Z_free(ret_var);
30984         return ret_arr;
30985 }
30986
30987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30988         LDKu8slice ser_ref;
30989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30991         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
30992         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
30993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30994         return tag_ptr(ret_conv, true);
30995 }
30996
30997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30998         if (!ptr_is_owned(this_ptr)) return;
30999         void* this_ptr_ptr = untag_ptr(this_ptr);
31000         CHECK_ACCESS(this_ptr_ptr);
31001         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
31002         FREE(untag_ptr(this_ptr));
31003         ChannelSigner_free(this_ptr_conv);
31004 }
31005
31006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31007         if (!ptr_is_owned(this_ptr)) return;
31008         void* this_ptr_ptr = untag_ptr(this_ptr);
31009         CHECK_ACCESS(this_ptr_ptr);
31010         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
31011         FREE(untag_ptr(this_ptr));
31012         EcdsaChannelSigner_free(this_ptr_conv);
31013 }
31014
31015 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
31016         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31017         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
31018         return tag_ptr(ret_ret, true);
31019 }
31020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31021         void* arg_ptr = untag_ptr(arg);
31022         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
31023         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
31024         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
31025         return ret_conv;
31026 }
31027
31028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31029         void* orig_ptr = untag_ptr(orig);
31030         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
31031         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
31032         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31033         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
31034         return tag_ptr(ret_ret, true);
31035 }
31036
31037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31038         if (!ptr_is_owned(this_ptr)) return;
31039         void* this_ptr_ptr = untag_ptr(this_ptr);
31040         CHECK_ACCESS(this_ptr_ptr);
31041         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
31042         FREE(untag_ptr(this_ptr));
31043         WriteableEcdsaChannelSigner_free(this_ptr_conv);
31044 }
31045
31046 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31047         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
31048         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
31049         return ret_conv;
31050 }
31051
31052 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
31053         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
31054         return ret_conv;
31055 }
31056
31057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
31058         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
31059         return ret_conv;
31060 }
31061
31062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EntropySource_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31063         if (!ptr_is_owned(this_ptr)) return;
31064         void* this_ptr_ptr = untag_ptr(this_ptr);
31065         CHECK_ACCESS(this_ptr_ptr);
31066         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
31067         FREE(untag_ptr(this_ptr));
31068         EntropySource_free(this_ptr_conv);
31069 }
31070
31071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31072         if (!ptr_is_owned(this_ptr)) return;
31073         void* this_ptr_ptr = untag_ptr(this_ptr);
31074         CHECK_ACCESS(this_ptr_ptr);
31075         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
31076         FREE(untag_ptr(this_ptr));
31077         NodeSigner_free(this_ptr_conv);
31078 }
31079
31080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignerProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31081         if (!ptr_is_owned(this_ptr)) return;
31082         void* this_ptr_ptr = untag_ptr(this_ptr);
31083         CHECK_ACCESS(this_ptr_ptr);
31084         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
31085         FREE(untag_ptr(this_ptr));
31086         SignerProvider_free(this_ptr_conv);
31087 }
31088
31089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31090         LDKInMemorySigner this_obj_conv;
31091         this_obj_conv.inner = untag_ptr(this_obj);
31092         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31094         InMemorySigner_free(this_obj_conv);
31095 }
31096
31097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31098         LDKInMemorySigner this_ptr_conv;
31099         this_ptr_conv.inner = untag_ptr(this_ptr);
31100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31102         this_ptr_conv.is_owned = false;
31103         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
31105         return ret_arr;
31106 }
31107
31108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31109         LDKInMemorySigner this_ptr_conv;
31110         this_ptr_conv.inner = untag_ptr(this_ptr);
31111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31113         this_ptr_conv.is_owned = false;
31114         LDKSecretKey val_ref;
31115         CHECK((*env)->GetArrayLength(env, val) == 32);
31116         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31117         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
31118 }
31119
31120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31121         LDKInMemorySigner this_ptr_conv;
31122         this_ptr_conv.inner = untag_ptr(this_ptr);
31123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31125         this_ptr_conv.is_owned = false;
31126         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
31128         return ret_arr;
31129 }
31130
31131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31132         LDKInMemorySigner this_ptr_conv;
31133         this_ptr_conv.inner = untag_ptr(this_ptr);
31134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31136         this_ptr_conv.is_owned = false;
31137         LDKSecretKey val_ref;
31138         CHECK((*env)->GetArrayLength(env, val) == 32);
31139         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31140         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
31141 }
31142
31143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31144         LDKInMemorySigner this_ptr_conv;
31145         this_ptr_conv.inner = untag_ptr(this_ptr);
31146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         this_ptr_conv.is_owned = false;
31149         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
31151         return ret_arr;
31152 }
31153
31154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31155         LDKInMemorySigner this_ptr_conv;
31156         this_ptr_conv.inner = untag_ptr(this_ptr);
31157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31159         this_ptr_conv.is_owned = false;
31160         LDKSecretKey val_ref;
31161         CHECK((*env)->GetArrayLength(env, val) == 32);
31162         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31163         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
31164 }
31165
31166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31167         LDKInMemorySigner this_ptr_conv;
31168         this_ptr_conv.inner = untag_ptr(this_ptr);
31169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31171         this_ptr_conv.is_owned = false;
31172         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
31174         return ret_arr;
31175 }
31176
31177 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) {
31178         LDKInMemorySigner this_ptr_conv;
31179         this_ptr_conv.inner = untag_ptr(this_ptr);
31180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31182         this_ptr_conv.is_owned = false;
31183         LDKSecretKey val_ref;
31184         CHECK((*env)->GetArrayLength(env, val) == 32);
31185         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31186         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
31187 }
31188
31189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31190         LDKInMemorySigner this_ptr_conv;
31191         this_ptr_conv.inner = untag_ptr(this_ptr);
31192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31194         this_ptr_conv.is_owned = false;
31195         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31196         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
31197         return ret_arr;
31198 }
31199
31200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31201         LDKInMemorySigner this_ptr_conv;
31202         this_ptr_conv.inner = untag_ptr(this_ptr);
31203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31205         this_ptr_conv.is_owned = false;
31206         LDKSecretKey val_ref;
31207         CHECK((*env)->GetArrayLength(env, val) == 32);
31208         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31209         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
31210 }
31211
31212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31213         LDKInMemorySigner this_ptr_conv;
31214         this_ptr_conv.inner = untag_ptr(this_ptr);
31215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31217         this_ptr_conv.is_owned = false;
31218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
31220         return ret_arr;
31221 }
31222
31223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31224         LDKInMemorySigner this_ptr_conv;
31225         this_ptr_conv.inner = untag_ptr(this_ptr);
31226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31228         this_ptr_conv.is_owned = false;
31229         LDKThirtyTwoBytes val_ref;
31230         CHECK((*env)->GetArrayLength(env, val) == 32);
31231         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31232         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
31233 }
31234
31235 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
31236         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
31237         int64_t ret_ref = 0;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31240         return ret_ref;
31241 }
31242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31243         LDKInMemorySigner arg_conv;
31244         arg_conv.inner = untag_ptr(arg);
31245         arg_conv.is_owned = ptr_is_owned(arg);
31246         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31247         arg_conv.is_owned = false;
31248         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
31249         return ret_conv;
31250 }
31251
31252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31253         LDKInMemorySigner orig_conv;
31254         orig_conv.inner = untag_ptr(orig);
31255         orig_conv.is_owned = ptr_is_owned(orig);
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31257         orig_conv.is_owned = false;
31258         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
31259         int64_t ret_ref = 0;
31260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31262         return ret_ref;
31263 }
31264
31265 JNIEXPORT 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) {
31266         LDKSecretKey funding_key_ref;
31267         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
31268         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
31269         LDKSecretKey revocation_base_key_ref;
31270         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
31271         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
31272         LDKSecretKey payment_key_ref;
31273         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
31274         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
31275         LDKSecretKey delayed_payment_base_key_ref;
31276         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
31277         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
31278         LDKSecretKey htlc_base_key_ref;
31279         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
31280         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
31281         LDKThirtyTwoBytes commitment_seed_ref;
31282         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31283         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
31284         LDKThirtyTwoBytes channel_keys_id_ref;
31285         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
31286         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
31287         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
31288         CHECK((*env)->GetArrayLength(env, rand_bytes_unique_start) == 32);
31289         (*env)->GetByteArrayRegion(env, rand_bytes_unique_start, 0, 32, rand_bytes_unique_start_ref.data);
31290         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);
31291         int64_t ret_ref = 0;
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31293         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31294         return ret_ref;
31295 }
31296
31297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
31298         LDKInMemorySigner this_arg_conv;
31299         this_arg_conv.inner = untag_ptr(this_arg);
31300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31302         this_arg_conv.is_owned = false;
31303         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
31304         int64_t ret_ref = 0;
31305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31307         return ret_ref;
31308 }
31309
31310 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31311         LDKInMemorySigner this_arg_conv;
31312         this_arg_conv.inner = untag_ptr(this_arg);
31313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31315         this_arg_conv.is_owned = false;
31316         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
31317         return ret_conv;
31318 }
31319
31320 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31321         LDKInMemorySigner this_arg_conv;
31322         this_arg_conv.inner = untag_ptr(this_arg);
31323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31325         this_arg_conv.is_owned = false;
31326         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
31327         return ret_conv;
31328 }
31329
31330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(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         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
31337         return ret_conv;
31338 }
31339
31340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(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         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
31347         int64_t ret_ref = 0;
31348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31350         return ret_ref;
31351 }
31352
31353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
31354         LDKInMemorySigner this_arg_conv;
31355         this_arg_conv.inner = untag_ptr(this_arg);
31356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31358         this_arg_conv.is_owned = false;
31359         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
31360         int64_t ret_ref = 0;
31361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31363         return ret_ref;
31364 }
31365
31366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
31367         LDKInMemorySigner this_arg_conv;
31368         this_arg_conv.inner = untag_ptr(this_arg);
31369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31371         this_arg_conv.is_owned = false;
31372         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
31373         return ret_conv;
31374 }
31375
31376 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) {
31377         LDKInMemorySigner this_arg_conv;
31378         this_arg_conv.inner = untag_ptr(this_arg);
31379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31381         this_arg_conv.is_owned = false;
31382         LDKTransaction spend_tx_ref;
31383         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31384         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31385         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31386         spend_tx_ref.data_is_owned = true;
31387         LDKStaticPaymentOutputDescriptor descriptor_conv;
31388         descriptor_conv.inner = untag_ptr(descriptor);
31389         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31390         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31391         descriptor_conv.is_owned = false;
31392         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31393         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31394         return tag_ptr(ret_conv, true);
31395 }
31396
31397 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) {
31398         LDKInMemorySigner this_arg_conv;
31399         this_arg_conv.inner = untag_ptr(this_arg);
31400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31402         this_arg_conv.is_owned = false;
31403         LDKTransaction spend_tx_ref;
31404         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31405         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31406         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31407         spend_tx_ref.data_is_owned = true;
31408         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31409         descriptor_conv.inner = untag_ptr(descriptor);
31410         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31411         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31412         descriptor_conv.is_owned = false;
31413         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31414         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31415         return tag_ptr(ret_conv, true);
31416 }
31417
31418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31419         LDKInMemorySigner this_arg_conv;
31420         this_arg_conv.inner = untag_ptr(this_arg);
31421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31423         this_arg_conv.is_owned = false;
31424         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31425         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
31426         return tag_ptr(ret_ret, true);
31427 }
31428
31429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1ChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31430         LDKInMemorySigner this_arg_conv;
31431         this_arg_conv.inner = untag_ptr(this_arg);
31432         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31434         this_arg_conv.is_owned = false;
31435         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
31436         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
31437         return tag_ptr(ret_ret, true);
31438 }
31439
31440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31441         LDKInMemorySigner this_arg_conv;
31442         this_arg_conv.inner = untag_ptr(this_arg);
31443         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31445         this_arg_conv.is_owned = false;
31446         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
31447         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
31448         return tag_ptr(ret_ret, true);
31449 }
31450
31451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1WriteableEcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31452         LDKInMemorySigner this_arg_conv;
31453         this_arg_conv.inner = untag_ptr(this_arg);
31454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31456         this_arg_conv.is_owned = false;
31457         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31458         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
31459         return tag_ptr(ret_ret, true);
31460 }
31461
31462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31463         LDKInMemorySigner obj_conv;
31464         obj_conv.inner = untag_ptr(obj);
31465         obj_conv.is_owned = ptr_is_owned(obj);
31466         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31467         obj_conv.is_owned = false;
31468         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31469         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31470         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31471         CVec_u8Z_free(ret_var);
31472         return ret_arr;
31473 }
31474
31475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31476         LDKu8slice ser_ref;
31477         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31478         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31479         void* arg_ptr = untag_ptr(arg);
31480         CHECK_ACCESS(arg_ptr);
31481         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
31482         if (arg_conv.free == LDKEntropySource_JCalls_free) {
31483                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31484                 LDKEntropySource_JCalls_cloned(&arg_conv);
31485         }
31486         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31487         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
31488         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31489         return tag_ptr(ret_conv, true);
31490 }
31491
31492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31493         LDKKeysManager this_obj_conv;
31494         this_obj_conv.inner = untag_ptr(this_obj);
31495         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31497         KeysManager_free(this_obj_conv);
31498 }
31499
31500 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) {
31501         uint8_t seed_arr[32];
31502         CHECK((*env)->GetArrayLength(env, seed) == 32);
31503         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31504         uint8_t (*seed_ref)[32] = &seed_arr;
31505         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31506         int64_t ret_ref = 0;
31507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31509         return ret_ref;
31510 }
31511
31512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31513         LDKKeysManager this_arg_conv;
31514         this_arg_conv.inner = untag_ptr(this_arg);
31515         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31517         this_arg_conv.is_owned = false;
31518         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, KeysManager_get_node_secret_key(&this_arg_conv).bytes);
31520         return ret_arr;
31521 }
31522
31523 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) {
31524         LDKKeysManager this_arg_conv;
31525         this_arg_conv.inner = untag_ptr(this_arg);
31526         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31528         this_arg_conv.is_owned = false;
31529         uint8_t params_arr[32];
31530         CHECK((*env)->GetArrayLength(env, params) == 32);
31531         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31532         uint8_t (*params_ref)[32] = &params_arr;
31533         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31534         int64_t ret_ref = 0;
31535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31537         return ret_ref;
31538 }
31539
31540 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) {
31541         LDKKeysManager this_arg_conv;
31542         this_arg_conv.inner = untag_ptr(this_arg);
31543         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31545         this_arg_conv.is_owned = false;
31546         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31547         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31548         if (descriptors_constr.datalen > 0)
31549                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31550         else
31551                 descriptors_constr.data = NULL;
31552         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31553         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31554                 int64_t descriptors_conv_27 = descriptors_vals[b];
31555                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31556                 CHECK_ACCESS(descriptors_conv_27_ptr);
31557                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31558                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31559                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31560         }
31561         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31562         LDKCVec_TxOutZ outputs_constr;
31563         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31564         if (outputs_constr.datalen > 0)
31565                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31566         else
31567                 outputs_constr.data = NULL;
31568         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31569         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31570                 int64_t outputs_conv_7 = outputs_vals[h];
31571                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31572                 CHECK_ACCESS(outputs_conv_7_ptr);
31573                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31574                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31575                 outputs_constr.data[h] = outputs_conv_7_conv;
31576         }
31577         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31578         LDKCVec_u8Z change_destination_script_ref;
31579         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31580         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31581         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31582         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31583         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31584         return tag_ptr(ret_conv, true);
31585 }
31586
31587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31588         LDKKeysManager this_arg_conv;
31589         this_arg_conv.inner = untag_ptr(this_arg);
31590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31592         this_arg_conv.is_owned = false;
31593         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31594         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
31595         return tag_ptr(ret_ret, true);
31596 }
31597
31598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31599         LDKKeysManager this_arg_conv;
31600         this_arg_conv.inner = untag_ptr(this_arg);
31601         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31603         this_arg_conv.is_owned = false;
31604         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31605         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
31606         return tag_ptr(ret_ret, true);
31607 }
31608
31609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31610         LDKKeysManager this_arg_conv;
31611         this_arg_conv.inner = untag_ptr(this_arg);
31612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31614         this_arg_conv.is_owned = false;
31615         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31616         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
31617         return tag_ptr(ret_ret, true);
31618 }
31619
31620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31621         LDKPhantomKeysManager this_obj_conv;
31622         this_obj_conv.inner = untag_ptr(this_obj);
31623         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31625         PhantomKeysManager_free(this_obj_conv);
31626 }
31627
31628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31629         LDKPhantomKeysManager this_arg_conv;
31630         this_arg_conv.inner = untag_ptr(this_arg);
31631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31633         this_arg_conv.is_owned = false;
31634         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31635         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
31636         return tag_ptr(ret_ret, true);
31637 }
31638
31639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31640         LDKPhantomKeysManager this_arg_conv;
31641         this_arg_conv.inner = untag_ptr(this_arg);
31642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31644         this_arg_conv.is_owned = false;
31645         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31646         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
31647         return tag_ptr(ret_ret, true);
31648 }
31649
31650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31651         LDKPhantomKeysManager this_arg_conv;
31652         this_arg_conv.inner = untag_ptr(this_arg);
31653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31655         this_arg_conv.is_owned = false;
31656         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31657         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
31658         return tag_ptr(ret_ret, true);
31659 }
31660
31661 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) {
31662         uint8_t seed_arr[32];
31663         CHECK((*env)->GetArrayLength(env, seed) == 32);
31664         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31665         uint8_t (*seed_ref)[32] = &seed_arr;
31666         uint8_t cross_node_seed_arr[32];
31667         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31668         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31669         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31670         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31671         int64_t ret_ref = 0;
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31674         return ret_ref;
31675 }
31676
31677 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) {
31678         LDKPhantomKeysManager this_arg_conv;
31679         this_arg_conv.inner = untag_ptr(this_arg);
31680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31682         this_arg_conv.is_owned = false;
31683         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31684         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31685         if (descriptors_constr.datalen > 0)
31686                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31687         else
31688                 descriptors_constr.data = NULL;
31689         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31690         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31691                 int64_t descriptors_conv_27 = descriptors_vals[b];
31692                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31693                 CHECK_ACCESS(descriptors_conv_27_ptr);
31694                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31695                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31696                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31697         }
31698         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31699         LDKCVec_TxOutZ outputs_constr;
31700         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31701         if (outputs_constr.datalen > 0)
31702                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31703         else
31704                 outputs_constr.data = NULL;
31705         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31706         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31707                 int64_t outputs_conv_7 = outputs_vals[h];
31708                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31709                 CHECK_ACCESS(outputs_conv_7_ptr);
31710                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31711                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31712                 outputs_constr.data[h] = outputs_conv_7_conv;
31713         }
31714         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31715         LDKCVec_u8Z change_destination_script_ref;
31716         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31717         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31718         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31719         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31720         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31721         return tag_ptr(ret_conv, true);
31722 }
31723
31724 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) {
31725         LDKPhantomKeysManager this_arg_conv;
31726         this_arg_conv.inner = untag_ptr(this_arg);
31727         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31729         this_arg_conv.is_owned = false;
31730         uint8_t params_arr[32];
31731         CHECK((*env)->GetArrayLength(env, params) == 32);
31732         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31733         uint8_t (*params_ref)[32] = &params_arr;
31734         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31735         int64_t ret_ref = 0;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31738         return ret_ref;
31739 }
31740
31741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31742         LDKPhantomKeysManager this_arg_conv;
31743         this_arg_conv.inner = untag_ptr(this_arg);
31744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31746         this_arg_conv.is_owned = false;
31747         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes);
31749         return ret_arr;
31750 }
31751
31752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1phantom_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31753         LDKPhantomKeysManager this_arg_conv;
31754         this_arg_conv.inner = untag_ptr(this_arg);
31755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31757         this_arg_conv.is_owned = false;
31758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes);
31760         return ret_arr;
31761 }
31762
31763 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31764         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
31765         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_clone(orig_conv));
31766         return ret_conv;
31767 }
31768
31769 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1temporary_1node_1failure(JNIEnv *env, jclass clz) {
31770         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_temporary_node_failure());
31771         return ret_conv;
31772 }
31773
31774 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1required_1node_1feature_1missing(JNIEnv *env, jclass clz) {
31775         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_required_node_feature_missing());
31776         return ret_conv;
31777 }
31778
31779 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1incorrect_1or_1unknown_1payment_1details(JNIEnv *env, jclass clz) {
31780         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_incorrect_or_unknown_payment_details());
31781         return ret_conv;
31782 }
31783
31784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31785         LDKChannelManager this_obj_conv;
31786         this_obj_conv.inner = untag_ptr(this_obj);
31787         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31789         ChannelManager_free(this_obj_conv);
31790 }
31791
31792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31793         LDKChainParameters this_obj_conv;
31794         this_obj_conv.inner = untag_ptr(this_obj);
31795         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31797         ChainParameters_free(this_obj_conv);
31798 }
31799
31800 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31801         LDKChainParameters this_ptr_conv;
31802         this_ptr_conv.inner = untag_ptr(this_ptr);
31803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31805         this_ptr_conv.is_owned = false;
31806         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31807         return ret_conv;
31808 }
31809
31810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31811         LDKChainParameters this_ptr_conv;
31812         this_ptr_conv.inner = untag_ptr(this_ptr);
31813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31815         this_ptr_conv.is_owned = false;
31816         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31817         ChainParameters_set_network(&this_ptr_conv, val_conv);
31818 }
31819
31820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(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         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31827         int64_t ret_ref = 0;
31828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31830         return ret_ref;
31831 }
31832
31833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31834         LDKChainParameters this_ptr_conv;
31835         this_ptr_conv.inner = untag_ptr(this_ptr);
31836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31838         this_ptr_conv.is_owned = false;
31839         LDKBestBlock val_conv;
31840         val_conv.inner = untag_ptr(val);
31841         val_conv.is_owned = ptr_is_owned(val);
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31843         val_conv = BestBlock_clone(&val_conv);
31844         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31845 }
31846
31847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31848         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31849         LDKBestBlock best_block_arg_conv;
31850         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31851         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31852         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31853         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31854         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31855         int64_t ret_ref = 0;
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31858         return ret_ref;
31859 }
31860
31861 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31862         LDKChainParameters ret_var = ChainParameters_clone(arg);
31863         int64_t ret_ref = 0;
31864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31866         return ret_ref;
31867 }
31868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31869         LDKChainParameters arg_conv;
31870         arg_conv.inner = untag_ptr(arg);
31871         arg_conv.is_owned = ptr_is_owned(arg);
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31873         arg_conv.is_owned = false;
31874         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31875         return ret_conv;
31876 }
31877
31878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31879         LDKChainParameters orig_conv;
31880         orig_conv.inner = untag_ptr(orig);
31881         orig_conv.is_owned = ptr_is_owned(orig);
31882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31883         orig_conv.is_owned = false;
31884         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31885         int64_t ret_ref = 0;
31886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31888         return ret_ref;
31889 }
31890
31891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31892         LDKCounterpartyForwardingInfo this_obj_conv;
31893         this_obj_conv.inner = untag_ptr(this_obj);
31894         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31896         CounterpartyForwardingInfo_free(this_obj_conv);
31897 }
31898
31899 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31900         LDKCounterpartyForwardingInfo this_ptr_conv;
31901         this_ptr_conv.inner = untag_ptr(this_ptr);
31902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31904         this_ptr_conv.is_owned = false;
31905         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31906         return ret_conv;
31907 }
31908
31909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31910         LDKCounterpartyForwardingInfo this_ptr_conv;
31911         this_ptr_conv.inner = untag_ptr(this_ptr);
31912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31914         this_ptr_conv.is_owned = false;
31915         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31916 }
31917
31918 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31919         LDKCounterpartyForwardingInfo this_ptr_conv;
31920         this_ptr_conv.inner = untag_ptr(this_ptr);
31921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31923         this_ptr_conv.is_owned = false;
31924         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31925         return ret_conv;
31926 }
31927
31928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31929         LDKCounterpartyForwardingInfo this_ptr_conv;
31930         this_ptr_conv.inner = untag_ptr(this_ptr);
31931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31933         this_ptr_conv.is_owned = false;
31934         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31935 }
31936
31937 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31938         LDKCounterpartyForwardingInfo this_ptr_conv;
31939         this_ptr_conv.inner = untag_ptr(this_ptr);
31940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31942         this_ptr_conv.is_owned = false;
31943         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31944         return ret_conv;
31945 }
31946
31947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31948         LDKCounterpartyForwardingInfo this_ptr_conv;
31949         this_ptr_conv.inner = untag_ptr(this_ptr);
31950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31952         this_ptr_conv.is_owned = false;
31953         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31954 }
31955
31956 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) {
31957         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31958         int64_t ret_ref = 0;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31961         return ret_ref;
31962 }
31963
31964 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31965         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31966         int64_t ret_ref = 0;
31967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31969         return ret_ref;
31970 }
31971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31972         LDKCounterpartyForwardingInfo arg_conv;
31973         arg_conv.inner = untag_ptr(arg);
31974         arg_conv.is_owned = ptr_is_owned(arg);
31975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31976         arg_conv.is_owned = false;
31977         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31978         return ret_conv;
31979 }
31980
31981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31982         LDKCounterpartyForwardingInfo orig_conv;
31983         orig_conv.inner = untag_ptr(orig);
31984         orig_conv.is_owned = ptr_is_owned(orig);
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31986         orig_conv.is_owned = false;
31987         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
31988         int64_t ret_ref = 0;
31989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31991         return ret_ref;
31992 }
31993
31994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31995         LDKChannelCounterparty this_obj_conv;
31996         this_obj_conv.inner = untag_ptr(this_obj);
31997         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31999         ChannelCounterparty_free(this_obj_conv);
32000 }
32001
32002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32003         LDKChannelCounterparty this_ptr_conv;
32004         this_ptr_conv.inner = untag_ptr(this_ptr);
32005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32007         this_ptr_conv.is_owned = false;
32008         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
32010         return ret_arr;
32011 }
32012
32013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32014         LDKChannelCounterparty this_ptr_conv;
32015         this_ptr_conv.inner = untag_ptr(this_ptr);
32016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32018         this_ptr_conv.is_owned = false;
32019         LDKPublicKey val_ref;
32020         CHECK((*env)->GetArrayLength(env, val) == 33);
32021         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32022         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
32023 }
32024
32025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32026         LDKChannelCounterparty this_ptr_conv;
32027         this_ptr_conv.inner = untag_ptr(this_ptr);
32028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32030         this_ptr_conv.is_owned = false;
32031         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
32032         int64_t ret_ref = 0;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32035         return ret_ref;
32036 }
32037
32038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32039         LDKChannelCounterparty this_ptr_conv;
32040         this_ptr_conv.inner = untag_ptr(this_ptr);
32041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32043         this_ptr_conv.is_owned = false;
32044         LDKInitFeatures val_conv;
32045         val_conv.inner = untag_ptr(val);
32046         val_conv.is_owned = ptr_is_owned(val);
32047         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32048         val_conv = InitFeatures_clone(&val_conv);
32049         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
32050 }
32051
32052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32053         LDKChannelCounterparty this_ptr_conv;
32054         this_ptr_conv.inner = untag_ptr(this_ptr);
32055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32057         this_ptr_conv.is_owned = false;
32058         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
32059         return ret_conv;
32060 }
32061
32062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32063         LDKChannelCounterparty this_ptr_conv;
32064         this_ptr_conv.inner = untag_ptr(this_ptr);
32065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32067         this_ptr_conv.is_owned = false;
32068         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
32069 }
32070
32071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
32072         LDKChannelCounterparty this_ptr_conv;
32073         this_ptr_conv.inner = untag_ptr(this_ptr);
32074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32076         this_ptr_conv.is_owned = false;
32077         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
32078         int64_t ret_ref = 0;
32079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32080         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32081         return ret_ref;
32082 }
32083
32084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32085         LDKChannelCounterparty this_ptr_conv;
32086         this_ptr_conv.inner = untag_ptr(this_ptr);
32087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         this_ptr_conv.is_owned = false;
32090         LDKCounterpartyForwardingInfo val_conv;
32091         val_conv.inner = untag_ptr(val);
32092         val_conv.is_owned = ptr_is_owned(val);
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32094         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
32095         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
32096 }
32097
32098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32099         LDKChannelCounterparty this_ptr_conv;
32100         this_ptr_conv.inner = untag_ptr(this_ptr);
32101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32103         this_ptr_conv.is_owned = false;
32104         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32105         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
32106         int64_t ret_ref = tag_ptr(ret_copy, true);
32107         return ret_ref;
32108 }
32109
32110 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) {
32111         LDKChannelCounterparty this_ptr_conv;
32112         this_ptr_conv.inner = untag_ptr(this_ptr);
32113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32115         this_ptr_conv.is_owned = false;
32116         void* val_ptr = untag_ptr(val);
32117         CHECK_ACCESS(val_ptr);
32118         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32119         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32120         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32121 }
32122
32123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32124         LDKChannelCounterparty this_ptr_conv;
32125         this_ptr_conv.inner = untag_ptr(this_ptr);
32126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32128         this_ptr_conv.is_owned = false;
32129         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32130         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
32131         int64_t ret_ref = tag_ptr(ret_copy, true);
32132         return ret_ref;
32133 }
32134
32135 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) {
32136         LDKChannelCounterparty this_ptr_conv;
32137         this_ptr_conv.inner = untag_ptr(this_ptr);
32138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32140         this_ptr_conv.is_owned = false;
32141         void* val_ptr = untag_ptr(val);
32142         CHECK_ACCESS(val_ptr);
32143         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32144         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32145         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32146 }
32147
32148 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) {
32149         LDKPublicKey node_id_arg_ref;
32150         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
32151         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
32152         LDKInitFeatures features_arg_conv;
32153         features_arg_conv.inner = untag_ptr(features_arg);
32154         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32155         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32156         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32157         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
32158         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
32159         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
32160         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
32161         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
32162         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
32163         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
32164         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
32165         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
32166         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
32167         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
32168         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
32169         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
32170         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);
32171         int64_t ret_ref = 0;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32174         return ret_ref;
32175 }
32176
32177 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
32178         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
32179         int64_t ret_ref = 0;
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32182         return ret_ref;
32183 }
32184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32185         LDKChannelCounterparty arg_conv;
32186         arg_conv.inner = untag_ptr(arg);
32187         arg_conv.is_owned = ptr_is_owned(arg);
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32189         arg_conv.is_owned = false;
32190         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
32191         return ret_conv;
32192 }
32193
32194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32195         LDKChannelCounterparty orig_conv;
32196         orig_conv.inner = untag_ptr(orig);
32197         orig_conv.is_owned = ptr_is_owned(orig);
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32199         orig_conv.is_owned = false;
32200         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
32201         int64_t ret_ref = 0;
32202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32204         return ret_ref;
32205 }
32206
32207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32208         LDKChannelDetails this_obj_conv;
32209         this_obj_conv.inner = untag_ptr(this_obj);
32210         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32212         ChannelDetails_free(this_obj_conv);
32213 }
32214
32215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32216         LDKChannelDetails this_ptr_conv;
32217         this_ptr_conv.inner = untag_ptr(this_ptr);
32218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32220         this_ptr_conv.is_owned = false;
32221         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32222         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
32223         return ret_arr;
32224 }
32225
32226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32227         LDKChannelDetails this_ptr_conv;
32228         this_ptr_conv.inner = untag_ptr(this_ptr);
32229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32231         this_ptr_conv.is_owned = false;
32232         LDKThirtyTwoBytes val_ref;
32233         CHECK((*env)->GetArrayLength(env, val) == 32);
32234         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32235         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
32236 }
32237
32238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
32239         LDKChannelDetails this_ptr_conv;
32240         this_ptr_conv.inner = untag_ptr(this_ptr);
32241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32243         this_ptr_conv.is_owned = false;
32244         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
32245         int64_t ret_ref = 0;
32246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32248         return ret_ref;
32249 }
32250
32251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32252         LDKChannelDetails this_ptr_conv;
32253         this_ptr_conv.inner = untag_ptr(this_ptr);
32254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32256         this_ptr_conv.is_owned = false;
32257         LDKChannelCounterparty val_conv;
32258         val_conv.inner = untag_ptr(val);
32259         val_conv.is_owned = ptr_is_owned(val);
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32261         val_conv = ChannelCounterparty_clone(&val_conv);
32262         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
32263 }
32264
32265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
32266         LDKChannelDetails this_ptr_conv;
32267         this_ptr_conv.inner = untag_ptr(this_ptr);
32268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32270         this_ptr_conv.is_owned = false;
32271         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
32272         int64_t ret_ref = 0;
32273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32275         return ret_ref;
32276 }
32277
32278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32279         LDKChannelDetails this_ptr_conv;
32280         this_ptr_conv.inner = untag_ptr(this_ptr);
32281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32283         this_ptr_conv.is_owned = false;
32284         LDKOutPoint val_conv;
32285         val_conv.inner = untag_ptr(val);
32286         val_conv.is_owned = ptr_is_owned(val);
32287         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32288         val_conv = OutPoint_clone(&val_conv);
32289         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
32290 }
32291
32292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32293         LDKChannelDetails this_ptr_conv;
32294         this_ptr_conv.inner = untag_ptr(this_ptr);
32295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32297         this_ptr_conv.is_owned = false;
32298         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
32299         int64_t ret_ref = 0;
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32301         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32302         return ret_ref;
32303 }
32304
32305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32306         LDKChannelDetails this_ptr_conv;
32307         this_ptr_conv.inner = untag_ptr(this_ptr);
32308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32310         this_ptr_conv.is_owned = false;
32311         LDKChannelTypeFeatures val_conv;
32312         val_conv.inner = untag_ptr(val);
32313         val_conv.is_owned = ptr_is_owned(val);
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32315         val_conv = ChannelTypeFeatures_clone(&val_conv);
32316         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
32317 }
32318
32319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32320         LDKChannelDetails this_ptr_conv;
32321         this_ptr_conv.inner = untag_ptr(this_ptr);
32322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32324         this_ptr_conv.is_owned = false;
32325         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32326         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
32327         int64_t ret_ref = tag_ptr(ret_copy, true);
32328         return ret_ref;
32329 }
32330
32331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32332         LDKChannelDetails this_ptr_conv;
32333         this_ptr_conv.inner = untag_ptr(this_ptr);
32334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32336         this_ptr_conv.is_owned = false;
32337         void* val_ptr = untag_ptr(val);
32338         CHECK_ACCESS(val_ptr);
32339         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32340         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32341         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
32342 }
32343
32344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32345         LDKChannelDetails this_ptr_conv;
32346         this_ptr_conv.inner = untag_ptr(this_ptr);
32347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32349         this_ptr_conv.is_owned = false;
32350         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32351         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
32352         int64_t ret_ref = tag_ptr(ret_copy, true);
32353         return ret_ref;
32354 }
32355
32356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32357         LDKChannelDetails this_ptr_conv;
32358         this_ptr_conv.inner = untag_ptr(this_ptr);
32359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32361         this_ptr_conv.is_owned = false;
32362         void* val_ptr = untag_ptr(val);
32363         CHECK_ACCESS(val_ptr);
32364         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32365         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32366         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
32367 }
32368
32369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32370         LDKChannelDetails this_ptr_conv;
32371         this_ptr_conv.inner = untag_ptr(this_ptr);
32372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32374         this_ptr_conv.is_owned = false;
32375         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32376         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
32377         int64_t ret_ref = tag_ptr(ret_copy, true);
32378         return ret_ref;
32379 }
32380
32381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32382         LDKChannelDetails this_ptr_conv;
32383         this_ptr_conv.inner = untag_ptr(this_ptr);
32384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32386         this_ptr_conv.is_owned = false;
32387         void* val_ptr = untag_ptr(val);
32388         CHECK_ACCESS(val_ptr);
32389         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32390         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32391         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
32392 }
32393
32394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32395         LDKChannelDetails this_ptr_conv;
32396         this_ptr_conv.inner = untag_ptr(this_ptr);
32397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32399         this_ptr_conv.is_owned = false;
32400         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
32401         return ret_conv;
32402 }
32403
32404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32405         LDKChannelDetails this_ptr_conv;
32406         this_ptr_conv.inner = untag_ptr(this_ptr);
32407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32409         this_ptr_conv.is_owned = false;
32410         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
32411 }
32412
32413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32414         LDKChannelDetails this_ptr_conv;
32415         this_ptr_conv.inner = untag_ptr(this_ptr);
32416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32418         this_ptr_conv.is_owned = false;
32419         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32420         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
32421         int64_t ret_ref = tag_ptr(ret_copy, true);
32422         return ret_ref;
32423 }
32424
32425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32426         LDKChannelDetails this_ptr_conv;
32427         this_ptr_conv.inner = untag_ptr(this_ptr);
32428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32430         this_ptr_conv.is_owned = false;
32431         void* val_ptr = untag_ptr(val);
32432         CHECK_ACCESS(val_ptr);
32433         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32434         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32435         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
32436 }
32437
32438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32439         LDKChannelDetails this_ptr_conv;
32440         this_ptr_conv.inner = untag_ptr(this_ptr);
32441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         this_ptr_conv.is_owned = false;
32444         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
32445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
32446         return ret_arr;
32447 }
32448
32449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32450         LDKChannelDetails this_ptr_conv;
32451         this_ptr_conv.inner = untag_ptr(this_ptr);
32452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32454         this_ptr_conv.is_owned = false;
32455         LDKU128 val_ref;
32456         CHECK((*env)->GetArrayLength(env, val) == 16);
32457         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
32458         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
32459 }
32460
32461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr) {
32462         LDKChannelDetails this_ptr_conv;
32463         this_ptr_conv.inner = untag_ptr(this_ptr);
32464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32466         this_ptr_conv.is_owned = false;
32467         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32468         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
32469         int64_t ret_ref = tag_ptr(ret_copy, true);
32470         return ret_ref;
32471 }
32472
32473 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) {
32474         LDKChannelDetails this_ptr_conv;
32475         this_ptr_conv.inner = untag_ptr(this_ptr);
32476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32478         this_ptr_conv.is_owned = false;
32479         void* val_ptr = untag_ptr(val);
32480         CHECK_ACCESS(val_ptr);
32481         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32482         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32483         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
32484 }
32485
32486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32487         LDKChannelDetails this_ptr_conv;
32488         this_ptr_conv.inner = untag_ptr(this_ptr);
32489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32491         this_ptr_conv.is_owned = false;
32492         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
32493         return ret_conv;
32494 }
32495
32496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32497         LDKChannelDetails this_ptr_conv;
32498         this_ptr_conv.inner = untag_ptr(this_ptr);
32499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32501         this_ptr_conv.is_owned = false;
32502         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
32503 }
32504
32505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32506         LDKChannelDetails this_ptr_conv;
32507         this_ptr_conv.inner = untag_ptr(this_ptr);
32508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32510         this_ptr_conv.is_owned = false;
32511         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
32512         return ret_conv;
32513 }
32514
32515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32516         LDKChannelDetails this_ptr_conv;
32517         this_ptr_conv.inner = untag_ptr(this_ptr);
32518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32520         this_ptr_conv.is_owned = false;
32521         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
32522 }
32523
32524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32525         LDKChannelDetails this_ptr_conv;
32526         this_ptr_conv.inner = untag_ptr(this_ptr);
32527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32529         this_ptr_conv.is_owned = false;
32530         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
32531         return ret_conv;
32532 }
32533
32534 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) {
32535         LDKChannelDetails this_ptr_conv;
32536         this_ptr_conv.inner = untag_ptr(this_ptr);
32537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32539         this_ptr_conv.is_owned = false;
32540         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32541 }
32542
32543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32544         LDKChannelDetails this_ptr_conv;
32545         this_ptr_conv.inner = untag_ptr(this_ptr);
32546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32548         this_ptr_conv.is_owned = false;
32549         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32550         return ret_conv;
32551 }
32552
32553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32554         LDKChannelDetails this_ptr_conv;
32555         this_ptr_conv.inner = untag_ptr(this_ptr);
32556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32558         this_ptr_conv.is_owned = false;
32559         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32560 }
32561
32562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32563         LDKChannelDetails this_ptr_conv;
32564         this_ptr_conv.inner = untag_ptr(this_ptr);
32565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32567         this_ptr_conv.is_owned = false;
32568         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32569         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32570         int64_t ret_ref = tag_ptr(ret_copy, true);
32571         return ret_ref;
32572 }
32573
32574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32575         LDKChannelDetails this_ptr_conv;
32576         this_ptr_conv.inner = untag_ptr(this_ptr);
32577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32579         this_ptr_conv.is_owned = false;
32580         void* val_ptr = untag_ptr(val);
32581         CHECK_ACCESS(val_ptr);
32582         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32583         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32584         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32585 }
32586
32587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32588         LDKChannelDetails this_ptr_conv;
32589         this_ptr_conv.inner = untag_ptr(this_ptr);
32590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32592         this_ptr_conv.is_owned = false;
32593         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32594         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32595         int64_t ret_ref = tag_ptr(ret_copy, true);
32596         return ret_ref;
32597 }
32598
32599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32600         LDKChannelDetails this_ptr_conv;
32601         this_ptr_conv.inner = untag_ptr(this_ptr);
32602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32604         this_ptr_conv.is_owned = false;
32605         void* val_ptr = untag_ptr(val);
32606         CHECK_ACCESS(val_ptr);
32607         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32608         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32609         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32610 }
32611
32612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32613         LDKChannelDetails this_ptr_conv;
32614         this_ptr_conv.inner = untag_ptr(this_ptr);
32615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32617         this_ptr_conv.is_owned = false;
32618         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32619         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32620         int64_t ret_ref = tag_ptr(ret_copy, true);
32621         return ret_ref;
32622 }
32623
32624 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) {
32625         LDKChannelDetails this_ptr_conv;
32626         this_ptr_conv.inner = untag_ptr(this_ptr);
32627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32629         this_ptr_conv.is_owned = false;
32630         void* val_ptr = untag_ptr(val);
32631         CHECK_ACCESS(val_ptr);
32632         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32633         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32634         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32635 }
32636
32637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32638         LDKChannelDetails this_ptr_conv;
32639         this_ptr_conv.inner = untag_ptr(this_ptr);
32640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32642         this_ptr_conv.is_owned = false;
32643         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32644         return ret_conv;
32645 }
32646
32647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32648         LDKChannelDetails this_ptr_conv;
32649         this_ptr_conv.inner = untag_ptr(this_ptr);
32650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32652         this_ptr_conv.is_owned = false;
32653         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32654 }
32655
32656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32657         LDKChannelDetails this_ptr_conv;
32658         this_ptr_conv.inner = untag_ptr(this_ptr);
32659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32661         this_ptr_conv.is_owned = false;
32662         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32663         return ret_conv;
32664 }
32665
32666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32667         LDKChannelDetails this_ptr_conv;
32668         this_ptr_conv.inner = untag_ptr(this_ptr);
32669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32671         this_ptr_conv.is_owned = false;
32672         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32673 }
32674
32675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32676         LDKChannelDetails this_ptr_conv;
32677         this_ptr_conv.inner = untag_ptr(this_ptr);
32678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32680         this_ptr_conv.is_owned = false;
32681         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32682         return ret_conv;
32683 }
32684
32685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32686         LDKChannelDetails this_ptr_conv;
32687         this_ptr_conv.inner = untag_ptr(this_ptr);
32688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32690         this_ptr_conv.is_owned = false;
32691         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32692 }
32693
32694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32695         LDKChannelDetails this_ptr_conv;
32696         this_ptr_conv.inner = untag_ptr(this_ptr);
32697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32699         this_ptr_conv.is_owned = false;
32700         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32701         return ret_conv;
32702 }
32703
32704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32705         LDKChannelDetails this_ptr_conv;
32706         this_ptr_conv.inner = untag_ptr(this_ptr);
32707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32709         this_ptr_conv.is_owned = false;
32710         ChannelDetails_set_is_public(&this_ptr_conv, val);
32711 }
32712
32713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32714         LDKChannelDetails this_ptr_conv;
32715         this_ptr_conv.inner = untag_ptr(this_ptr);
32716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32718         this_ptr_conv.is_owned = false;
32719         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32720         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32721         int64_t ret_ref = tag_ptr(ret_copy, true);
32722         return ret_ref;
32723 }
32724
32725 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) {
32726         LDKChannelDetails this_ptr_conv;
32727         this_ptr_conv.inner = untag_ptr(this_ptr);
32728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32730         this_ptr_conv.is_owned = false;
32731         void* val_ptr = untag_ptr(val);
32732         CHECK_ACCESS(val_ptr);
32733         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32734         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32735         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32736 }
32737
32738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32739         LDKChannelDetails this_ptr_conv;
32740         this_ptr_conv.inner = untag_ptr(this_ptr);
32741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32743         this_ptr_conv.is_owned = false;
32744         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32745         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32746         int64_t ret_ref = tag_ptr(ret_copy, true);
32747         return ret_ref;
32748 }
32749
32750 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) {
32751         LDKChannelDetails this_ptr_conv;
32752         this_ptr_conv.inner = untag_ptr(this_ptr);
32753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32755         this_ptr_conv.is_owned = false;
32756         void* val_ptr = untag_ptr(val);
32757         CHECK_ACCESS(val_ptr);
32758         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32759         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32760         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32761 }
32762
32763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32764         LDKChannelDetails this_ptr_conv;
32765         this_ptr_conv.inner = untag_ptr(this_ptr);
32766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32768         this_ptr_conv.is_owned = false;
32769         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32770         int64_t ret_ref = 0;
32771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32773         return ret_ref;
32774 }
32775
32776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32777         LDKChannelDetails this_ptr_conv;
32778         this_ptr_conv.inner = untag_ptr(this_ptr);
32779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32781         this_ptr_conv.is_owned = false;
32782         LDKChannelConfig val_conv;
32783         val_conv.inner = untag_ptr(val);
32784         val_conv.is_owned = ptr_is_owned(val);
32785         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32786         val_conv = ChannelConfig_clone(&val_conv);
32787         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32788 }
32789
32790 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) {
32791         LDKThirtyTwoBytes channel_id_arg_ref;
32792         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32793         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32794         LDKChannelCounterparty counterparty_arg_conv;
32795         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32796         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32797         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32798         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32799         LDKOutPoint funding_txo_arg_conv;
32800         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32801         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32802         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32803         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32804         LDKChannelTypeFeatures channel_type_arg_conv;
32805         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32806         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32807         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32808         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32809         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32810         CHECK_ACCESS(short_channel_id_arg_ptr);
32811         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32812         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32813         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32814         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32815         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32816         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32817         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32818         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32819         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32820         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32821         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32822         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32823         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32824         LDKU128 user_channel_id_arg_ref;
32825         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32826         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32827         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
32828         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
32829         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
32830         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
32831         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32832         CHECK_ACCESS(confirmations_required_arg_ptr);
32833         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32834         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32835         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32836         CHECK_ACCESS(confirmations_arg_ptr);
32837         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32838         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32839         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32840         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32841         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32842         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32843         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32844         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32845         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32846         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32847         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32848         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32849         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32850         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32851         LDKChannelConfig config_arg_conv;
32852         config_arg_conv.inner = untag_ptr(config_arg);
32853         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32855         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32856         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);
32857         int64_t ret_ref = 0;
32858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32860         return ret_ref;
32861 }
32862
32863 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32864         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32865         int64_t ret_ref = 0;
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32868         return ret_ref;
32869 }
32870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32871         LDKChannelDetails arg_conv;
32872         arg_conv.inner = untag_ptr(arg);
32873         arg_conv.is_owned = ptr_is_owned(arg);
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32875         arg_conv.is_owned = false;
32876         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32877         return ret_conv;
32878 }
32879
32880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32881         LDKChannelDetails orig_conv;
32882         orig_conv.inner = untag_ptr(orig);
32883         orig_conv.is_owned = ptr_is_owned(orig);
32884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32885         orig_conv.is_owned = false;
32886         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32887         int64_t ret_ref = 0;
32888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32890         return ret_ref;
32891 }
32892
32893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32894         LDKChannelDetails this_arg_conv;
32895         this_arg_conv.inner = untag_ptr(this_arg);
32896         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32898         this_arg_conv.is_owned = false;
32899         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32900         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32901         int64_t ret_ref = tag_ptr(ret_copy, true);
32902         return ret_ref;
32903 }
32904
32905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32906         LDKChannelDetails this_arg_conv;
32907         this_arg_conv.inner = untag_ptr(this_arg);
32908         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32910         this_arg_conv.is_owned = false;
32911         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32912         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32913         int64_t ret_ref = tag_ptr(ret_copy, true);
32914         return ret_ref;
32915 }
32916
32917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32918         if (!ptr_is_owned(this_ptr)) return;
32919         void* this_ptr_ptr = untag_ptr(this_ptr);
32920         CHECK_ACCESS(this_ptr_ptr);
32921         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
32922         FREE(untag_ptr(this_ptr));
32923         RecentPaymentDetails_free(this_ptr_conv);
32924 }
32925
32926 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
32927         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32928         *ret_copy = RecentPaymentDetails_clone(arg);
32929         int64_t ret_ref = tag_ptr(ret_copy, true);
32930         return ret_ref;
32931 }
32932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32933         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
32934         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
32935         return ret_conv;
32936 }
32937
32938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32939         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
32940         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32941         *ret_copy = RecentPaymentDetails_clone(orig_conv);
32942         int64_t ret_ref = tag_ptr(ret_copy, true);
32943         return ret_ref;
32944 }
32945
32946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1pending(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t total_msat) {
32947         LDKThirtyTwoBytes payment_hash_ref;
32948         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32949         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32950         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32951         *ret_copy = RecentPaymentDetails_pending(payment_hash_ref, total_msat);
32952         int64_t ret_ref = tag_ptr(ret_copy, true);
32953         return ret_ref;
32954 }
32955
32956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1fulfilled(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32957         LDKThirtyTwoBytes payment_hash_ref;
32958         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32959         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32960         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32961         *ret_copy = RecentPaymentDetails_fulfilled(payment_hash_ref);
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_1abandoned(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
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_abandoned(payment_hash_ref);
32972         int64_t ret_ref = tag_ptr(ret_copy, true);
32973         return ret_ref;
32974 }
32975
32976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32977         LDKPhantomRouteHints this_obj_conv;
32978         this_obj_conv.inner = untag_ptr(this_obj);
32979         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32981         PhantomRouteHints_free(this_obj_conv);
32982 }
32983
32984 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
32985         LDKPhantomRouteHints this_ptr_conv;
32986         this_ptr_conv.inner = untag_ptr(this_ptr);
32987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32989         this_ptr_conv.is_owned = false;
32990         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
32991         int64_tArray ret_arr = NULL;
32992         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32993         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32994         for (size_t q = 0; q < ret_var.datalen; q++) {
32995                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32996                 int64_t ret_conv_16_ref = 0;
32997                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32998                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32999                 ret_arr_ptr[q] = ret_conv_16_ref;
33000         }
33001         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33002         FREE(ret_var.data);
33003         return ret_arr;
33004 }
33005
33006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33007         LDKPhantomRouteHints this_ptr_conv;
33008         this_ptr_conv.inner = untag_ptr(this_ptr);
33009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33011         this_ptr_conv.is_owned = false;
33012         LDKCVec_ChannelDetailsZ val_constr;
33013         val_constr.datalen = (*env)->GetArrayLength(env, val);
33014         if (val_constr.datalen > 0)
33015                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33016         else
33017                 val_constr.data = NULL;
33018         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33019         for (size_t q = 0; q < val_constr.datalen; q++) {
33020                 int64_t val_conv_16 = val_vals[q];
33021                 LDKChannelDetails val_conv_16_conv;
33022                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
33023                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
33024                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33025                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
33026                 val_constr.data[q] = val_conv_16_conv;
33027         }
33028         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33029         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
33030 }
33031
33032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33033         LDKPhantomRouteHints this_ptr_conv;
33034         this_ptr_conv.inner = untag_ptr(this_ptr);
33035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33037         this_ptr_conv.is_owned = false;
33038         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
33039         return ret_conv;
33040 }
33041
33042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33043         LDKPhantomRouteHints this_ptr_conv;
33044         this_ptr_conv.inner = untag_ptr(this_ptr);
33045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33047         this_ptr_conv.is_owned = false;
33048         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
33049 }
33050
33051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33052         LDKPhantomRouteHints this_ptr_conv;
33053         this_ptr_conv.inner = untag_ptr(this_ptr);
33054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33056         this_ptr_conv.is_owned = false;
33057         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33058         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
33059         return ret_arr;
33060 }
33061
33062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
33069         CHECK((*env)->GetArrayLength(env, val) == 33);
33070         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33071         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
33072 }
33073
33074 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) {
33075         LDKCVec_ChannelDetailsZ channels_arg_constr;
33076         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
33077         if (channels_arg_constr.datalen > 0)
33078                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33079         else
33080                 channels_arg_constr.data = NULL;
33081         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
33082         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
33083                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
33084                 LDKChannelDetails channels_arg_conv_16_conv;
33085                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
33086                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
33087                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
33088                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
33089                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
33090         }
33091         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
33092         LDKPublicKey real_node_pubkey_arg_ref;
33093         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
33094         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
33095         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
33096         int64_t ret_ref = 0;
33097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33099         return ret_ref;
33100 }
33101
33102 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
33103         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
33104         int64_t ret_ref = 0;
33105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33107         return ret_ref;
33108 }
33109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33110         LDKPhantomRouteHints arg_conv;
33111         arg_conv.inner = untag_ptr(arg);
33112         arg_conv.is_owned = ptr_is_owned(arg);
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33114         arg_conv.is_owned = false;
33115         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
33116         return ret_conv;
33117 }
33118
33119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33120         LDKPhantomRouteHints orig_conv;
33121         orig_conv.inner = untag_ptr(orig);
33122         orig_conv.is_owned = ptr_is_owned(orig);
33123         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33124         orig_conv.is_owned = false;
33125         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
33126         int64_t ret_ref = 0;
33127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33128         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33129         return ret_ref;
33130 }
33131
33132 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) {
33133         void* fee_est_ptr = untag_ptr(fee_est);
33134         CHECK_ACCESS(fee_est_ptr);
33135         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
33136         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
33137                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33138                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
33139         }
33140         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33141         CHECK_ACCESS(chain_monitor_ptr);
33142         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33143         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33144                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33145                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33146         }
33147         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33148         CHECK_ACCESS(tx_broadcaster_ptr);
33149         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33150         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33152                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33153         }
33154         void* router_ptr = untag_ptr(router);
33155         CHECK_ACCESS(router_ptr);
33156         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33157         if (router_conv.free == LDKRouter_JCalls_free) {
33158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33159                 LDKRouter_JCalls_cloned(&router_conv);
33160         }
33161         void* logger_ptr = untag_ptr(logger);
33162         CHECK_ACCESS(logger_ptr);
33163         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33164         if (logger_conv.free == LDKLogger_JCalls_free) {
33165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33166                 LDKLogger_JCalls_cloned(&logger_conv);
33167         }
33168         void* entropy_source_ptr = untag_ptr(entropy_source);
33169         CHECK_ACCESS(entropy_source_ptr);
33170         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
33171         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
33172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33173                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
33174         }
33175         void* node_signer_ptr = untag_ptr(node_signer);
33176         CHECK_ACCESS(node_signer_ptr);
33177         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
33178         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
33179                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33180                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
33181         }
33182         void* signer_provider_ptr = untag_ptr(signer_provider);
33183         CHECK_ACCESS(signer_provider_ptr);
33184         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
33185         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
33186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33187                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
33188         }
33189         LDKUserConfig config_conv;
33190         config_conv.inner = untag_ptr(config);
33191         config_conv.is_owned = ptr_is_owned(config);
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33193         config_conv = UserConfig_clone(&config_conv);
33194         LDKChainParameters params_conv;
33195         params_conv.inner = untag_ptr(params);
33196         params_conv.is_owned = ptr_is_owned(params);
33197         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
33198         params_conv = ChainParameters_clone(&params_conv);
33199         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);
33200         int64_t ret_ref = 0;
33201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33203         return ret_ref;
33204 }
33205
33206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
33207         LDKChannelManager this_arg_conv;
33208         this_arg_conv.inner = untag_ptr(this_arg);
33209         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33211         this_arg_conv.is_owned = false;
33212         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
33213         int64_t ret_ref = 0;
33214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33216         return ret_ref;
33217 }
33218
33219 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) {
33220         LDKChannelManager this_arg_conv;
33221         this_arg_conv.inner = untag_ptr(this_arg);
33222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33224         this_arg_conv.is_owned = false;
33225         LDKPublicKey their_network_key_ref;
33226         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
33227         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
33228         LDKU128 user_channel_id_ref;
33229         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33230         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33231         LDKUserConfig override_config_conv;
33232         override_config_conv.inner = untag_ptr(override_config);
33233         override_config_conv.is_owned = ptr_is_owned(override_config);
33234         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
33235         override_config_conv = UserConfig_clone(&override_config_conv);
33236         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
33237         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
33238         return tag_ptr(ret_conv, true);
33239 }
33240
33241 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33242         LDKChannelManager this_arg_conv;
33243         this_arg_conv.inner = untag_ptr(this_arg);
33244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33246         this_arg_conv.is_owned = false;
33247         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
33248         int64_tArray ret_arr = NULL;
33249         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33250         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33251         for (size_t q = 0; q < ret_var.datalen; q++) {
33252                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33253                 int64_t ret_conv_16_ref = 0;
33254                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33255                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33256                 ret_arr_ptr[q] = ret_conv_16_ref;
33257         }
33258         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33259         FREE(ret_var.data);
33260         return ret_arr;
33261 }
33262
33263 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33264         LDKChannelManager this_arg_conv;
33265         this_arg_conv.inner = untag_ptr(this_arg);
33266         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33268         this_arg_conv.is_owned = false;
33269         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
33270         int64_tArray ret_arr = NULL;
33271         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33272         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33273         for (size_t q = 0; q < ret_var.datalen; q++) {
33274                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33275                 int64_t ret_conv_16_ref = 0;
33276                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33277                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33278                 ret_arr_ptr[q] = ret_conv_16_ref;
33279         }
33280         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33281         FREE(ret_var.data);
33282         return ret_arr;
33283 }
33284
33285 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) {
33286         LDKChannelManager this_arg_conv;
33287         this_arg_conv.inner = untag_ptr(this_arg);
33288         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33290         this_arg_conv.is_owned = false;
33291         LDKPublicKey counterparty_node_id_ref;
33292         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33293         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33294         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
33295         int64_tArray ret_arr = NULL;
33296         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33297         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33298         for (size_t q = 0; q < ret_var.datalen; q++) {
33299                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33300                 int64_t ret_conv_16_ref = 0;
33301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33302                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33303                 ret_arr_ptr[q] = ret_conv_16_ref;
33304         }
33305         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33306         FREE(ret_var.data);
33307         return ret_arr;
33308 }
33309
33310 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1recent_1payments(JNIEnv *env, jclass clz, int64_t this_arg) {
33311         LDKChannelManager this_arg_conv;
33312         this_arg_conv.inner = untag_ptr(this_arg);
33313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33315         this_arg_conv.is_owned = false;
33316         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
33317         int64_tArray ret_arr = NULL;
33318         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33319         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33320         for (size_t w = 0; w < ret_var.datalen; w++) {
33321                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
33322                 *ret_conv_22_copy = ret_var.data[w];
33323                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
33324                 ret_arr_ptr[w] = ret_conv_22_ref;
33325         }
33326         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33327         FREE(ret_var.data);
33328         return ret_arr;
33329 }
33330
33331 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) {
33332         LDKChannelManager this_arg_conv;
33333         this_arg_conv.inner = untag_ptr(this_arg);
33334         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33336         this_arg_conv.is_owned = false;
33337         uint8_t channel_id_arr[32];
33338         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33339         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33340         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33341         LDKPublicKey counterparty_node_id_ref;
33342         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33343         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33344         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33345         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33346         return tag_ptr(ret_conv, true);
33347 }
33348
33349 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) {
33350         LDKChannelManager this_arg_conv;
33351         this_arg_conv.inner = untag_ptr(this_arg);
33352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33354         this_arg_conv.is_owned = false;
33355         uint8_t channel_id_arr[32];
33356         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33357         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33358         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33359         LDKPublicKey counterparty_node_id_ref;
33360         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33361         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33362         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33363         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
33364         return tag_ptr(ret_conv, true);
33365 }
33366
33367 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) {
33368         LDKChannelManager this_arg_conv;
33369         this_arg_conv.inner = untag_ptr(this_arg);
33370         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33372         this_arg_conv.is_owned = false;
33373         uint8_t channel_id_arr[32];
33374         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33375         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33376         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33377         LDKPublicKey counterparty_node_id_ref;
33378         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33379         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33380         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33381         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33382         return tag_ptr(ret_conv, true);
33383 }
33384
33385 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) {
33386         LDKChannelManager this_arg_conv;
33387         this_arg_conv.inner = untag_ptr(this_arg);
33388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33390         this_arg_conv.is_owned = false;
33391         uint8_t channel_id_arr[32];
33392         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33393         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33394         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33395         LDKPublicKey counterparty_node_id_ref;
33396         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33397         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33398         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33399         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33400         return tag_ptr(ret_conv, true);
33401 }
33402
33403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33404         LDKChannelManager this_arg_conv;
33405         this_arg_conv.inner = untag_ptr(this_arg);
33406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33408         this_arg_conv.is_owned = false;
33409         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
33410 }
33411
33412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33413         LDKChannelManager this_arg_conv;
33414         this_arg_conv.inner = untag_ptr(this_arg);
33415         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33417         this_arg_conv.is_owned = false;
33418         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
33419 }
33420
33421 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) {
33422         LDKChannelManager this_arg_conv;
33423         this_arg_conv.inner = untag_ptr(this_arg);
33424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33426         this_arg_conv.is_owned = false;
33427         LDKRoute route_conv;
33428         route_conv.inner = untag_ptr(route);
33429         route_conv.is_owned = ptr_is_owned(route);
33430         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33431         route_conv.is_owned = false;
33432         LDKThirtyTwoBytes payment_hash_ref;
33433         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33434         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33435         LDKRecipientOnionFields recipient_onion_conv;
33436         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33437         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33438         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33439         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33440         LDKThirtyTwoBytes payment_id_ref;
33441         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33442         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33443         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
33444         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
33445         return tag_ptr(ret_conv, true);
33446 }
33447
33448 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) {
33449         LDKChannelManager this_arg_conv;
33450         this_arg_conv.inner = untag_ptr(this_arg);
33451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33453         this_arg_conv.is_owned = false;
33454         LDKThirtyTwoBytes payment_hash_ref;
33455         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33456         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33457         LDKRecipientOnionFields recipient_onion_conv;
33458         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33459         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33460         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33461         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33462         LDKThirtyTwoBytes payment_id_ref;
33463         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33464         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33465         LDKRouteParameters route_params_conv;
33466         route_params_conv.inner = untag_ptr(route_params);
33467         route_params_conv.is_owned = ptr_is_owned(route_params);
33468         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33469         route_params_conv = RouteParameters_clone(&route_params_conv);
33470         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33471         CHECK_ACCESS(retry_strategy_ptr);
33472         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33473         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33474         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
33475         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33476         return tag_ptr(ret_conv, true);
33477 }
33478
33479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
33480         LDKChannelManager this_arg_conv;
33481         this_arg_conv.inner = untag_ptr(this_arg);
33482         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33484         this_arg_conv.is_owned = false;
33485         LDKThirtyTwoBytes payment_id_ref;
33486         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33487         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33488         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
33489 }
33490
33491 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) {
33492         LDKChannelManager this_arg_conv;
33493         this_arg_conv.inner = untag_ptr(this_arg);
33494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33496         this_arg_conv.is_owned = false;
33497         LDKRoute route_conv;
33498         route_conv.inner = untag_ptr(route);
33499         route_conv.is_owned = ptr_is_owned(route);
33500         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33501         route_conv.is_owned = false;
33502         LDKThirtyTwoBytes payment_preimage_ref;
33503         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33504         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33505         LDKRecipientOnionFields recipient_onion_conv;
33506         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33507         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33508         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33509         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33510         LDKThirtyTwoBytes payment_id_ref;
33511         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33512         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33513         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
33514         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref);
33515         return tag_ptr(ret_conv, true);
33516 }
33517
33518 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) {
33519         LDKChannelManager this_arg_conv;
33520         this_arg_conv.inner = untag_ptr(this_arg);
33521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33523         this_arg_conv.is_owned = false;
33524         LDKThirtyTwoBytes payment_preimage_ref;
33525         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33526         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33527         LDKRecipientOnionFields recipient_onion_conv;
33528         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33529         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33531         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33532         LDKThirtyTwoBytes payment_id_ref;
33533         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33534         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33535         LDKRouteParameters route_params_conv;
33536         route_params_conv.inner = untag_ptr(route_params);
33537         route_params_conv.is_owned = ptr_is_owned(route_params);
33538         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33539         route_params_conv = RouteParameters_clone(&route_params_conv);
33540         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33541         CHECK_ACCESS(retry_strategy_ptr);
33542         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33543         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33544         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
33545         *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);
33546         return tag_ptr(ret_conv, true);
33547 }
33548
33549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
33550         LDKChannelManager this_arg_conv;
33551         this_arg_conv.inner = untag_ptr(this_arg);
33552         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33554         this_arg_conv.is_owned = false;
33555         LDKPath path_conv;
33556         path_conv.inner = untag_ptr(path);
33557         path_conv.is_owned = ptr_is_owned(path);
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
33559         path_conv = Path_clone(&path_conv);
33560         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
33561         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
33562         return tag_ptr(ret_conv, true);
33563 }
33564
33565 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) {
33566         LDKChannelManager this_arg_conv;
33567         this_arg_conv.inner = untag_ptr(this_arg);
33568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33570         this_arg_conv.is_owned = false;
33571         uint8_t temporary_channel_id_arr[32];
33572         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33573         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33574         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33575         LDKPublicKey counterparty_node_id_ref;
33576         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33577         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33578         LDKTransaction funding_transaction_ref;
33579         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33580         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33581         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33582         funding_transaction_ref.data_is_owned = true;
33583         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33584         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33585         return tag_ptr(ret_conv, true);
33586 }
33587
33588 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) {
33589         LDKChannelManager this_arg_conv;
33590         this_arg_conv.inner = untag_ptr(this_arg);
33591         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33593         this_arg_conv.is_owned = false;
33594         LDKPublicKey counterparty_node_id_ref;
33595         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33596         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33597         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33598         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33599         if (channel_ids_constr.datalen > 0)
33600                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33601         else
33602                 channel_ids_constr.data = NULL;
33603         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33604                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33605                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33606                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33607                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33608                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33609         }
33610         LDKChannelConfig config_conv;
33611         config_conv.inner = untag_ptr(config);
33612         config_conv.is_owned = ptr_is_owned(config);
33613         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33614         config_conv.is_owned = false;
33615         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33616         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33617         return tag_ptr(ret_conv, true);
33618 }
33619
33620 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) {
33621         LDKChannelManager this_arg_conv;
33622         this_arg_conv.inner = untag_ptr(this_arg);
33623         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33625         this_arg_conv.is_owned = false;
33626         LDKThirtyTwoBytes intercept_id_ref;
33627         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33628         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33629         uint8_t next_hop_channel_id_arr[32];
33630         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33631         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33632         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33633         LDKPublicKey next_node_id_ref;
33634         CHECK((*env)->GetArrayLength(env, next_node_id) == 33);
33635         (*env)->GetByteArrayRegion(env, next_node_id, 0, 33, next_node_id_ref.compressed_form);
33636         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33637         *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);
33638         return tag_ptr(ret_conv, true);
33639 }
33640
33641 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) {
33642         LDKChannelManager this_arg_conv;
33643         this_arg_conv.inner = untag_ptr(this_arg);
33644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33646         this_arg_conv.is_owned = false;
33647         LDKThirtyTwoBytes intercept_id_ref;
33648         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33649         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33650         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33651         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33652         return tag_ptr(ret_conv, true);
33653 }
33654
33655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33656         LDKChannelManager this_arg_conv;
33657         this_arg_conv.inner = untag_ptr(this_arg);
33658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33660         this_arg_conv.is_owned = false;
33661         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33662 }
33663
33664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33665         LDKChannelManager this_arg_conv;
33666         this_arg_conv.inner = untag_ptr(this_arg);
33667         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33669         this_arg_conv.is_owned = false;
33670         ChannelManager_timer_tick_occurred(&this_arg_conv);
33671 }
33672
33673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33674         LDKChannelManager this_arg_conv;
33675         this_arg_conv.inner = untag_ptr(this_arg);
33676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33678         this_arg_conv.is_owned = false;
33679         uint8_t payment_hash_arr[32];
33680         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33681         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33682         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33683         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33684 }
33685
33686 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) {
33687         LDKChannelManager this_arg_conv;
33688         this_arg_conv.inner = untag_ptr(this_arg);
33689         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33691         this_arg_conv.is_owned = false;
33692         uint8_t payment_hash_arr[32];
33693         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33694         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33695         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33696         LDKFailureCode failure_code_conv = LDKFailureCode_from_java(env, failure_code);
33697         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
33698 }
33699
33700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33701         LDKChannelManager this_arg_conv;
33702         this_arg_conv.inner = untag_ptr(this_arg);
33703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33705         this_arg_conv.is_owned = false;
33706         LDKThirtyTwoBytes payment_preimage_ref;
33707         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33708         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33709         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33710 }
33711
33712 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33713         LDKChannelManager this_arg_conv;
33714         this_arg_conv.inner = untag_ptr(this_arg);
33715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33717         this_arg_conv.is_owned = false;
33718         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33719         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33720         return ret_arr;
33721 }
33722
33723 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) {
33724         LDKChannelManager this_arg_conv;
33725         this_arg_conv.inner = untag_ptr(this_arg);
33726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33728         this_arg_conv.is_owned = false;
33729         uint8_t temporary_channel_id_arr[32];
33730         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33731         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33732         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33733         LDKPublicKey counterparty_node_id_ref;
33734         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33735         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33736         LDKU128 user_channel_id_ref;
33737         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33738         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33739         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33740         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33741         return tag_ptr(ret_conv, true);
33742 }
33743
33744 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) {
33745         LDKChannelManager this_arg_conv;
33746         this_arg_conv.inner = untag_ptr(this_arg);
33747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33749         this_arg_conv.is_owned = false;
33750         uint8_t temporary_channel_id_arr[32];
33751         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33752         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33753         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33754         LDKPublicKey counterparty_node_id_ref;
33755         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33756         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33757         LDKU128 user_channel_id_ref;
33758         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33759         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33760         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33761         *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);
33762         return tag_ptr(ret_conv, true);
33763 }
33764
33765 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) {
33766         LDKChannelManager this_arg_conv;
33767         this_arg_conv.inner = untag_ptr(this_arg);
33768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33770         this_arg_conv.is_owned = false;
33771         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33772         CHECK_ACCESS(min_value_msat_ptr);
33773         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33774         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33775         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
33776         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
33777         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
33778         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
33779         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33780         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
33781         return tag_ptr(ret_conv, true);
33782 }
33783
33784 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) {
33785         LDKChannelManager this_arg_conv;
33786         this_arg_conv.inner = untag_ptr(this_arg);
33787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33789         this_arg_conv.is_owned = false;
33790         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33791         CHECK_ACCESS(min_value_msat_ptr);
33792         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33793         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33794         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33795         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33796         return tag_ptr(ret_conv, true);
33797 }
33798
33799 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) {
33800         LDKChannelManager this_arg_conv;
33801         this_arg_conv.inner = untag_ptr(this_arg);
33802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33804         this_arg_conv.is_owned = false;
33805         LDKThirtyTwoBytes payment_hash_ref;
33806         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33807         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33808         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33809         CHECK_ACCESS(min_value_msat_ptr);
33810         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33811         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33812         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
33813         CHECK_ACCESS(min_final_cltv_expiry_ptr);
33814         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
33815         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
33816         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33817         *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);
33818         return tag_ptr(ret_conv, true);
33819 }
33820
33821 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) {
33822         LDKChannelManager this_arg_conv;
33823         this_arg_conv.inner = untag_ptr(this_arg);
33824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33826         this_arg_conv.is_owned = false;
33827         LDKThirtyTwoBytes payment_hash_ref;
33828         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33829         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33830         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33831         CHECK_ACCESS(min_value_msat_ptr);
33832         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33833         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33834         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33835         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33836         return tag_ptr(ret_conv, true);
33837 }
33838
33839 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) {
33840         LDKChannelManager this_arg_conv;
33841         this_arg_conv.inner = untag_ptr(this_arg);
33842         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33844         this_arg_conv.is_owned = false;
33845         LDKThirtyTwoBytes payment_hash_ref;
33846         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33847         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33848         LDKThirtyTwoBytes payment_secret_ref;
33849         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33850         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33851         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33852         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33853         return tag_ptr(ret_conv, true);
33854 }
33855
33856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33857         LDKChannelManager this_arg_conv;
33858         this_arg_conv.inner = untag_ptr(this_arg);
33859         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33861         this_arg_conv.is_owned = false;
33862         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33863         return ret_conv;
33864 }
33865
33866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33867         LDKChannelManager this_arg_conv;
33868         this_arg_conv.inner = untag_ptr(this_arg);
33869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33871         this_arg_conv.is_owned = false;
33872         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33873         int64_t ret_ref = 0;
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33876         return ret_ref;
33877 }
33878
33879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33880         LDKChannelManager this_arg_conv;
33881         this_arg_conv.inner = untag_ptr(this_arg);
33882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33884         this_arg_conv.is_owned = false;
33885         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33886         return ret_conv;
33887 }
33888
33889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33890         LDKChannelManager this_arg_conv;
33891         this_arg_conv.inner = untag_ptr(this_arg);
33892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33894         this_arg_conv.is_owned = false;
33895         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33896         int64_t ret_ref = 0;
33897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33899         return ret_ref;
33900 }
33901
33902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33903         LDKChannelManager this_arg_conv;
33904         this_arg_conv.inner = untag_ptr(this_arg);
33905         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33907         this_arg_conv.is_owned = false;
33908         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33909         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33910         return tag_ptr(ret_ret, true);
33911 }
33912
33913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33914         LDKChannelManager this_arg_conv;
33915         this_arg_conv.inner = untag_ptr(this_arg);
33916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33918         this_arg_conv.is_owned = false;
33919         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33920         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33921         return tag_ptr(ret_ret, true);
33922 }
33923
33924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33925         LDKChannelManager this_arg_conv;
33926         this_arg_conv.inner = untag_ptr(this_arg);
33927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33929         this_arg_conv.is_owned = false;
33930         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33931         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33932         return tag_ptr(ret_ret, true);
33933 }
33934
33935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33936         LDKChannelManager this_arg_conv;
33937         this_arg_conv.inner = untag_ptr(this_arg);
33938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33940         this_arg_conv.is_owned = false;
33941         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33942         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33943         return tag_ptr(ret_ret, true);
33944 }
33945
33946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33947         LDKChannelManager this_arg_conv;
33948         this_arg_conv.inner = untag_ptr(this_arg);
33949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33951         this_arg_conv.is_owned = false;
33952         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33953         int64_t ret_ref = 0;
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33955         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33956         return ret_ref;
33957 }
33958
33959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33960         LDKChannelManager this_arg_conv;
33961         this_arg_conv.inner = untag_ptr(this_arg);
33962         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33964         this_arg_conv.is_owned = false;
33965         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33966         int64_t ret_ref = 0;
33967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33969         return ret_ref;
33970 }
33971
33972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33973         LDKChannelManager this_arg_conv;
33974         this_arg_conv.inner = untag_ptr(this_arg);
33975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33977         this_arg_conv.is_owned = false;
33978         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
33979         int64_t ret_ref = 0;
33980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33982         return ret_ref;
33983 }
33984
33985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33986         LDKChannelManager this_arg_conv;
33987         this_arg_conv.inner = untag_ptr(this_arg);
33988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33990         this_arg_conv.is_owned = false;
33991         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
33992         int64_t ret_ref = 0;
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33995         return ret_ref;
33996 }
33997
33998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1type_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33999         LDKChannelManager this_arg_conv;
34000         this_arg_conv.inner = untag_ptr(this_arg);
34001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34003         this_arg_conv.is_owned = false;
34004         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
34005         int64_t ret_ref = 0;
34006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34008         return ret_ref;
34009 }
34010
34011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34012         LDKChannelManager this_arg_conv;
34013         this_arg_conv.inner = untag_ptr(this_arg);
34014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34016         this_arg_conv.is_owned = false;
34017         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
34018         int64_t ret_ref = 0;
34019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34021         return ret_ref;
34022 }
34023
34024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34025         LDKChannelManager this_arg_conv;
34026         this_arg_conv.inner = untag_ptr(this_arg);
34027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34029         this_arg_conv.is_owned = false;
34030         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34031         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
34032         return tag_ptr(ret_ret, true);
34033 }
34034
34035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz, int64_t _config) {
34036         LDKUserConfig _config_conv;
34037         _config_conv.inner = untag_ptr(_config);
34038         _config_conv.is_owned = ptr_is_owned(_config);
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(_config_conv);
34040         _config_conv.is_owned = false;
34041         LDKInitFeatures ret_var = provided_init_features(&_config_conv);
34042         int64_t ret_ref = 0;
34043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34045         return ret_ref;
34046 }
34047
34048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
34049         LDKCounterpartyForwardingInfo obj_conv;
34050         obj_conv.inner = untag_ptr(obj);
34051         obj_conv.is_owned = ptr_is_owned(obj);
34052         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34053         obj_conv.is_owned = false;
34054         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
34055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34057         CVec_u8Z_free(ret_var);
34058         return ret_arr;
34059 }
34060
34061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34062         LDKu8slice ser_ref;
34063         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34064         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34065         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
34066         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
34067         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34068         return tag_ptr(ret_conv, true);
34069 }
34070
34071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
34072         LDKChannelCounterparty obj_conv;
34073         obj_conv.inner = untag_ptr(obj);
34074         obj_conv.is_owned = ptr_is_owned(obj);
34075         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34076         obj_conv.is_owned = false;
34077         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
34078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34080         CVec_u8Z_free(ret_var);
34081         return ret_arr;
34082 }
34083
34084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34085         LDKu8slice ser_ref;
34086         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34087         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34088         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
34089         *ret_conv = ChannelCounterparty_read(ser_ref);
34090         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34091         return tag_ptr(ret_conv, true);
34092 }
34093
34094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
34095         LDKChannelDetails obj_conv;
34096         obj_conv.inner = untag_ptr(obj);
34097         obj_conv.is_owned = ptr_is_owned(obj);
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34099         obj_conv.is_owned = false;
34100         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
34101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34103         CVec_u8Z_free(ret_var);
34104         return ret_arr;
34105 }
34106
34107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34108         LDKu8slice ser_ref;
34109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34111         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
34112         *ret_conv = ChannelDetails_read(ser_ref);
34113         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34114         return tag_ptr(ret_conv, true);
34115 }
34116
34117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
34118         LDKPhantomRouteHints obj_conv;
34119         obj_conv.inner = untag_ptr(obj);
34120         obj_conv.is_owned = ptr_is_owned(obj);
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34122         obj_conv.is_owned = false;
34123         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
34124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34126         CVec_u8Z_free(ret_var);
34127         return ret_arr;
34128 }
34129
34130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34131         LDKu8slice ser_ref;
34132         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34133         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34134         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
34135         *ret_conv = PhantomRouteHints_read(ser_ref);
34136         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34137         return tag_ptr(ret_conv, true);
34138 }
34139
34140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
34141         LDKChannelManager obj_conv;
34142         obj_conv.inner = untag_ptr(obj);
34143         obj_conv.is_owned = ptr_is_owned(obj);
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34145         obj_conv.is_owned = false;
34146         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
34147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34149         CVec_u8Z_free(ret_var);
34150         return ret_arr;
34151 }
34152
34153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34154         LDKChannelManagerReadArgs this_obj_conv;
34155         this_obj_conv.inner = untag_ptr(this_obj);
34156         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34158         ChannelManagerReadArgs_free(this_obj_conv);
34159 }
34160
34161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr) {
34162         LDKChannelManagerReadArgs this_ptr_conv;
34163         this_ptr_conv.inner = untag_ptr(this_ptr);
34164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34166         this_ptr_conv.is_owned = false;
34167         // WARNING: This object doesn't live past this scope, needs clone!
34168         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
34169         return ret_ret;
34170 }
34171
34172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34173         LDKChannelManagerReadArgs this_ptr_conv;
34174         this_ptr_conv.inner = untag_ptr(this_ptr);
34175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34177         this_ptr_conv.is_owned = false;
34178         void* val_ptr = untag_ptr(val);
34179         CHECK_ACCESS(val_ptr);
34180         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
34181         if (val_conv.free == LDKEntropySource_JCalls_free) {
34182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34183                 LDKEntropySource_JCalls_cloned(&val_conv);
34184         }
34185         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
34186 }
34187
34188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr) {
34189         LDKChannelManagerReadArgs this_ptr_conv;
34190         this_ptr_conv.inner = untag_ptr(this_ptr);
34191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34193         this_ptr_conv.is_owned = false;
34194         // WARNING: This object doesn't live past this scope, needs clone!
34195         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
34196         return ret_ret;
34197 }
34198
34199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34200         LDKChannelManagerReadArgs this_ptr_conv;
34201         this_ptr_conv.inner = untag_ptr(this_ptr);
34202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34204         this_ptr_conv.is_owned = false;
34205         void* val_ptr = untag_ptr(val);
34206         CHECK_ACCESS(val_ptr);
34207         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
34208         if (val_conv.free == LDKNodeSigner_JCalls_free) {
34209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34210                 LDKNodeSigner_JCalls_cloned(&val_conv);
34211         }
34212         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
34213 }
34214
34215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr) {
34216         LDKChannelManagerReadArgs this_ptr_conv;
34217         this_ptr_conv.inner = untag_ptr(this_ptr);
34218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34220         this_ptr_conv.is_owned = false;
34221         // WARNING: This object doesn't live past this scope, needs clone!
34222         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
34223         return ret_ret;
34224 }
34225
34226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34227         LDKChannelManagerReadArgs this_ptr_conv;
34228         this_ptr_conv.inner = untag_ptr(this_ptr);
34229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34231         this_ptr_conv.is_owned = false;
34232         void* val_ptr = untag_ptr(val);
34233         CHECK_ACCESS(val_ptr);
34234         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
34235         if (val_conv.free == LDKSignerProvider_JCalls_free) {
34236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34237                 LDKSignerProvider_JCalls_cloned(&val_conv);
34238         }
34239         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
34240 }
34241
34242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
34243         LDKChannelManagerReadArgs this_ptr_conv;
34244         this_ptr_conv.inner = untag_ptr(this_ptr);
34245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34247         this_ptr_conv.is_owned = false;
34248         // WARNING: This object doesn't live past this scope, needs clone!
34249         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
34250         return ret_ret;
34251 }
34252
34253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34254         LDKChannelManagerReadArgs this_ptr_conv;
34255         this_ptr_conv.inner = untag_ptr(this_ptr);
34256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34258         this_ptr_conv.is_owned = false;
34259         void* val_ptr = untag_ptr(val);
34260         CHECK_ACCESS(val_ptr);
34261         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
34262         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
34263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34264                 LDKFeeEstimator_JCalls_cloned(&val_conv);
34265         }
34266         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
34267 }
34268
34269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
34270         LDKChannelManagerReadArgs this_ptr_conv;
34271         this_ptr_conv.inner = untag_ptr(this_ptr);
34272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34274         this_ptr_conv.is_owned = false;
34275         // WARNING: This object doesn't live past this scope, needs clone!
34276         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
34277         return ret_ret;
34278 }
34279
34280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34281         LDKChannelManagerReadArgs this_ptr_conv;
34282         this_ptr_conv.inner = untag_ptr(this_ptr);
34283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34285         this_ptr_conv.is_owned = false;
34286         void* val_ptr = untag_ptr(val);
34287         CHECK_ACCESS(val_ptr);
34288         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
34289         if (val_conv.free == LDKWatch_JCalls_free) {
34290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34291                 LDKWatch_JCalls_cloned(&val_conv);
34292         }
34293         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
34294 }
34295
34296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
34297         LDKChannelManagerReadArgs this_ptr_conv;
34298         this_ptr_conv.inner = untag_ptr(this_ptr);
34299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34301         this_ptr_conv.is_owned = false;
34302         // WARNING: This object doesn't live past this scope, needs clone!
34303         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
34304         return ret_ret;
34305 }
34306
34307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34308         LDKChannelManagerReadArgs this_ptr_conv;
34309         this_ptr_conv.inner = untag_ptr(this_ptr);
34310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34312         this_ptr_conv.is_owned = false;
34313         void* val_ptr = untag_ptr(val);
34314         CHECK_ACCESS(val_ptr);
34315         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
34316         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
34317                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34318                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
34319         }
34320         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
34321 }
34322
34323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1router(JNIEnv *env, jclass clz, int64_t this_ptr) {
34324         LDKChannelManagerReadArgs this_ptr_conv;
34325         this_ptr_conv.inner = untag_ptr(this_ptr);
34326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34328         this_ptr_conv.is_owned = false;
34329         // WARNING: This object doesn't live past this scope, needs clone!
34330         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
34331         return ret_ret;
34332 }
34333
34334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1router(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34335         LDKChannelManagerReadArgs this_ptr_conv;
34336         this_ptr_conv.inner = untag_ptr(this_ptr);
34337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34339         this_ptr_conv.is_owned = false;
34340         void* val_ptr = untag_ptr(val);
34341         CHECK_ACCESS(val_ptr);
34342         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
34343         if (val_conv.free == LDKRouter_JCalls_free) {
34344                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34345                 LDKRouter_JCalls_cloned(&val_conv);
34346         }
34347         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
34348 }
34349
34350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
34351         LDKChannelManagerReadArgs this_ptr_conv;
34352         this_ptr_conv.inner = untag_ptr(this_ptr);
34353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34355         this_ptr_conv.is_owned = false;
34356         // WARNING: This object doesn't live past this scope, needs clone!
34357         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
34358         return ret_ret;
34359 }
34360
34361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34362         LDKChannelManagerReadArgs this_ptr_conv;
34363         this_ptr_conv.inner = untag_ptr(this_ptr);
34364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34366         this_ptr_conv.is_owned = false;
34367         void* val_ptr = untag_ptr(val);
34368         CHECK_ACCESS(val_ptr);
34369         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
34370         if (val_conv.free == LDKLogger_JCalls_free) {
34371                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34372                 LDKLogger_JCalls_cloned(&val_conv);
34373         }
34374         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
34375 }
34376
34377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
34378         LDKChannelManagerReadArgs this_ptr_conv;
34379         this_ptr_conv.inner = untag_ptr(this_ptr);
34380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34382         this_ptr_conv.is_owned = false;
34383         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
34384         int64_t ret_ref = 0;
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34387         return ret_ref;
34388 }
34389
34390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34391         LDKChannelManagerReadArgs this_ptr_conv;
34392         this_ptr_conv.inner = untag_ptr(this_ptr);
34393         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34395         this_ptr_conv.is_owned = false;
34396         LDKUserConfig val_conv;
34397         val_conv.inner = untag_ptr(val);
34398         val_conv.is_owned = ptr_is_owned(val);
34399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34400         val_conv = UserConfig_clone(&val_conv);
34401         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
34402 }
34403
34404 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) {
34405         void* entropy_source_ptr = untag_ptr(entropy_source);
34406         CHECK_ACCESS(entropy_source_ptr);
34407         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
34408         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
34409                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34410                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
34411         }
34412         void* node_signer_ptr = untag_ptr(node_signer);
34413         CHECK_ACCESS(node_signer_ptr);
34414         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
34415         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
34416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34417                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
34418         }
34419         void* signer_provider_ptr = untag_ptr(signer_provider);
34420         CHECK_ACCESS(signer_provider_ptr);
34421         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
34422         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
34423                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34424                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
34425         }
34426         void* fee_estimator_ptr = untag_ptr(fee_estimator);
34427         CHECK_ACCESS(fee_estimator_ptr);
34428         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
34429         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
34430                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34431                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
34432         }
34433         void* chain_monitor_ptr = untag_ptr(chain_monitor);
34434         CHECK_ACCESS(chain_monitor_ptr);
34435         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
34436         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
34437                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34438                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
34439         }
34440         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
34441         CHECK_ACCESS(tx_broadcaster_ptr);
34442         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
34443         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
34444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34445                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
34446         }
34447         void* router_ptr = untag_ptr(router);
34448         CHECK_ACCESS(router_ptr);
34449         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
34450         if (router_conv.free == LDKRouter_JCalls_free) {
34451                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34452                 LDKRouter_JCalls_cloned(&router_conv);
34453         }
34454         void* logger_ptr = untag_ptr(logger);
34455         CHECK_ACCESS(logger_ptr);
34456         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34457         if (logger_conv.free == LDKLogger_JCalls_free) {
34458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34459                 LDKLogger_JCalls_cloned(&logger_conv);
34460         }
34461         LDKUserConfig default_config_conv;
34462         default_config_conv.inner = untag_ptr(default_config);
34463         default_config_conv.is_owned = ptr_is_owned(default_config);
34464         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
34465         default_config_conv = UserConfig_clone(&default_config_conv);
34466         LDKCVec_ChannelMonitorZ channel_monitors_constr;
34467         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
34468         if (channel_monitors_constr.datalen > 0)
34469                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
34470         else
34471                 channel_monitors_constr.data = NULL;
34472         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
34473         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
34474                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
34475                 LDKChannelMonitor channel_monitors_conv_16_conv;
34476                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
34477                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
34478                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
34479                 channel_monitors_conv_16_conv.is_owned = false;
34480                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
34481         }
34482         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
34483         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);
34484         int64_t ret_ref = 0;
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34487         return ret_ref;
34488 }
34489
34490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
34491         LDKu8slice ser_ref;
34492         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34493         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34494         LDKChannelManagerReadArgs arg_conv;
34495         arg_conv.inner = untag_ptr(arg);
34496         arg_conv.is_owned = ptr_is_owned(arg);
34497         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34498         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
34499         
34500         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
34501         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
34502         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34503         return tag_ptr(ret_conv, true);
34504 }
34505
34506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34507         LDKExpandedKey this_obj_conv;
34508         this_obj_conv.inner = untag_ptr(this_obj);
34509         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34511         ExpandedKey_free(this_obj_conv);
34512 }
34513
34514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
34515         uint8_t key_material_arr[32];
34516         CHECK((*env)->GetArrayLength(env, key_material) == 32);
34517         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
34518         uint8_t (*key_material_ref)[32] = &key_material_arr;
34519         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
34520         int64_t ret_ref = 0;
34521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34523         return ret_ref;
34524 }
34525
34526 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) {
34527         LDKExpandedKey keys_conv;
34528         keys_conv.inner = untag_ptr(keys);
34529         keys_conv.is_owned = ptr_is_owned(keys);
34530         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34531         keys_conv.is_owned = false;
34532         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34533         CHECK_ACCESS(min_value_msat_ptr);
34534         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34535         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34536         void* entropy_source_ptr = untag_ptr(entropy_source);
34537         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
34538         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
34539         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34540         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34541         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34542         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34543         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
34544         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
34545         return tag_ptr(ret_conv, true);
34546 }
34547
34548 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) {
34549         LDKExpandedKey keys_conv;
34550         keys_conv.inner = untag_ptr(keys);
34551         keys_conv.is_owned = ptr_is_owned(keys);
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34553         keys_conv.is_owned = false;
34554         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34555         CHECK_ACCESS(min_value_msat_ptr);
34556         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34557         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34558         LDKThirtyTwoBytes payment_hash_ref;
34559         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
34560         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
34561         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34562         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34563         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34564         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34565         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
34566         *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);
34567         return tag_ptr(ret_conv, true);
34568 }
34569
34570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34571         if (!ptr_is_owned(this_ptr)) return;
34572         void* this_ptr_ptr = untag_ptr(this_ptr);
34573         CHECK_ACCESS(this_ptr_ptr);
34574         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
34575         FREE(untag_ptr(this_ptr));
34576         DecodeError_free(this_ptr_conv);
34577 }
34578
34579 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
34580         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34581         *ret_copy = DecodeError_clone(arg);
34582         int64_t ret_ref = tag_ptr(ret_copy, true);
34583         return ret_ref;
34584 }
34585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34586         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
34587         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
34588         return ret_conv;
34589 }
34590
34591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34592         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
34593         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34594         *ret_copy = DecodeError_clone(orig_conv);
34595         int64_t ret_ref = tag_ptr(ret_copy, true);
34596         return ret_ref;
34597 }
34598
34599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
34600         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34601         *ret_copy = DecodeError_unknown_version();
34602         int64_t ret_ref = tag_ptr(ret_copy, true);
34603         return ret_ref;
34604 }
34605
34606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
34607         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34608         *ret_copy = DecodeError_unknown_required_feature();
34609         int64_t ret_ref = tag_ptr(ret_copy, true);
34610         return ret_ref;
34611 }
34612
34613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
34614         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34615         *ret_copy = DecodeError_invalid_value();
34616         int64_t ret_ref = tag_ptr(ret_copy, true);
34617         return ret_ref;
34618 }
34619
34620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
34621         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34622         *ret_copy = DecodeError_short_read();
34623         int64_t ret_ref = tag_ptr(ret_copy, true);
34624         return ret_ref;
34625 }
34626
34627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
34628         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34629         *ret_copy = DecodeError_bad_length_descriptor();
34630         int64_t ret_ref = tag_ptr(ret_copy, true);
34631         return ret_ref;
34632 }
34633
34634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
34635         LDKIOError a_conv = LDKIOError_from_java(env, a);
34636         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34637         *ret_copy = DecodeError_io(a_conv);
34638         int64_t ret_ref = tag_ptr(ret_copy, true);
34639         return ret_ref;
34640 }
34641
34642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
34643         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34644         *ret_copy = DecodeError_unsupported_compression();
34645         int64_t ret_ref = tag_ptr(ret_copy, true);
34646         return ret_ref;
34647 }
34648
34649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34650         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
34651         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
34652         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
34653         return ret_conv;
34654 }
34655
34656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34657         LDKInit this_obj_conv;
34658         this_obj_conv.inner = untag_ptr(this_obj);
34659         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34661         Init_free(this_obj_conv);
34662 }
34663
34664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34665         LDKInit this_ptr_conv;
34666         this_ptr_conv.inner = untag_ptr(this_ptr);
34667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34669         this_ptr_conv.is_owned = false;
34670         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
34671         int64_t ret_ref = 0;
34672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34674         return ret_ref;
34675 }
34676
34677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34678         LDKInit this_ptr_conv;
34679         this_ptr_conv.inner = untag_ptr(this_ptr);
34680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34682         this_ptr_conv.is_owned = false;
34683         LDKInitFeatures val_conv;
34684         val_conv.inner = untag_ptr(val);
34685         val_conv.is_owned = ptr_is_owned(val);
34686         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34687         val_conv = InitFeatures_clone(&val_conv);
34688         Init_set_features(&this_ptr_conv, val_conv);
34689 }
34690
34691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
34692         LDKInit this_ptr_conv;
34693         this_ptr_conv.inner = untag_ptr(this_ptr);
34694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34696         this_ptr_conv.is_owned = false;
34697         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
34698         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
34699         int64_t ret_ref = tag_ptr(ret_copy, true);
34700         return ret_ref;
34701 }
34702
34703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34704         LDKInit this_ptr_conv;
34705         this_ptr_conv.inner = untag_ptr(this_ptr);
34706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34708         this_ptr_conv.is_owned = false;
34709         void* val_ptr = untag_ptr(val);
34710         CHECK_ACCESS(val_ptr);
34711         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
34712         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
34713         Init_set_remote_network_address(&this_ptr_conv, val_conv);
34714 }
34715
34716 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) {
34717         LDKInitFeatures features_arg_conv;
34718         features_arg_conv.inner = untag_ptr(features_arg);
34719         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34720         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34721         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34722         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
34723         CHECK_ACCESS(remote_network_address_arg_ptr);
34724         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
34725         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
34726         int64_t ret_ref = 0;
34727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34729         return ret_ref;
34730 }
34731
34732 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34733         LDKInit ret_var = Init_clone(arg);
34734         int64_t ret_ref = 0;
34735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34736         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34737         return ret_ref;
34738 }
34739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34740         LDKInit arg_conv;
34741         arg_conv.inner = untag_ptr(arg);
34742         arg_conv.is_owned = ptr_is_owned(arg);
34743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34744         arg_conv.is_owned = false;
34745         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34746         return ret_conv;
34747 }
34748
34749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34750         LDKInit orig_conv;
34751         orig_conv.inner = untag_ptr(orig);
34752         orig_conv.is_owned = ptr_is_owned(orig);
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34754         orig_conv.is_owned = false;
34755         LDKInit ret_var = Init_clone(&orig_conv);
34756         int64_t ret_ref = 0;
34757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34759         return ret_ref;
34760 }
34761
34762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34763         LDKInit a_conv;
34764         a_conv.inner = untag_ptr(a);
34765         a_conv.is_owned = ptr_is_owned(a);
34766         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34767         a_conv.is_owned = false;
34768         LDKInit b_conv;
34769         b_conv.inner = untag_ptr(b);
34770         b_conv.is_owned = ptr_is_owned(b);
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34772         b_conv.is_owned = false;
34773         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34774         return ret_conv;
34775 }
34776
34777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34778         LDKErrorMessage this_obj_conv;
34779         this_obj_conv.inner = untag_ptr(this_obj);
34780         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34782         ErrorMessage_free(this_obj_conv);
34783 }
34784
34785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34786         LDKErrorMessage this_ptr_conv;
34787         this_ptr_conv.inner = untag_ptr(this_ptr);
34788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34790         this_ptr_conv.is_owned = false;
34791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34793         return ret_arr;
34794 }
34795
34796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34797         LDKErrorMessage this_ptr_conv;
34798         this_ptr_conv.inner = untag_ptr(this_ptr);
34799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34801         this_ptr_conv.is_owned = false;
34802         LDKThirtyTwoBytes val_ref;
34803         CHECK((*env)->GetArrayLength(env, val) == 32);
34804         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34805         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34806 }
34807
34808 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34809         LDKErrorMessage this_ptr_conv;
34810         this_ptr_conv.inner = untag_ptr(this_ptr);
34811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34813         this_ptr_conv.is_owned = false;
34814         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34815         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34816         Str_free(ret_str);
34817         return ret_conv;
34818 }
34819
34820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34821         LDKErrorMessage this_ptr_conv;
34822         this_ptr_conv.inner = untag_ptr(this_ptr);
34823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34825         this_ptr_conv.is_owned = false;
34826         LDKStr val_conv = java_to_owned_str(env, val);
34827         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34828 }
34829
34830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34831         LDKThirtyTwoBytes channel_id_arg_ref;
34832         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34833         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34834         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34835         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34836         int64_t ret_ref = 0;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34839         return ret_ref;
34840 }
34841
34842 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34843         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34844         int64_t ret_ref = 0;
34845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34847         return ret_ref;
34848 }
34849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34850         LDKErrorMessage arg_conv;
34851         arg_conv.inner = untag_ptr(arg);
34852         arg_conv.is_owned = ptr_is_owned(arg);
34853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34854         arg_conv.is_owned = false;
34855         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34856         return ret_conv;
34857 }
34858
34859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34860         LDKErrorMessage orig_conv;
34861         orig_conv.inner = untag_ptr(orig);
34862         orig_conv.is_owned = ptr_is_owned(orig);
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34864         orig_conv.is_owned = false;
34865         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34866         int64_t ret_ref = 0;
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34869         return ret_ref;
34870 }
34871
34872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34873         LDKErrorMessage a_conv;
34874         a_conv.inner = untag_ptr(a);
34875         a_conv.is_owned = ptr_is_owned(a);
34876         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34877         a_conv.is_owned = false;
34878         LDKErrorMessage b_conv;
34879         b_conv.inner = untag_ptr(b);
34880         b_conv.is_owned = ptr_is_owned(b);
34881         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34882         b_conv.is_owned = false;
34883         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34884         return ret_conv;
34885 }
34886
34887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34888         LDKWarningMessage this_obj_conv;
34889         this_obj_conv.inner = untag_ptr(this_obj);
34890         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34892         WarningMessage_free(this_obj_conv);
34893 }
34894
34895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34896         LDKWarningMessage this_ptr_conv;
34897         this_ptr_conv.inner = untag_ptr(this_ptr);
34898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34900         this_ptr_conv.is_owned = false;
34901         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34903         return ret_arr;
34904 }
34905
34906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34907         LDKWarningMessage this_ptr_conv;
34908         this_ptr_conv.inner = untag_ptr(this_ptr);
34909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34911         this_ptr_conv.is_owned = false;
34912         LDKThirtyTwoBytes val_ref;
34913         CHECK((*env)->GetArrayLength(env, val) == 32);
34914         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34915         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34916 }
34917
34918 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34919         LDKWarningMessage this_ptr_conv;
34920         this_ptr_conv.inner = untag_ptr(this_ptr);
34921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34923         this_ptr_conv.is_owned = false;
34924         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34925         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34926         Str_free(ret_str);
34927         return ret_conv;
34928 }
34929
34930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34931         LDKWarningMessage this_ptr_conv;
34932         this_ptr_conv.inner = untag_ptr(this_ptr);
34933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34935         this_ptr_conv.is_owned = false;
34936         LDKStr val_conv = java_to_owned_str(env, val);
34937         WarningMessage_set_data(&this_ptr_conv, val_conv);
34938 }
34939
34940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34941         LDKThirtyTwoBytes channel_id_arg_ref;
34942         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34943         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34944         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34945         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34946         int64_t ret_ref = 0;
34947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34949         return ret_ref;
34950 }
34951
34952 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34953         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34954         int64_t ret_ref = 0;
34955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34957         return ret_ref;
34958 }
34959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34960         LDKWarningMessage arg_conv;
34961         arg_conv.inner = untag_ptr(arg);
34962         arg_conv.is_owned = ptr_is_owned(arg);
34963         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34964         arg_conv.is_owned = false;
34965         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34966         return ret_conv;
34967 }
34968
34969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34970         LDKWarningMessage orig_conv;
34971         orig_conv.inner = untag_ptr(orig);
34972         orig_conv.is_owned = ptr_is_owned(orig);
34973         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34974         orig_conv.is_owned = false;
34975         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34976         int64_t ret_ref = 0;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34979         return ret_ref;
34980 }
34981
34982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34983         LDKWarningMessage a_conv;
34984         a_conv.inner = untag_ptr(a);
34985         a_conv.is_owned = ptr_is_owned(a);
34986         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34987         a_conv.is_owned = false;
34988         LDKWarningMessage b_conv;
34989         b_conv.inner = untag_ptr(b);
34990         b_conv.is_owned = ptr_is_owned(b);
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34992         b_conv.is_owned = false;
34993         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
34994         return ret_conv;
34995 }
34996
34997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34998         LDKPing this_obj_conv;
34999         this_obj_conv.inner = untag_ptr(this_obj);
35000         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35002         Ping_free(this_obj_conv);
35003 }
35004
35005 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35006         LDKPing this_ptr_conv;
35007         this_ptr_conv.inner = untag_ptr(this_ptr);
35008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35010         this_ptr_conv.is_owned = false;
35011         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
35012         return ret_conv;
35013 }
35014
35015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35016         LDKPing this_ptr_conv;
35017         this_ptr_conv.inner = untag_ptr(this_ptr);
35018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35020         this_ptr_conv.is_owned = false;
35021         Ping_set_ponglen(&this_ptr_conv, val);
35022 }
35023
35024 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35025         LDKPing this_ptr_conv;
35026         this_ptr_conv.inner = untag_ptr(this_ptr);
35027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35029         this_ptr_conv.is_owned = false;
35030         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
35031         return ret_conv;
35032 }
35033
35034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35035         LDKPing this_ptr_conv;
35036         this_ptr_conv.inner = untag_ptr(this_ptr);
35037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35039         this_ptr_conv.is_owned = false;
35040         Ping_set_byteslen(&this_ptr_conv, val);
35041 }
35042
35043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
35044         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
35045         int64_t ret_ref = 0;
35046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35048         return ret_ref;
35049 }
35050
35051 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
35052         LDKPing ret_var = Ping_clone(arg);
35053         int64_t ret_ref = 0;
35054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35056         return ret_ref;
35057 }
35058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35059         LDKPing arg_conv;
35060         arg_conv.inner = untag_ptr(arg);
35061         arg_conv.is_owned = ptr_is_owned(arg);
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35063         arg_conv.is_owned = false;
35064         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
35065         return ret_conv;
35066 }
35067
35068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35069         LDKPing orig_conv;
35070         orig_conv.inner = untag_ptr(orig);
35071         orig_conv.is_owned = ptr_is_owned(orig);
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35073         orig_conv.is_owned = false;
35074         LDKPing ret_var = Ping_clone(&orig_conv);
35075         int64_t ret_ref = 0;
35076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35078         return ret_ref;
35079 }
35080
35081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35082         LDKPing a_conv;
35083         a_conv.inner = untag_ptr(a);
35084         a_conv.is_owned = ptr_is_owned(a);
35085         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35086         a_conv.is_owned = false;
35087         LDKPing b_conv;
35088         b_conv.inner = untag_ptr(b);
35089         b_conv.is_owned = ptr_is_owned(b);
35090         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35091         b_conv.is_owned = false;
35092         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
35093         return ret_conv;
35094 }
35095
35096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35097         LDKPong this_obj_conv;
35098         this_obj_conv.inner = untag_ptr(this_obj);
35099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35101         Pong_free(this_obj_conv);
35102 }
35103
35104 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35105         LDKPong this_ptr_conv;
35106         this_ptr_conv.inner = untag_ptr(this_ptr);
35107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35109         this_ptr_conv.is_owned = false;
35110         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
35111         return ret_conv;
35112 }
35113
35114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35115         LDKPong this_ptr_conv;
35116         this_ptr_conv.inner = untag_ptr(this_ptr);
35117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35119         this_ptr_conv.is_owned = false;
35120         Pong_set_byteslen(&this_ptr_conv, val);
35121 }
35122
35123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
35124         LDKPong ret_var = Pong_new(byteslen_arg);
35125         int64_t ret_ref = 0;
35126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35128         return ret_ref;
35129 }
35130
35131 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
35132         LDKPong ret_var = Pong_clone(arg);
35133         int64_t ret_ref = 0;
35134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35136         return ret_ref;
35137 }
35138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35139         LDKPong arg_conv;
35140         arg_conv.inner = untag_ptr(arg);
35141         arg_conv.is_owned = ptr_is_owned(arg);
35142         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35143         arg_conv.is_owned = false;
35144         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
35145         return ret_conv;
35146 }
35147
35148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35149         LDKPong orig_conv;
35150         orig_conv.inner = untag_ptr(orig);
35151         orig_conv.is_owned = ptr_is_owned(orig);
35152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35153         orig_conv.is_owned = false;
35154         LDKPong ret_var = Pong_clone(&orig_conv);
35155         int64_t ret_ref = 0;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35158         return ret_ref;
35159 }
35160
35161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35162         LDKPong a_conv;
35163         a_conv.inner = untag_ptr(a);
35164         a_conv.is_owned = ptr_is_owned(a);
35165         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35166         a_conv.is_owned = false;
35167         LDKPong b_conv;
35168         b_conv.inner = untag_ptr(b);
35169         b_conv.is_owned = ptr_is_owned(b);
35170         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35171         b_conv.is_owned = false;
35172         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
35173         return ret_conv;
35174 }
35175
35176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35177         LDKOpenChannel this_obj_conv;
35178         this_obj_conv.inner = untag_ptr(this_obj);
35179         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35181         OpenChannel_free(this_obj_conv);
35182 }
35183
35184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35185         LDKOpenChannel this_ptr_conv;
35186         this_ptr_conv.inner = untag_ptr(this_ptr);
35187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35189         this_ptr_conv.is_owned = false;
35190         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
35192         return ret_arr;
35193 }
35194
35195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35196         LDKOpenChannel this_ptr_conv;
35197         this_ptr_conv.inner = untag_ptr(this_ptr);
35198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35200         this_ptr_conv.is_owned = false;
35201         LDKThirtyTwoBytes val_ref;
35202         CHECK((*env)->GetArrayLength(env, val) == 32);
35203         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35204         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
35205 }
35206
35207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35208         LDKOpenChannel this_ptr_conv;
35209         this_ptr_conv.inner = untag_ptr(this_ptr);
35210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35212         this_ptr_conv.is_owned = false;
35213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
35215         return ret_arr;
35216 }
35217
35218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35219         LDKOpenChannel this_ptr_conv;
35220         this_ptr_conv.inner = untag_ptr(this_ptr);
35221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35223         this_ptr_conv.is_owned = false;
35224         LDKThirtyTwoBytes val_ref;
35225         CHECK((*env)->GetArrayLength(env, val) == 32);
35226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35227         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35228 }
35229
35230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35231         LDKOpenChannel this_ptr_conv;
35232         this_ptr_conv.inner = untag_ptr(this_ptr);
35233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35235         this_ptr_conv.is_owned = false;
35236         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
35237         return ret_conv;
35238 }
35239
35240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35241         LDKOpenChannel this_ptr_conv;
35242         this_ptr_conv.inner = untag_ptr(this_ptr);
35243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35245         this_ptr_conv.is_owned = false;
35246         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
35247 }
35248
35249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35250         LDKOpenChannel this_ptr_conv;
35251         this_ptr_conv.inner = untag_ptr(this_ptr);
35252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35254         this_ptr_conv.is_owned = false;
35255         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
35256         return ret_conv;
35257 }
35258
35259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35260         LDKOpenChannel this_ptr_conv;
35261         this_ptr_conv.inner = untag_ptr(this_ptr);
35262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35264         this_ptr_conv.is_owned = false;
35265         OpenChannel_set_push_msat(&this_ptr_conv, val);
35266 }
35267
35268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35269         LDKOpenChannel this_ptr_conv;
35270         this_ptr_conv.inner = untag_ptr(this_ptr);
35271         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35273         this_ptr_conv.is_owned = false;
35274         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
35275         return ret_conv;
35276 }
35277
35278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35279         LDKOpenChannel this_ptr_conv;
35280         this_ptr_conv.inner = untag_ptr(this_ptr);
35281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35283         this_ptr_conv.is_owned = false;
35284         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35285 }
35286
35287 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) {
35288         LDKOpenChannel this_ptr_conv;
35289         this_ptr_conv.inner = untag_ptr(this_ptr);
35290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35292         this_ptr_conv.is_owned = false;
35293         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35294         return ret_conv;
35295 }
35296
35297 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) {
35298         LDKOpenChannel this_ptr_conv;
35299         this_ptr_conv.inner = untag_ptr(this_ptr);
35300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35302         this_ptr_conv.is_owned = false;
35303         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35304 }
35305
35306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35307         LDKOpenChannel this_ptr_conv;
35308         this_ptr_conv.inner = untag_ptr(this_ptr);
35309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35311         this_ptr_conv.is_owned = false;
35312         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35313         return ret_conv;
35314 }
35315
35316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35317         LDKOpenChannel this_ptr_conv;
35318         this_ptr_conv.inner = untag_ptr(this_ptr);
35319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35321         this_ptr_conv.is_owned = false;
35322         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35323 }
35324
35325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35326         LDKOpenChannel this_ptr_conv;
35327         this_ptr_conv.inner = untag_ptr(this_ptr);
35328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35330         this_ptr_conv.is_owned = false;
35331         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
35332         return ret_conv;
35333 }
35334
35335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35336         LDKOpenChannel this_ptr_conv;
35337         this_ptr_conv.inner = untag_ptr(this_ptr);
35338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35340         this_ptr_conv.is_owned = false;
35341         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35342 }
35343
35344 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35345         LDKOpenChannel this_ptr_conv;
35346         this_ptr_conv.inner = untag_ptr(this_ptr);
35347         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35349         this_ptr_conv.is_owned = false;
35350         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
35351         return ret_conv;
35352 }
35353
35354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35355         LDKOpenChannel this_ptr_conv;
35356         this_ptr_conv.inner = untag_ptr(this_ptr);
35357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35359         this_ptr_conv.is_owned = false;
35360         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
35361 }
35362
35363 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35364         LDKOpenChannel this_ptr_conv;
35365         this_ptr_conv.inner = untag_ptr(this_ptr);
35366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35368         this_ptr_conv.is_owned = false;
35369         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
35370         return ret_conv;
35371 }
35372
35373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35374         LDKOpenChannel this_ptr_conv;
35375         this_ptr_conv.inner = untag_ptr(this_ptr);
35376         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35378         this_ptr_conv.is_owned = false;
35379         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
35380 }
35381
35382 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35383         LDKOpenChannel this_ptr_conv;
35384         this_ptr_conv.inner = untag_ptr(this_ptr);
35385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         this_ptr_conv.is_owned = false;
35388         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
35389         return ret_conv;
35390 }
35391
35392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35393         LDKOpenChannel this_ptr_conv;
35394         this_ptr_conv.inner = untag_ptr(this_ptr);
35395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35397         this_ptr_conv.is_owned = false;
35398         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35399 }
35400
35401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35402         LDKOpenChannel this_ptr_conv;
35403         this_ptr_conv.inner = untag_ptr(this_ptr);
35404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35406         this_ptr_conv.is_owned = false;
35407         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35408         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35409         return ret_arr;
35410 }
35411
35412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
35419         CHECK((*env)->GetArrayLength(env, val) == 33);
35420         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35421         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35422 }
35423
35424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35425         LDKOpenChannel this_ptr_conv;
35426         this_ptr_conv.inner = untag_ptr(this_ptr);
35427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35429         this_ptr_conv.is_owned = false;
35430         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35431         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35432         return ret_arr;
35433 }
35434
35435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35436         LDKOpenChannel this_ptr_conv;
35437         this_ptr_conv.inner = untag_ptr(this_ptr);
35438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35440         this_ptr_conv.is_owned = false;
35441         LDKPublicKey val_ref;
35442         CHECK((*env)->GetArrayLength(env, val) == 33);
35443         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35444         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35445 }
35446
35447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35448         LDKOpenChannel this_ptr_conv;
35449         this_ptr_conv.inner = untag_ptr(this_ptr);
35450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35452         this_ptr_conv.is_owned = false;
35453         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
35455         return ret_arr;
35456 }
35457
35458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35459         LDKOpenChannel this_ptr_conv;
35460         this_ptr_conv.inner = untag_ptr(this_ptr);
35461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35463         this_ptr_conv.is_owned = false;
35464         LDKPublicKey val_ref;
35465         CHECK((*env)->GetArrayLength(env, val) == 33);
35466         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35467         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
35468 }
35469
35470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35471         LDKOpenChannel this_ptr_conv;
35472         this_ptr_conv.inner = untag_ptr(this_ptr);
35473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35475         this_ptr_conv.is_owned = false;
35476         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35478         return ret_arr;
35479 }
35480
35481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35482         LDKOpenChannel this_ptr_conv;
35483         this_ptr_conv.inner = untag_ptr(this_ptr);
35484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35486         this_ptr_conv.is_owned = false;
35487         LDKPublicKey val_ref;
35488         CHECK((*env)->GetArrayLength(env, val) == 33);
35489         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35490         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35491 }
35492
35493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35494         LDKOpenChannel this_ptr_conv;
35495         this_ptr_conv.inner = untag_ptr(this_ptr);
35496         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35498         this_ptr_conv.is_owned = false;
35499         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35500         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35501         return ret_arr;
35502 }
35503
35504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35505         LDKOpenChannel this_ptr_conv;
35506         this_ptr_conv.inner = untag_ptr(this_ptr);
35507         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35509         this_ptr_conv.is_owned = false;
35510         LDKPublicKey val_ref;
35511         CHECK((*env)->GetArrayLength(env, val) == 33);
35512         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35513         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35514 }
35515
35516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35517         LDKOpenChannel this_ptr_conv;
35518         this_ptr_conv.inner = untag_ptr(this_ptr);
35519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35521         this_ptr_conv.is_owned = false;
35522         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35523         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35524         return ret_arr;
35525 }
35526
35527 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) {
35528         LDKOpenChannel this_ptr_conv;
35529         this_ptr_conv.inner = untag_ptr(this_ptr);
35530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35532         this_ptr_conv.is_owned = false;
35533         LDKPublicKey val_ref;
35534         CHECK((*env)->GetArrayLength(env, val) == 33);
35535         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35536         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35537 }
35538
35539 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35540         LDKOpenChannel this_ptr_conv;
35541         this_ptr_conv.inner = untag_ptr(this_ptr);
35542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35544         this_ptr_conv.is_owned = false;
35545         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
35546         return ret_conv;
35547 }
35548
35549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35550         LDKOpenChannel this_ptr_conv;
35551         this_ptr_conv.inner = untag_ptr(this_ptr);
35552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35554         this_ptr_conv.is_owned = false;
35555         OpenChannel_set_channel_flags(&this_ptr_conv, val);
35556 }
35557
35558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35559         LDKOpenChannel this_ptr_conv;
35560         this_ptr_conv.inner = untag_ptr(this_ptr);
35561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35563         this_ptr_conv.is_owned = false;
35564         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
35565         int64_t ret_ref = 0;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35568         return ret_ref;
35569 }
35570
35571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35572         LDKOpenChannel this_ptr_conv;
35573         this_ptr_conv.inner = untag_ptr(this_ptr);
35574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35576         this_ptr_conv.is_owned = false;
35577         LDKChannelTypeFeatures val_conv;
35578         val_conv.inner = untag_ptr(val);
35579         val_conv.is_owned = ptr_is_owned(val);
35580         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35581         val_conv = ChannelTypeFeatures_clone(&val_conv);
35582         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
35583 }
35584
35585 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
35586         LDKOpenChannel ret_var = OpenChannel_clone(arg);
35587         int64_t ret_ref = 0;
35588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35590         return ret_ref;
35591 }
35592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35593         LDKOpenChannel arg_conv;
35594         arg_conv.inner = untag_ptr(arg);
35595         arg_conv.is_owned = ptr_is_owned(arg);
35596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35597         arg_conv.is_owned = false;
35598         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
35599         return ret_conv;
35600 }
35601
35602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35603         LDKOpenChannel orig_conv;
35604         orig_conv.inner = untag_ptr(orig);
35605         orig_conv.is_owned = ptr_is_owned(orig);
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35607         orig_conv.is_owned = false;
35608         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
35609         int64_t ret_ref = 0;
35610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35612         return ret_ref;
35613 }
35614
35615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35616         LDKOpenChannel a_conv;
35617         a_conv.inner = untag_ptr(a);
35618         a_conv.is_owned = ptr_is_owned(a);
35619         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35620         a_conv.is_owned = false;
35621         LDKOpenChannel b_conv;
35622         b_conv.inner = untag_ptr(b);
35623         b_conv.is_owned = ptr_is_owned(b);
35624         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35625         b_conv.is_owned = false;
35626         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
35627         return ret_conv;
35628 }
35629
35630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35631         LDKAcceptChannel this_obj_conv;
35632         this_obj_conv.inner = untag_ptr(this_obj);
35633         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35635         AcceptChannel_free(this_obj_conv);
35636 }
35637
35638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35639         LDKAcceptChannel this_ptr_conv;
35640         this_ptr_conv.inner = untag_ptr(this_ptr);
35641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35643         this_ptr_conv.is_owned = false;
35644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
35646         return ret_arr;
35647 }
35648
35649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35650         LDKAcceptChannel this_ptr_conv;
35651         this_ptr_conv.inner = untag_ptr(this_ptr);
35652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35654         this_ptr_conv.is_owned = false;
35655         LDKThirtyTwoBytes val_ref;
35656         CHECK((*env)->GetArrayLength(env, val) == 32);
35657         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35658         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35659 }
35660
35661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35662         LDKAcceptChannel this_ptr_conv;
35663         this_ptr_conv.inner = untag_ptr(this_ptr);
35664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35666         this_ptr_conv.is_owned = false;
35667         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
35668         return ret_conv;
35669 }
35670
35671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35672         LDKAcceptChannel this_ptr_conv;
35673         this_ptr_conv.inner = untag_ptr(this_ptr);
35674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35676         this_ptr_conv.is_owned = false;
35677         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35678 }
35679
35680 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) {
35681         LDKAcceptChannel this_ptr_conv;
35682         this_ptr_conv.inner = untag_ptr(this_ptr);
35683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35685         this_ptr_conv.is_owned = false;
35686         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35687         return ret_conv;
35688 }
35689
35690 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) {
35691         LDKAcceptChannel this_ptr_conv;
35692         this_ptr_conv.inner = untag_ptr(this_ptr);
35693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35695         this_ptr_conv.is_owned = false;
35696         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35697 }
35698
35699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35700         LDKAcceptChannel this_ptr_conv;
35701         this_ptr_conv.inner = untag_ptr(this_ptr);
35702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35704         this_ptr_conv.is_owned = false;
35705         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35706         return ret_conv;
35707 }
35708
35709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35710         LDKAcceptChannel this_ptr_conv;
35711         this_ptr_conv.inner = untag_ptr(this_ptr);
35712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35714         this_ptr_conv.is_owned = false;
35715         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35716 }
35717
35718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35719         LDKAcceptChannel this_ptr_conv;
35720         this_ptr_conv.inner = untag_ptr(this_ptr);
35721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35723         this_ptr_conv.is_owned = false;
35724         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
35725         return ret_conv;
35726 }
35727
35728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35729         LDKAcceptChannel this_ptr_conv;
35730         this_ptr_conv.inner = untag_ptr(this_ptr);
35731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35733         this_ptr_conv.is_owned = false;
35734         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35735 }
35736
35737 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35738         LDKAcceptChannel this_ptr_conv;
35739         this_ptr_conv.inner = untag_ptr(this_ptr);
35740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35742         this_ptr_conv.is_owned = false;
35743         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35744         return ret_conv;
35745 }
35746
35747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35748         LDKAcceptChannel this_ptr_conv;
35749         this_ptr_conv.inner = untag_ptr(this_ptr);
35750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35752         this_ptr_conv.is_owned = false;
35753         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35754 }
35755
35756 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35757         LDKAcceptChannel this_ptr_conv;
35758         this_ptr_conv.inner = untag_ptr(this_ptr);
35759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35761         this_ptr_conv.is_owned = false;
35762         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35763         return ret_conv;
35764 }
35765
35766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35767         LDKAcceptChannel this_ptr_conv;
35768         this_ptr_conv.inner = untag_ptr(this_ptr);
35769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35771         this_ptr_conv.is_owned = false;
35772         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35773 }
35774
35775 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35776         LDKAcceptChannel this_ptr_conv;
35777         this_ptr_conv.inner = untag_ptr(this_ptr);
35778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35780         this_ptr_conv.is_owned = false;
35781         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35782         return ret_conv;
35783 }
35784
35785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35786         LDKAcceptChannel this_ptr_conv;
35787         this_ptr_conv.inner = untag_ptr(this_ptr);
35788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35790         this_ptr_conv.is_owned = false;
35791         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35792 }
35793
35794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35795         LDKAcceptChannel this_ptr_conv;
35796         this_ptr_conv.inner = untag_ptr(this_ptr);
35797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35799         this_ptr_conv.is_owned = false;
35800         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35802         return ret_arr;
35803 }
35804
35805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
35812         CHECK((*env)->GetArrayLength(env, val) == 33);
35813         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35814         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35815 }
35816
35817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35818         LDKAcceptChannel this_ptr_conv;
35819         this_ptr_conv.inner = untag_ptr(this_ptr);
35820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35822         this_ptr_conv.is_owned = false;
35823         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35825         return ret_arr;
35826 }
35827
35828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35829         LDKAcceptChannel this_ptr_conv;
35830         this_ptr_conv.inner = untag_ptr(this_ptr);
35831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35833         this_ptr_conv.is_owned = false;
35834         LDKPublicKey val_ref;
35835         CHECK((*env)->GetArrayLength(env, val) == 33);
35836         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35837         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35838 }
35839
35840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35841         LDKAcceptChannel this_ptr_conv;
35842         this_ptr_conv.inner = untag_ptr(this_ptr);
35843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35845         this_ptr_conv.is_owned = false;
35846         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35848         return ret_arr;
35849 }
35850
35851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35852         LDKAcceptChannel this_ptr_conv;
35853         this_ptr_conv.inner = untag_ptr(this_ptr);
35854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35856         this_ptr_conv.is_owned = false;
35857         LDKPublicKey val_ref;
35858         CHECK((*env)->GetArrayLength(env, val) == 33);
35859         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35860         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35861 }
35862
35863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35864         LDKAcceptChannel this_ptr_conv;
35865         this_ptr_conv.inner = untag_ptr(this_ptr);
35866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35868         this_ptr_conv.is_owned = false;
35869         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35871         return ret_arr;
35872 }
35873
35874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35875         LDKAcceptChannel this_ptr_conv;
35876         this_ptr_conv.inner = untag_ptr(this_ptr);
35877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35879         this_ptr_conv.is_owned = false;
35880         LDKPublicKey val_ref;
35881         CHECK((*env)->GetArrayLength(env, val) == 33);
35882         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35883         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35884 }
35885
35886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35887         LDKAcceptChannel this_ptr_conv;
35888         this_ptr_conv.inner = untag_ptr(this_ptr);
35889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35891         this_ptr_conv.is_owned = false;
35892         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35893         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35894         return ret_arr;
35895 }
35896
35897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35898         LDKAcceptChannel this_ptr_conv;
35899         this_ptr_conv.inner = untag_ptr(this_ptr);
35900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35902         this_ptr_conv.is_owned = false;
35903         LDKPublicKey val_ref;
35904         CHECK((*env)->GetArrayLength(env, val) == 33);
35905         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35906         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35907 }
35908
35909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35910         LDKAcceptChannel this_ptr_conv;
35911         this_ptr_conv.inner = untag_ptr(this_ptr);
35912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35914         this_ptr_conv.is_owned = false;
35915         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35917         return ret_arr;
35918 }
35919
35920 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) {
35921         LDKAcceptChannel this_ptr_conv;
35922         this_ptr_conv.inner = untag_ptr(this_ptr);
35923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35925         this_ptr_conv.is_owned = false;
35926         LDKPublicKey val_ref;
35927         CHECK((*env)->GetArrayLength(env, val) == 33);
35928         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35929         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35930 }
35931
35932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35933         LDKAcceptChannel this_ptr_conv;
35934         this_ptr_conv.inner = untag_ptr(this_ptr);
35935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35937         this_ptr_conv.is_owned = false;
35938         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35939         int64_t ret_ref = 0;
35940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35942         return ret_ref;
35943 }
35944
35945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35946         LDKAcceptChannel this_ptr_conv;
35947         this_ptr_conv.inner = untag_ptr(this_ptr);
35948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35950         this_ptr_conv.is_owned = false;
35951         LDKChannelTypeFeatures val_conv;
35952         val_conv.inner = untag_ptr(val);
35953         val_conv.is_owned = ptr_is_owned(val);
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35955         val_conv = ChannelTypeFeatures_clone(&val_conv);
35956         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35957 }
35958
35959 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35960         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35961         int64_t ret_ref = 0;
35962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35964         return ret_ref;
35965 }
35966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35967         LDKAcceptChannel arg_conv;
35968         arg_conv.inner = untag_ptr(arg);
35969         arg_conv.is_owned = ptr_is_owned(arg);
35970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35971         arg_conv.is_owned = false;
35972         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35973         return ret_conv;
35974 }
35975
35976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35977         LDKAcceptChannel orig_conv;
35978         orig_conv.inner = untag_ptr(orig);
35979         orig_conv.is_owned = ptr_is_owned(orig);
35980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35981         orig_conv.is_owned = false;
35982         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
35983         int64_t ret_ref = 0;
35984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35986         return ret_ref;
35987 }
35988
35989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35990         LDKAcceptChannel a_conv;
35991         a_conv.inner = untag_ptr(a);
35992         a_conv.is_owned = ptr_is_owned(a);
35993         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35994         a_conv.is_owned = false;
35995         LDKAcceptChannel b_conv;
35996         b_conv.inner = untag_ptr(b);
35997         b_conv.is_owned = ptr_is_owned(b);
35998         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35999         b_conv.is_owned = false;
36000         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
36001         return ret_conv;
36002 }
36003
36004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36005         LDKFundingCreated this_obj_conv;
36006         this_obj_conv.inner = untag_ptr(this_obj);
36007         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36009         FundingCreated_free(this_obj_conv);
36010 }
36011
36012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36013         LDKFundingCreated this_ptr_conv;
36014         this_ptr_conv.inner = untag_ptr(this_ptr);
36015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36017         this_ptr_conv.is_owned = false;
36018         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36019         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
36020         return ret_arr;
36021 }
36022
36023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36024         LDKFundingCreated this_ptr_conv;
36025         this_ptr_conv.inner = untag_ptr(this_ptr);
36026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36028         this_ptr_conv.is_owned = false;
36029         LDKThirtyTwoBytes val_ref;
36030         CHECK((*env)->GetArrayLength(env, val) == 32);
36031         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36032         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
36033 }
36034
36035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
36036         LDKFundingCreated this_ptr_conv;
36037         this_ptr_conv.inner = untag_ptr(this_ptr);
36038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36040         this_ptr_conv.is_owned = false;
36041         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36042         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
36043         return ret_arr;
36044 }
36045
36046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36047         LDKFundingCreated this_ptr_conv;
36048         this_ptr_conv.inner = untag_ptr(this_ptr);
36049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36051         this_ptr_conv.is_owned = false;
36052         LDKThirtyTwoBytes val_ref;
36053         CHECK((*env)->GetArrayLength(env, val) == 32);
36054         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36055         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
36056 }
36057
36058 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36059         LDKFundingCreated this_ptr_conv;
36060         this_ptr_conv.inner = untag_ptr(this_ptr);
36061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36063         this_ptr_conv.is_owned = false;
36064         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
36065         return ret_conv;
36066 }
36067
36068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36069         LDKFundingCreated this_ptr_conv;
36070         this_ptr_conv.inner = untag_ptr(this_ptr);
36071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36073         this_ptr_conv.is_owned = false;
36074         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
36075 }
36076
36077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36078         LDKFundingCreated this_ptr_conv;
36079         this_ptr_conv.inner = untag_ptr(this_ptr);
36080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36082         this_ptr_conv.is_owned = false;
36083         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
36085         return ret_arr;
36086 }
36087
36088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
36095         CHECK((*env)->GetArrayLength(env, val) == 64);
36096         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36097         FundingCreated_set_signature(&this_ptr_conv, val_ref);
36098 }
36099
36100 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) {
36101         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
36102         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
36103         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
36104         LDKThirtyTwoBytes funding_txid_arg_ref;
36105         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
36106         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
36107         LDKSignature signature_arg_ref;
36108         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36109         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36110         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
36111         int64_t ret_ref = 0;
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36114         return ret_ref;
36115 }
36116
36117 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
36118         LDKFundingCreated ret_var = FundingCreated_clone(arg);
36119         int64_t ret_ref = 0;
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36122         return ret_ref;
36123 }
36124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36125         LDKFundingCreated arg_conv;
36126         arg_conv.inner = untag_ptr(arg);
36127         arg_conv.is_owned = ptr_is_owned(arg);
36128         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36129         arg_conv.is_owned = false;
36130         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
36131         return ret_conv;
36132 }
36133
36134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36135         LDKFundingCreated orig_conv;
36136         orig_conv.inner = untag_ptr(orig);
36137         orig_conv.is_owned = ptr_is_owned(orig);
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36139         orig_conv.is_owned = false;
36140         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
36141         int64_t ret_ref = 0;
36142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36143         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36144         return ret_ref;
36145 }
36146
36147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36148         LDKFundingCreated a_conv;
36149         a_conv.inner = untag_ptr(a);
36150         a_conv.is_owned = ptr_is_owned(a);
36151         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36152         a_conv.is_owned = false;
36153         LDKFundingCreated b_conv;
36154         b_conv.inner = untag_ptr(b);
36155         b_conv.is_owned = ptr_is_owned(b);
36156         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36157         b_conv.is_owned = false;
36158         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
36159         return ret_conv;
36160 }
36161
36162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36163         LDKFundingSigned this_obj_conv;
36164         this_obj_conv.inner = untag_ptr(this_obj);
36165         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36167         FundingSigned_free(this_obj_conv);
36168 }
36169
36170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36171         LDKFundingSigned this_ptr_conv;
36172         this_ptr_conv.inner = untag_ptr(this_ptr);
36173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36175         this_ptr_conv.is_owned = false;
36176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
36178         return ret_arr;
36179 }
36180
36181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36182         LDKFundingSigned this_ptr_conv;
36183         this_ptr_conv.inner = untag_ptr(this_ptr);
36184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36186         this_ptr_conv.is_owned = false;
36187         LDKThirtyTwoBytes val_ref;
36188         CHECK((*env)->GetArrayLength(env, val) == 32);
36189         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36190         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
36191 }
36192
36193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36194         LDKFundingSigned this_ptr_conv;
36195         this_ptr_conv.inner = untag_ptr(this_ptr);
36196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36198         this_ptr_conv.is_owned = false;
36199         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
36201         return ret_arr;
36202 }
36203
36204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36205         LDKFundingSigned this_ptr_conv;
36206         this_ptr_conv.inner = untag_ptr(this_ptr);
36207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36209         this_ptr_conv.is_owned = false;
36210         LDKSignature val_ref;
36211         CHECK((*env)->GetArrayLength(env, val) == 64);
36212         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36213         FundingSigned_set_signature(&this_ptr_conv, val_ref);
36214 }
36215
36216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
36217         LDKThirtyTwoBytes channel_id_arg_ref;
36218         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36219         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36220         LDKSignature signature_arg_ref;
36221         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36222         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36223         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
36224         int64_t ret_ref = 0;
36225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36227         return ret_ref;
36228 }
36229
36230 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
36231         LDKFundingSigned ret_var = FundingSigned_clone(arg);
36232         int64_t ret_ref = 0;
36233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36235         return ret_ref;
36236 }
36237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36238         LDKFundingSigned arg_conv;
36239         arg_conv.inner = untag_ptr(arg);
36240         arg_conv.is_owned = ptr_is_owned(arg);
36241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36242         arg_conv.is_owned = false;
36243         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
36244         return ret_conv;
36245 }
36246
36247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36248         LDKFundingSigned orig_conv;
36249         orig_conv.inner = untag_ptr(orig);
36250         orig_conv.is_owned = ptr_is_owned(orig);
36251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36252         orig_conv.is_owned = false;
36253         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
36254         int64_t ret_ref = 0;
36255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36257         return ret_ref;
36258 }
36259
36260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36261         LDKFundingSigned a_conv;
36262         a_conv.inner = untag_ptr(a);
36263         a_conv.is_owned = ptr_is_owned(a);
36264         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36265         a_conv.is_owned = false;
36266         LDKFundingSigned b_conv;
36267         b_conv.inner = untag_ptr(b);
36268         b_conv.is_owned = ptr_is_owned(b);
36269         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36270         b_conv.is_owned = false;
36271         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
36272         return ret_conv;
36273 }
36274
36275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36276         LDKChannelReady this_obj_conv;
36277         this_obj_conv.inner = untag_ptr(this_obj);
36278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36280         ChannelReady_free(this_obj_conv);
36281 }
36282
36283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36284         LDKChannelReady this_ptr_conv;
36285         this_ptr_conv.inner = untag_ptr(this_ptr);
36286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36288         this_ptr_conv.is_owned = false;
36289         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
36291         return ret_arr;
36292 }
36293
36294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36295         LDKChannelReady this_ptr_conv;
36296         this_ptr_conv.inner = untag_ptr(this_ptr);
36297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36299         this_ptr_conv.is_owned = false;
36300         LDKThirtyTwoBytes val_ref;
36301         CHECK((*env)->GetArrayLength(env, val) == 32);
36302         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36303         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
36304 }
36305
36306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36307         LDKChannelReady this_ptr_conv;
36308         this_ptr_conv.inner = untag_ptr(this_ptr);
36309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36311         this_ptr_conv.is_owned = false;
36312         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36314         return ret_arr;
36315 }
36316
36317 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) {
36318         LDKChannelReady this_ptr_conv;
36319         this_ptr_conv.inner = untag_ptr(this_ptr);
36320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36322         this_ptr_conv.is_owned = false;
36323         LDKPublicKey val_ref;
36324         CHECK((*env)->GetArrayLength(env, val) == 33);
36325         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36326         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36327 }
36328
36329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36330         LDKChannelReady this_ptr_conv;
36331         this_ptr_conv.inner = untag_ptr(this_ptr);
36332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36334         this_ptr_conv.is_owned = false;
36335         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36336         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
36337         int64_t ret_ref = tag_ptr(ret_copy, true);
36338         return ret_ref;
36339 }
36340
36341 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) {
36342         LDKChannelReady this_ptr_conv;
36343         this_ptr_conv.inner = untag_ptr(this_ptr);
36344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36346         this_ptr_conv.is_owned = false;
36347         void* val_ptr = untag_ptr(val);
36348         CHECK_ACCESS(val_ptr);
36349         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36350         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
36351         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
36352 }
36353
36354 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) {
36355         LDKThirtyTwoBytes channel_id_arg_ref;
36356         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36357         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36358         LDKPublicKey next_per_commitment_point_arg_ref;
36359         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36360         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36361         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
36362         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
36363         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
36364         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
36365         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
36366         int64_t ret_ref = 0;
36367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36369         return ret_ref;
36370 }
36371
36372 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
36373         LDKChannelReady ret_var = ChannelReady_clone(arg);
36374         int64_t ret_ref = 0;
36375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36376         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36377         return ret_ref;
36378 }
36379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36380         LDKChannelReady arg_conv;
36381         arg_conv.inner = untag_ptr(arg);
36382         arg_conv.is_owned = ptr_is_owned(arg);
36383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36384         arg_conv.is_owned = false;
36385         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
36386         return ret_conv;
36387 }
36388
36389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36390         LDKChannelReady orig_conv;
36391         orig_conv.inner = untag_ptr(orig);
36392         orig_conv.is_owned = ptr_is_owned(orig);
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36394         orig_conv.is_owned = false;
36395         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
36396         int64_t ret_ref = 0;
36397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36399         return ret_ref;
36400 }
36401
36402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36403         LDKChannelReady a_conv;
36404         a_conv.inner = untag_ptr(a);
36405         a_conv.is_owned = ptr_is_owned(a);
36406         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36407         a_conv.is_owned = false;
36408         LDKChannelReady b_conv;
36409         b_conv.inner = untag_ptr(b);
36410         b_conv.is_owned = ptr_is_owned(b);
36411         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36412         b_conv.is_owned = false;
36413         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
36414         return ret_conv;
36415 }
36416
36417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36418         LDKShutdown this_obj_conv;
36419         this_obj_conv.inner = untag_ptr(this_obj);
36420         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36422         Shutdown_free(this_obj_conv);
36423 }
36424
36425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36426         LDKShutdown this_ptr_conv;
36427         this_ptr_conv.inner = untag_ptr(this_ptr);
36428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36430         this_ptr_conv.is_owned = false;
36431         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
36433         return ret_arr;
36434 }
36435
36436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36437         LDKShutdown this_ptr_conv;
36438         this_ptr_conv.inner = untag_ptr(this_ptr);
36439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36441         this_ptr_conv.is_owned = false;
36442         LDKThirtyTwoBytes val_ref;
36443         CHECK((*env)->GetArrayLength(env, val) == 32);
36444         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36445         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
36446 }
36447
36448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36449         LDKShutdown this_ptr_conv;
36450         this_ptr_conv.inner = untag_ptr(this_ptr);
36451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36453         this_ptr_conv.is_owned = false;
36454         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
36455         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36456         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36457         return ret_arr;
36458 }
36459
36460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36461         LDKShutdown this_ptr_conv;
36462         this_ptr_conv.inner = untag_ptr(this_ptr);
36463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36465         this_ptr_conv.is_owned = false;
36466         LDKCVec_u8Z val_ref;
36467         val_ref.datalen = (*env)->GetArrayLength(env, val);
36468         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36469         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36470         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
36471 }
36472
36473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
36474         LDKThirtyTwoBytes channel_id_arg_ref;
36475         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36476         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36477         LDKCVec_u8Z scriptpubkey_arg_ref;
36478         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
36479         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36480         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
36481         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
36482         int64_t ret_ref = 0;
36483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36485         return ret_ref;
36486 }
36487
36488 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
36489         LDKShutdown ret_var = Shutdown_clone(arg);
36490         int64_t ret_ref = 0;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36493         return ret_ref;
36494 }
36495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36496         LDKShutdown arg_conv;
36497         arg_conv.inner = untag_ptr(arg);
36498         arg_conv.is_owned = ptr_is_owned(arg);
36499         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36500         arg_conv.is_owned = false;
36501         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
36502         return ret_conv;
36503 }
36504
36505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36506         LDKShutdown orig_conv;
36507         orig_conv.inner = untag_ptr(orig);
36508         orig_conv.is_owned = ptr_is_owned(orig);
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36510         orig_conv.is_owned = false;
36511         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
36512         int64_t ret_ref = 0;
36513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36515         return ret_ref;
36516 }
36517
36518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36519         LDKShutdown a_conv;
36520         a_conv.inner = untag_ptr(a);
36521         a_conv.is_owned = ptr_is_owned(a);
36522         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36523         a_conv.is_owned = false;
36524         LDKShutdown b_conv;
36525         b_conv.inner = untag_ptr(b);
36526         b_conv.is_owned = ptr_is_owned(b);
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36528         b_conv.is_owned = false;
36529         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
36530         return ret_conv;
36531 }
36532
36533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36534         LDKClosingSignedFeeRange this_obj_conv;
36535         this_obj_conv.inner = untag_ptr(this_obj);
36536         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36538         ClosingSignedFeeRange_free(this_obj_conv);
36539 }
36540
36541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36542         LDKClosingSignedFeeRange this_ptr_conv;
36543         this_ptr_conv.inner = untag_ptr(this_ptr);
36544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36546         this_ptr_conv.is_owned = false;
36547         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
36548         return ret_conv;
36549 }
36550
36551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36552         LDKClosingSignedFeeRange this_ptr_conv;
36553         this_ptr_conv.inner = untag_ptr(this_ptr);
36554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36556         this_ptr_conv.is_owned = false;
36557         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
36558 }
36559
36560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36561         LDKClosingSignedFeeRange this_ptr_conv;
36562         this_ptr_conv.inner = untag_ptr(this_ptr);
36563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36565         this_ptr_conv.is_owned = false;
36566         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
36567         return ret_conv;
36568 }
36569
36570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36571         LDKClosingSignedFeeRange this_ptr_conv;
36572         this_ptr_conv.inner = untag_ptr(this_ptr);
36573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36575         this_ptr_conv.is_owned = false;
36576         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
36577 }
36578
36579 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) {
36580         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
36581         int64_t ret_ref = 0;
36582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36584         return ret_ref;
36585 }
36586
36587 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
36588         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
36589         int64_t ret_ref = 0;
36590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36592         return ret_ref;
36593 }
36594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36595         LDKClosingSignedFeeRange arg_conv;
36596         arg_conv.inner = untag_ptr(arg);
36597         arg_conv.is_owned = ptr_is_owned(arg);
36598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36599         arg_conv.is_owned = false;
36600         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
36601         return ret_conv;
36602 }
36603
36604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36605         LDKClosingSignedFeeRange orig_conv;
36606         orig_conv.inner = untag_ptr(orig);
36607         orig_conv.is_owned = ptr_is_owned(orig);
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36609         orig_conv.is_owned = false;
36610         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
36611         int64_t ret_ref = 0;
36612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36614         return ret_ref;
36615 }
36616
36617 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36618         LDKClosingSignedFeeRange a_conv;
36619         a_conv.inner = untag_ptr(a);
36620         a_conv.is_owned = ptr_is_owned(a);
36621         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36622         a_conv.is_owned = false;
36623         LDKClosingSignedFeeRange b_conv;
36624         b_conv.inner = untag_ptr(b);
36625         b_conv.is_owned = ptr_is_owned(b);
36626         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36627         b_conv.is_owned = false;
36628         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
36629         return ret_conv;
36630 }
36631
36632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36633         LDKClosingSigned this_obj_conv;
36634         this_obj_conv.inner = untag_ptr(this_obj);
36635         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36637         ClosingSigned_free(this_obj_conv);
36638 }
36639
36640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36641         LDKClosingSigned this_ptr_conv;
36642         this_ptr_conv.inner = untag_ptr(this_ptr);
36643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36645         this_ptr_conv.is_owned = false;
36646         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
36648         return ret_arr;
36649 }
36650
36651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36652         LDKClosingSigned this_ptr_conv;
36653         this_ptr_conv.inner = untag_ptr(this_ptr);
36654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36656         this_ptr_conv.is_owned = false;
36657         LDKThirtyTwoBytes val_ref;
36658         CHECK((*env)->GetArrayLength(env, val) == 32);
36659         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36660         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
36661 }
36662
36663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36664         LDKClosingSigned this_ptr_conv;
36665         this_ptr_conv.inner = untag_ptr(this_ptr);
36666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36668         this_ptr_conv.is_owned = false;
36669         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
36670         return ret_conv;
36671 }
36672
36673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36674         LDKClosingSigned this_ptr_conv;
36675         this_ptr_conv.inner = untag_ptr(this_ptr);
36676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36678         this_ptr_conv.is_owned = false;
36679         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
36680 }
36681
36682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36683         LDKClosingSigned this_ptr_conv;
36684         this_ptr_conv.inner = untag_ptr(this_ptr);
36685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36687         this_ptr_conv.is_owned = false;
36688         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
36690         return ret_arr;
36691 }
36692
36693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
36700         CHECK((*env)->GetArrayLength(env, val) == 64);
36701         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36702         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
36703 }
36704
36705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36706         LDKClosingSigned this_ptr_conv;
36707         this_ptr_conv.inner = untag_ptr(this_ptr);
36708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36710         this_ptr_conv.is_owned = false;
36711         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
36712         int64_t ret_ref = 0;
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36715         return ret_ref;
36716 }
36717
36718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36719         LDKClosingSigned this_ptr_conv;
36720         this_ptr_conv.inner = untag_ptr(this_ptr);
36721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36723         this_ptr_conv.is_owned = false;
36724         LDKClosingSignedFeeRange val_conv;
36725         val_conv.inner = untag_ptr(val);
36726         val_conv.is_owned = ptr_is_owned(val);
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36728         val_conv = ClosingSignedFeeRange_clone(&val_conv);
36729         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
36730 }
36731
36732 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) {
36733         LDKThirtyTwoBytes channel_id_arg_ref;
36734         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36735         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36736         LDKSignature signature_arg_ref;
36737         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36738         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36739         LDKClosingSignedFeeRange fee_range_arg_conv;
36740         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36741         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36742         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36743         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36744         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36745         int64_t ret_ref = 0;
36746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36748         return ret_ref;
36749 }
36750
36751 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36752         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36753         int64_t ret_ref = 0;
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36756         return ret_ref;
36757 }
36758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36759         LDKClosingSigned arg_conv;
36760         arg_conv.inner = untag_ptr(arg);
36761         arg_conv.is_owned = ptr_is_owned(arg);
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36763         arg_conv.is_owned = false;
36764         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36765         return ret_conv;
36766 }
36767
36768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36769         LDKClosingSigned orig_conv;
36770         orig_conv.inner = untag_ptr(orig);
36771         orig_conv.is_owned = ptr_is_owned(orig);
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36773         orig_conv.is_owned = false;
36774         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36775         int64_t ret_ref = 0;
36776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36778         return ret_ref;
36779 }
36780
36781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36782         LDKClosingSigned a_conv;
36783         a_conv.inner = untag_ptr(a);
36784         a_conv.is_owned = ptr_is_owned(a);
36785         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36786         a_conv.is_owned = false;
36787         LDKClosingSigned b_conv;
36788         b_conv.inner = untag_ptr(b);
36789         b_conv.is_owned = ptr_is_owned(b);
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36791         b_conv.is_owned = false;
36792         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36793         return ret_conv;
36794 }
36795
36796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36797         LDKUpdateAddHTLC this_obj_conv;
36798         this_obj_conv.inner = untag_ptr(this_obj);
36799         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36801         UpdateAddHTLC_free(this_obj_conv);
36802 }
36803
36804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36805         LDKUpdateAddHTLC this_ptr_conv;
36806         this_ptr_conv.inner = untag_ptr(this_ptr);
36807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36809         this_ptr_conv.is_owned = false;
36810         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36812         return ret_arr;
36813 }
36814
36815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36816         LDKUpdateAddHTLC this_ptr_conv;
36817         this_ptr_conv.inner = untag_ptr(this_ptr);
36818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36820         this_ptr_conv.is_owned = false;
36821         LDKThirtyTwoBytes val_ref;
36822         CHECK((*env)->GetArrayLength(env, val) == 32);
36823         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36824         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36825 }
36826
36827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36828         LDKUpdateAddHTLC this_ptr_conv;
36829         this_ptr_conv.inner = untag_ptr(this_ptr);
36830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36832         this_ptr_conv.is_owned = false;
36833         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36834         return ret_conv;
36835 }
36836
36837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36838         LDKUpdateAddHTLC this_ptr_conv;
36839         this_ptr_conv.inner = untag_ptr(this_ptr);
36840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36842         this_ptr_conv.is_owned = false;
36843         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36844 }
36845
36846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36847         LDKUpdateAddHTLC this_ptr_conv;
36848         this_ptr_conv.inner = untag_ptr(this_ptr);
36849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36851         this_ptr_conv.is_owned = false;
36852         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36853         return ret_conv;
36854 }
36855
36856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36857         LDKUpdateAddHTLC this_ptr_conv;
36858         this_ptr_conv.inner = untag_ptr(this_ptr);
36859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36861         this_ptr_conv.is_owned = false;
36862         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36863 }
36864
36865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36866         LDKUpdateAddHTLC this_ptr_conv;
36867         this_ptr_conv.inner = untag_ptr(this_ptr);
36868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36870         this_ptr_conv.is_owned = false;
36871         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36873         return ret_arr;
36874 }
36875
36876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
36883         CHECK((*env)->GetArrayLength(env, val) == 32);
36884         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36885         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36886 }
36887
36888 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36889         LDKUpdateAddHTLC this_ptr_conv;
36890         this_ptr_conv.inner = untag_ptr(this_ptr);
36891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36893         this_ptr_conv.is_owned = false;
36894         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36895         return ret_conv;
36896 }
36897
36898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36899         LDKUpdateAddHTLC this_ptr_conv;
36900         this_ptr_conv.inner = untag_ptr(this_ptr);
36901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36903         this_ptr_conv.is_owned = false;
36904         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36905 }
36906
36907 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36908         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36909         int64_t ret_ref = 0;
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36912         return ret_ref;
36913 }
36914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36915         LDKUpdateAddHTLC arg_conv;
36916         arg_conv.inner = untag_ptr(arg);
36917         arg_conv.is_owned = ptr_is_owned(arg);
36918         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36919         arg_conv.is_owned = false;
36920         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36921         return ret_conv;
36922 }
36923
36924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36925         LDKUpdateAddHTLC orig_conv;
36926         orig_conv.inner = untag_ptr(orig);
36927         orig_conv.is_owned = ptr_is_owned(orig);
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36929         orig_conv.is_owned = false;
36930         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36931         int64_t ret_ref = 0;
36932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36934         return ret_ref;
36935 }
36936
36937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36938         LDKUpdateAddHTLC a_conv;
36939         a_conv.inner = untag_ptr(a);
36940         a_conv.is_owned = ptr_is_owned(a);
36941         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36942         a_conv.is_owned = false;
36943         LDKUpdateAddHTLC b_conv;
36944         b_conv.inner = untag_ptr(b);
36945         b_conv.is_owned = ptr_is_owned(b);
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36947         b_conv.is_owned = false;
36948         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36949         return ret_conv;
36950 }
36951
36952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36953         LDKOnionMessage this_obj_conv;
36954         this_obj_conv.inner = untag_ptr(this_obj);
36955         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36957         OnionMessage_free(this_obj_conv);
36958 }
36959
36960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36961         LDKOnionMessage this_ptr_conv;
36962         this_ptr_conv.inner = untag_ptr(this_ptr);
36963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36965         this_ptr_conv.is_owned = false;
36966         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36967         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36968         return ret_arr;
36969 }
36970
36971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36972         LDKOnionMessage this_ptr_conv;
36973         this_ptr_conv.inner = untag_ptr(this_ptr);
36974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36976         this_ptr_conv.is_owned = false;
36977         LDKPublicKey val_ref;
36978         CHECK((*env)->GetArrayLength(env, val) == 33);
36979         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36980         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36981 }
36982
36983 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
36984         LDKOnionMessage ret_var = OnionMessage_clone(arg);
36985         int64_t ret_ref = 0;
36986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36988         return ret_ref;
36989 }
36990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36991         LDKOnionMessage arg_conv;
36992         arg_conv.inner = untag_ptr(arg);
36993         arg_conv.is_owned = ptr_is_owned(arg);
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36995         arg_conv.is_owned = false;
36996         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
36997         return ret_conv;
36998 }
36999
37000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37001         LDKOnionMessage orig_conv;
37002         orig_conv.inner = untag_ptr(orig);
37003         orig_conv.is_owned = ptr_is_owned(orig);
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37005         orig_conv.is_owned = false;
37006         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
37007         int64_t ret_ref = 0;
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37010         return ret_ref;
37011 }
37012
37013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37014         LDKOnionMessage a_conv;
37015         a_conv.inner = untag_ptr(a);
37016         a_conv.is_owned = ptr_is_owned(a);
37017         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37018         a_conv.is_owned = false;
37019         LDKOnionMessage b_conv;
37020         b_conv.inner = untag_ptr(b);
37021         b_conv.is_owned = ptr_is_owned(b);
37022         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37023         b_conv.is_owned = false;
37024         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
37025         return ret_conv;
37026 }
37027
37028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37029         LDKUpdateFulfillHTLC this_obj_conv;
37030         this_obj_conv.inner = untag_ptr(this_obj);
37031         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37033         UpdateFulfillHTLC_free(this_obj_conv);
37034 }
37035
37036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37037         LDKUpdateFulfillHTLC this_ptr_conv;
37038         this_ptr_conv.inner = untag_ptr(this_ptr);
37039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37041         this_ptr_conv.is_owned = false;
37042         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
37044         return ret_arr;
37045 }
37046
37047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37048         LDKUpdateFulfillHTLC this_ptr_conv;
37049         this_ptr_conv.inner = untag_ptr(this_ptr);
37050         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37052         this_ptr_conv.is_owned = false;
37053         LDKThirtyTwoBytes val_ref;
37054         CHECK((*env)->GetArrayLength(env, val) == 32);
37055         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37056         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
37057 }
37058
37059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37060         LDKUpdateFulfillHTLC this_ptr_conv;
37061         this_ptr_conv.inner = untag_ptr(this_ptr);
37062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37064         this_ptr_conv.is_owned = false;
37065         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
37066         return ret_conv;
37067 }
37068
37069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37070         LDKUpdateFulfillHTLC this_ptr_conv;
37071         this_ptr_conv.inner = untag_ptr(this_ptr);
37072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37074         this_ptr_conv.is_owned = false;
37075         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
37076 }
37077
37078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
37079         LDKUpdateFulfillHTLC this_ptr_conv;
37080         this_ptr_conv.inner = untag_ptr(this_ptr);
37081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37083         this_ptr_conv.is_owned = false;
37084         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
37086         return ret_arr;
37087 }
37088
37089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
37096         CHECK((*env)->GetArrayLength(env, val) == 32);
37097         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37098         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
37099 }
37100
37101 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) {
37102         LDKThirtyTwoBytes channel_id_arg_ref;
37103         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37104         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37105         LDKThirtyTwoBytes payment_preimage_arg_ref;
37106         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
37107         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
37108         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
37109         int64_t ret_ref = 0;
37110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37112         return ret_ref;
37113 }
37114
37115 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
37116         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
37117         int64_t ret_ref = 0;
37118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37120         return ret_ref;
37121 }
37122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37123         LDKUpdateFulfillHTLC arg_conv;
37124         arg_conv.inner = untag_ptr(arg);
37125         arg_conv.is_owned = ptr_is_owned(arg);
37126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37127         arg_conv.is_owned = false;
37128         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
37129         return ret_conv;
37130 }
37131
37132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37133         LDKUpdateFulfillHTLC orig_conv;
37134         orig_conv.inner = untag_ptr(orig);
37135         orig_conv.is_owned = ptr_is_owned(orig);
37136         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37137         orig_conv.is_owned = false;
37138         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
37139         int64_t ret_ref = 0;
37140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37142         return ret_ref;
37143 }
37144
37145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37146         LDKUpdateFulfillHTLC a_conv;
37147         a_conv.inner = untag_ptr(a);
37148         a_conv.is_owned = ptr_is_owned(a);
37149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37150         a_conv.is_owned = false;
37151         LDKUpdateFulfillHTLC b_conv;
37152         b_conv.inner = untag_ptr(b);
37153         b_conv.is_owned = ptr_is_owned(b);
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37155         b_conv.is_owned = false;
37156         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
37157         return ret_conv;
37158 }
37159
37160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37161         LDKUpdateFailHTLC this_obj_conv;
37162         this_obj_conv.inner = untag_ptr(this_obj);
37163         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37165         UpdateFailHTLC_free(this_obj_conv);
37166 }
37167
37168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37169         LDKUpdateFailHTLC this_ptr_conv;
37170         this_ptr_conv.inner = untag_ptr(this_ptr);
37171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37173         this_ptr_conv.is_owned = false;
37174         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
37176         return ret_arr;
37177 }
37178
37179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37180         LDKUpdateFailHTLC this_ptr_conv;
37181         this_ptr_conv.inner = untag_ptr(this_ptr);
37182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37184         this_ptr_conv.is_owned = false;
37185         LDKThirtyTwoBytes val_ref;
37186         CHECK((*env)->GetArrayLength(env, val) == 32);
37187         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37188         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
37189 }
37190
37191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37192         LDKUpdateFailHTLC this_ptr_conv;
37193         this_ptr_conv.inner = untag_ptr(this_ptr);
37194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37196         this_ptr_conv.is_owned = false;
37197         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
37198         return ret_conv;
37199 }
37200
37201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37202         LDKUpdateFailHTLC this_ptr_conv;
37203         this_ptr_conv.inner = untag_ptr(this_ptr);
37204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37206         this_ptr_conv.is_owned = false;
37207         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
37208 }
37209
37210 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
37211         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
37212         int64_t ret_ref = 0;
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37215         return ret_ref;
37216 }
37217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37218         LDKUpdateFailHTLC arg_conv;
37219         arg_conv.inner = untag_ptr(arg);
37220         arg_conv.is_owned = ptr_is_owned(arg);
37221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37222         arg_conv.is_owned = false;
37223         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
37224         return ret_conv;
37225 }
37226
37227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37228         LDKUpdateFailHTLC orig_conv;
37229         orig_conv.inner = untag_ptr(orig);
37230         orig_conv.is_owned = ptr_is_owned(orig);
37231         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37232         orig_conv.is_owned = false;
37233         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
37234         int64_t ret_ref = 0;
37235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37237         return ret_ref;
37238 }
37239
37240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37241         LDKUpdateFailHTLC a_conv;
37242         a_conv.inner = untag_ptr(a);
37243         a_conv.is_owned = ptr_is_owned(a);
37244         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37245         a_conv.is_owned = false;
37246         LDKUpdateFailHTLC b_conv;
37247         b_conv.inner = untag_ptr(b);
37248         b_conv.is_owned = ptr_is_owned(b);
37249         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37250         b_conv.is_owned = false;
37251         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
37252         return ret_conv;
37253 }
37254
37255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37256         LDKUpdateFailMalformedHTLC this_obj_conv;
37257         this_obj_conv.inner = untag_ptr(this_obj);
37258         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37260         UpdateFailMalformedHTLC_free(this_obj_conv);
37261 }
37262
37263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37264         LDKUpdateFailMalformedHTLC this_ptr_conv;
37265         this_ptr_conv.inner = untag_ptr(this_ptr);
37266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37268         this_ptr_conv.is_owned = false;
37269         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
37271         return ret_arr;
37272 }
37273
37274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37275         LDKUpdateFailMalformedHTLC this_ptr_conv;
37276         this_ptr_conv.inner = untag_ptr(this_ptr);
37277         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37279         this_ptr_conv.is_owned = false;
37280         LDKThirtyTwoBytes val_ref;
37281         CHECK((*env)->GetArrayLength(env, val) == 32);
37282         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37283         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
37284 }
37285
37286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37287         LDKUpdateFailMalformedHTLC this_ptr_conv;
37288         this_ptr_conv.inner = untag_ptr(this_ptr);
37289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37291         this_ptr_conv.is_owned = false;
37292         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
37293         return ret_conv;
37294 }
37295
37296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37297         LDKUpdateFailMalformedHTLC this_ptr_conv;
37298         this_ptr_conv.inner = untag_ptr(this_ptr);
37299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37301         this_ptr_conv.is_owned = false;
37302         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
37303 }
37304
37305 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
37306         LDKUpdateFailMalformedHTLC this_ptr_conv;
37307         this_ptr_conv.inner = untag_ptr(this_ptr);
37308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37310         this_ptr_conv.is_owned = false;
37311         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
37312         return ret_conv;
37313 }
37314
37315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37316         LDKUpdateFailMalformedHTLC this_ptr_conv;
37317         this_ptr_conv.inner = untag_ptr(this_ptr);
37318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37320         this_ptr_conv.is_owned = false;
37321         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
37322 }
37323
37324 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
37325         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
37326         int64_t ret_ref = 0;
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37329         return ret_ref;
37330 }
37331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37332         LDKUpdateFailMalformedHTLC arg_conv;
37333         arg_conv.inner = untag_ptr(arg);
37334         arg_conv.is_owned = ptr_is_owned(arg);
37335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37336         arg_conv.is_owned = false;
37337         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
37338         return ret_conv;
37339 }
37340
37341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37342         LDKUpdateFailMalformedHTLC orig_conv;
37343         orig_conv.inner = untag_ptr(orig);
37344         orig_conv.is_owned = ptr_is_owned(orig);
37345         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37346         orig_conv.is_owned = false;
37347         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
37348         int64_t ret_ref = 0;
37349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37350         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37351         return ret_ref;
37352 }
37353
37354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37355         LDKUpdateFailMalformedHTLC a_conv;
37356         a_conv.inner = untag_ptr(a);
37357         a_conv.is_owned = ptr_is_owned(a);
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37359         a_conv.is_owned = false;
37360         LDKUpdateFailMalformedHTLC b_conv;
37361         b_conv.inner = untag_ptr(b);
37362         b_conv.is_owned = ptr_is_owned(b);
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37364         b_conv.is_owned = false;
37365         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
37366         return ret_conv;
37367 }
37368
37369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37370         LDKCommitmentSigned this_obj_conv;
37371         this_obj_conv.inner = untag_ptr(this_obj);
37372         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37374         CommitmentSigned_free(this_obj_conv);
37375 }
37376
37377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37378         LDKCommitmentSigned this_ptr_conv;
37379         this_ptr_conv.inner = untag_ptr(this_ptr);
37380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37382         this_ptr_conv.is_owned = false;
37383         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37384         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
37385         return ret_arr;
37386 }
37387
37388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37389         LDKCommitmentSigned this_ptr_conv;
37390         this_ptr_conv.inner = untag_ptr(this_ptr);
37391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37393         this_ptr_conv.is_owned = false;
37394         LDKThirtyTwoBytes val_ref;
37395         CHECK((*env)->GetArrayLength(env, val) == 32);
37396         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37397         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
37398 }
37399
37400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37401         LDKCommitmentSigned this_ptr_conv;
37402         this_ptr_conv.inner = untag_ptr(this_ptr);
37403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37405         this_ptr_conv.is_owned = false;
37406         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37407         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
37408         return ret_arr;
37409 }
37410
37411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37412         LDKCommitmentSigned this_ptr_conv;
37413         this_ptr_conv.inner = untag_ptr(this_ptr);
37414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37416         this_ptr_conv.is_owned = false;
37417         LDKSignature val_ref;
37418         CHECK((*env)->GetArrayLength(env, val) == 64);
37419         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37420         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
37421 }
37422
37423 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
37424         LDKCommitmentSigned this_ptr_conv;
37425         this_ptr_conv.inner = untag_ptr(this_ptr);
37426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37428         this_ptr_conv.is_owned = false;
37429         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
37430         jobjectArray ret_arr = NULL;
37431         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37432         ;
37433         for (size_t i = 0; i < ret_var.datalen; i++) {
37434                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
37435                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
37436                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37437         }
37438         
37439         FREE(ret_var.data);
37440         return ret_arr;
37441 }
37442
37443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
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 val_constr;
37450         val_constr.datalen = (*env)->GetArrayLength(env, val);
37451         if (val_constr.datalen > 0)
37452                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37453         else
37454                 val_constr.data = NULL;
37455         for (size_t i = 0; i < val_constr.datalen; i++) {
37456                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37457                 LDKSignature val_conv_8_ref;
37458                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37459                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37460                 val_constr.data[i] = val_conv_8_ref;
37461         }
37462         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
37463 }
37464
37465 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) {
37466         LDKThirtyTwoBytes channel_id_arg_ref;
37467         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37468         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37469         LDKSignature signature_arg_ref;
37470         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37471         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37472         LDKCVec_SignatureZ htlc_signatures_arg_constr;
37473         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
37474         if (htlc_signatures_arg_constr.datalen > 0)
37475                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37476         else
37477                 htlc_signatures_arg_constr.data = NULL;
37478         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
37479                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
37480                 LDKSignature htlc_signatures_arg_conv_8_ref;
37481                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
37482                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
37483                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
37484         }
37485         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
37486         int64_t ret_ref = 0;
37487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37489         return ret_ref;
37490 }
37491
37492 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
37493         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
37494         int64_t ret_ref = 0;
37495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37497         return ret_ref;
37498 }
37499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37500         LDKCommitmentSigned arg_conv;
37501         arg_conv.inner = untag_ptr(arg);
37502         arg_conv.is_owned = ptr_is_owned(arg);
37503         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37504         arg_conv.is_owned = false;
37505         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
37506         return ret_conv;
37507 }
37508
37509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37510         LDKCommitmentSigned orig_conv;
37511         orig_conv.inner = untag_ptr(orig);
37512         orig_conv.is_owned = ptr_is_owned(orig);
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37514         orig_conv.is_owned = false;
37515         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
37516         int64_t ret_ref = 0;
37517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37519         return ret_ref;
37520 }
37521
37522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37523         LDKCommitmentSigned a_conv;
37524         a_conv.inner = untag_ptr(a);
37525         a_conv.is_owned = ptr_is_owned(a);
37526         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37527         a_conv.is_owned = false;
37528         LDKCommitmentSigned b_conv;
37529         b_conv.inner = untag_ptr(b);
37530         b_conv.is_owned = ptr_is_owned(b);
37531         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37532         b_conv.is_owned = false;
37533         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
37534         return ret_conv;
37535 }
37536
37537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37538         LDKRevokeAndACK this_obj_conv;
37539         this_obj_conv.inner = untag_ptr(this_obj);
37540         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37542         RevokeAndACK_free(this_obj_conv);
37543 }
37544
37545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37546         LDKRevokeAndACK this_ptr_conv;
37547         this_ptr_conv.inner = untag_ptr(this_ptr);
37548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37550         this_ptr_conv.is_owned = false;
37551         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37552         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
37553         return ret_arr;
37554 }
37555
37556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37557         LDKRevokeAndACK this_ptr_conv;
37558         this_ptr_conv.inner = untag_ptr(this_ptr);
37559         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37561         this_ptr_conv.is_owned = false;
37562         LDKThirtyTwoBytes val_ref;
37563         CHECK((*env)->GetArrayLength(env, val) == 32);
37564         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37565         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
37566 }
37567
37568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37569         LDKRevokeAndACK this_ptr_conv;
37570         this_ptr_conv.inner = untag_ptr(this_ptr);
37571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37573         this_ptr_conv.is_owned = false;
37574         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
37576         return ret_arr;
37577 }
37578
37579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37580         LDKRevokeAndACK this_ptr_conv;
37581         this_ptr_conv.inner = untag_ptr(this_ptr);
37582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37584         this_ptr_conv.is_owned = false;
37585         LDKThirtyTwoBytes val_ref;
37586         CHECK((*env)->GetArrayLength(env, val) == 32);
37587         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37588         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
37589 }
37590
37591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37592         LDKRevokeAndACK this_ptr_conv;
37593         this_ptr_conv.inner = untag_ptr(this_ptr);
37594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37596         this_ptr_conv.is_owned = false;
37597         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
37599         return ret_arr;
37600 }
37601
37602 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) {
37603         LDKRevokeAndACK this_ptr_conv;
37604         this_ptr_conv.inner = untag_ptr(this_ptr);
37605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37607         this_ptr_conv.is_owned = false;
37608         LDKPublicKey val_ref;
37609         CHECK((*env)->GetArrayLength(env, val) == 33);
37610         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37611         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
37612 }
37613
37614 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) {
37615         LDKThirtyTwoBytes channel_id_arg_ref;
37616         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37617         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37618         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
37619         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
37620         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
37621         LDKPublicKey next_per_commitment_point_arg_ref;
37622         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
37623         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
37624         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
37625         int64_t ret_ref = 0;
37626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37628         return ret_ref;
37629 }
37630
37631 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
37632         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
37633         int64_t ret_ref = 0;
37634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37636         return ret_ref;
37637 }
37638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37639         LDKRevokeAndACK arg_conv;
37640         arg_conv.inner = untag_ptr(arg);
37641         arg_conv.is_owned = ptr_is_owned(arg);
37642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37643         arg_conv.is_owned = false;
37644         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
37645         return ret_conv;
37646 }
37647
37648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37649         LDKRevokeAndACK orig_conv;
37650         orig_conv.inner = untag_ptr(orig);
37651         orig_conv.is_owned = ptr_is_owned(orig);
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37653         orig_conv.is_owned = false;
37654         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
37655         int64_t ret_ref = 0;
37656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37657         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37658         return ret_ref;
37659 }
37660
37661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37662         LDKRevokeAndACK a_conv;
37663         a_conv.inner = untag_ptr(a);
37664         a_conv.is_owned = ptr_is_owned(a);
37665         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37666         a_conv.is_owned = false;
37667         LDKRevokeAndACK b_conv;
37668         b_conv.inner = untag_ptr(b);
37669         b_conv.is_owned = ptr_is_owned(b);
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37671         b_conv.is_owned = false;
37672         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
37673         return ret_conv;
37674 }
37675
37676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37677         LDKUpdateFee this_obj_conv;
37678         this_obj_conv.inner = untag_ptr(this_obj);
37679         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37681         UpdateFee_free(this_obj_conv);
37682 }
37683
37684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37685         LDKUpdateFee this_ptr_conv;
37686         this_ptr_conv.inner = untag_ptr(this_ptr);
37687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37689         this_ptr_conv.is_owned = false;
37690         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37691         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
37692         return ret_arr;
37693 }
37694
37695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37696         LDKUpdateFee this_ptr_conv;
37697         this_ptr_conv.inner = untag_ptr(this_ptr);
37698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37700         this_ptr_conv.is_owned = false;
37701         LDKThirtyTwoBytes val_ref;
37702         CHECK((*env)->GetArrayLength(env, val) == 32);
37703         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37704         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
37705 }
37706
37707 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
37708         LDKUpdateFee this_ptr_conv;
37709         this_ptr_conv.inner = untag_ptr(this_ptr);
37710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37712         this_ptr_conv.is_owned = false;
37713         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
37714         return ret_conv;
37715 }
37716
37717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37718         LDKUpdateFee this_ptr_conv;
37719         this_ptr_conv.inner = untag_ptr(this_ptr);
37720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37722         this_ptr_conv.is_owned = false;
37723         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
37724 }
37725
37726 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) {
37727         LDKThirtyTwoBytes channel_id_arg_ref;
37728         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37729         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37730         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
37731         int64_t ret_ref = 0;
37732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37734         return ret_ref;
37735 }
37736
37737 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37738         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37739         int64_t ret_ref = 0;
37740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37742         return ret_ref;
37743 }
37744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37745         LDKUpdateFee arg_conv;
37746         arg_conv.inner = untag_ptr(arg);
37747         arg_conv.is_owned = ptr_is_owned(arg);
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37749         arg_conv.is_owned = false;
37750         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37751         return ret_conv;
37752 }
37753
37754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37755         LDKUpdateFee orig_conv;
37756         orig_conv.inner = untag_ptr(orig);
37757         orig_conv.is_owned = ptr_is_owned(orig);
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37759         orig_conv.is_owned = false;
37760         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37761         int64_t ret_ref = 0;
37762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37764         return ret_ref;
37765 }
37766
37767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37768         LDKUpdateFee a_conv;
37769         a_conv.inner = untag_ptr(a);
37770         a_conv.is_owned = ptr_is_owned(a);
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37772         a_conv.is_owned = false;
37773         LDKUpdateFee b_conv;
37774         b_conv.inner = untag_ptr(b);
37775         b_conv.is_owned = ptr_is_owned(b);
37776         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37777         b_conv.is_owned = false;
37778         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37779         return ret_conv;
37780 }
37781
37782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37783         LDKDataLossProtect this_obj_conv;
37784         this_obj_conv.inner = untag_ptr(this_obj);
37785         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37787         DataLossProtect_free(this_obj_conv);
37788 }
37789
37790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37791         LDKDataLossProtect this_ptr_conv;
37792         this_ptr_conv.inner = untag_ptr(this_ptr);
37793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37795         this_ptr_conv.is_owned = false;
37796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37798         return ret_arr;
37799 }
37800
37801 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) {
37802         LDKDataLossProtect this_ptr_conv;
37803         this_ptr_conv.inner = untag_ptr(this_ptr);
37804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37806         this_ptr_conv.is_owned = false;
37807         LDKThirtyTwoBytes val_ref;
37808         CHECK((*env)->GetArrayLength(env, val) == 32);
37809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37810         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37811 }
37812
37813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37814         LDKDataLossProtect this_ptr_conv;
37815         this_ptr_conv.inner = untag_ptr(this_ptr);
37816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37818         this_ptr_conv.is_owned = false;
37819         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37821         return ret_arr;
37822 }
37823
37824 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) {
37825         LDKDataLossProtect this_ptr_conv;
37826         this_ptr_conv.inner = untag_ptr(this_ptr);
37827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37829         this_ptr_conv.is_owned = false;
37830         LDKPublicKey val_ref;
37831         CHECK((*env)->GetArrayLength(env, val) == 33);
37832         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37833         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37834 }
37835
37836 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) {
37837         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37838         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37839         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37840         LDKPublicKey my_current_per_commitment_point_arg_ref;
37841         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37842         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37843         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37844         int64_t ret_ref = 0;
37845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37847         return ret_ref;
37848 }
37849
37850 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37851         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37852         int64_t ret_ref = 0;
37853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37855         return ret_ref;
37856 }
37857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37858         LDKDataLossProtect arg_conv;
37859         arg_conv.inner = untag_ptr(arg);
37860         arg_conv.is_owned = ptr_is_owned(arg);
37861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37862         arg_conv.is_owned = false;
37863         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37864         return ret_conv;
37865 }
37866
37867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37868         LDKDataLossProtect orig_conv;
37869         orig_conv.inner = untag_ptr(orig);
37870         orig_conv.is_owned = ptr_is_owned(orig);
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37872         orig_conv.is_owned = false;
37873         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37874         int64_t ret_ref = 0;
37875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37877         return ret_ref;
37878 }
37879
37880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37881         LDKDataLossProtect a_conv;
37882         a_conv.inner = untag_ptr(a);
37883         a_conv.is_owned = ptr_is_owned(a);
37884         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37885         a_conv.is_owned = false;
37886         LDKDataLossProtect b_conv;
37887         b_conv.inner = untag_ptr(b);
37888         b_conv.is_owned = ptr_is_owned(b);
37889         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37890         b_conv.is_owned = false;
37891         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37892         return ret_conv;
37893 }
37894
37895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37896         LDKChannelReestablish this_obj_conv;
37897         this_obj_conv.inner = untag_ptr(this_obj);
37898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37900         ChannelReestablish_free(this_obj_conv);
37901 }
37902
37903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37904         LDKChannelReestablish this_ptr_conv;
37905         this_ptr_conv.inner = untag_ptr(this_ptr);
37906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37908         this_ptr_conv.is_owned = false;
37909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37911         return ret_arr;
37912 }
37913
37914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37915         LDKChannelReestablish this_ptr_conv;
37916         this_ptr_conv.inner = untag_ptr(this_ptr);
37917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37919         this_ptr_conv.is_owned = false;
37920         LDKThirtyTwoBytes val_ref;
37921         CHECK((*env)->GetArrayLength(env, val) == 32);
37922         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37923         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37924 }
37925
37926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37927         LDKChannelReestablish this_ptr_conv;
37928         this_ptr_conv.inner = untag_ptr(this_ptr);
37929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37931         this_ptr_conv.is_owned = false;
37932         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37933         return ret_conv;
37934 }
37935
37936 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) {
37937         LDKChannelReestablish this_ptr_conv;
37938         this_ptr_conv.inner = untag_ptr(this_ptr);
37939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37941         this_ptr_conv.is_owned = false;
37942         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37943 }
37944
37945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37946         LDKChannelReestablish this_ptr_conv;
37947         this_ptr_conv.inner = untag_ptr(this_ptr);
37948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37950         this_ptr_conv.is_owned = false;
37951         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37952         return ret_conv;
37953 }
37954
37955 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) {
37956         LDKChannelReestablish this_ptr_conv;
37957         this_ptr_conv.inner = untag_ptr(this_ptr);
37958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37960         this_ptr_conv.is_owned = false;
37961         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37962 }
37963
37964 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37965         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37966         int64_t ret_ref = 0;
37967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37969         return ret_ref;
37970 }
37971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37972         LDKChannelReestablish arg_conv;
37973         arg_conv.inner = untag_ptr(arg);
37974         arg_conv.is_owned = ptr_is_owned(arg);
37975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37976         arg_conv.is_owned = false;
37977         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37978         return ret_conv;
37979 }
37980
37981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37982         LDKChannelReestablish orig_conv;
37983         orig_conv.inner = untag_ptr(orig);
37984         orig_conv.is_owned = ptr_is_owned(orig);
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37986         orig_conv.is_owned = false;
37987         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
37988         int64_t ret_ref = 0;
37989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37991         return ret_ref;
37992 }
37993
37994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37995         LDKChannelReestablish a_conv;
37996         a_conv.inner = untag_ptr(a);
37997         a_conv.is_owned = ptr_is_owned(a);
37998         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37999         a_conv.is_owned = false;
38000         LDKChannelReestablish b_conv;
38001         b_conv.inner = untag_ptr(b);
38002         b_conv.is_owned = ptr_is_owned(b);
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38004         b_conv.is_owned = false;
38005         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
38006         return ret_conv;
38007 }
38008
38009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38010         LDKAnnouncementSignatures this_obj_conv;
38011         this_obj_conv.inner = untag_ptr(this_obj);
38012         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38014         AnnouncementSignatures_free(this_obj_conv);
38015 }
38016
38017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38018         LDKAnnouncementSignatures this_ptr_conv;
38019         this_ptr_conv.inner = untag_ptr(this_ptr);
38020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38022         this_ptr_conv.is_owned = false;
38023         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
38025         return ret_arr;
38026 }
38027
38028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38029         LDKAnnouncementSignatures this_ptr_conv;
38030         this_ptr_conv.inner = untag_ptr(this_ptr);
38031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38033         this_ptr_conv.is_owned = false;
38034         LDKThirtyTwoBytes val_ref;
38035         CHECK((*env)->GetArrayLength(env, val) == 32);
38036         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38037         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
38038 }
38039
38040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38041         LDKAnnouncementSignatures this_ptr_conv;
38042         this_ptr_conv.inner = untag_ptr(this_ptr);
38043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38045         this_ptr_conv.is_owned = false;
38046         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
38047         return ret_conv;
38048 }
38049
38050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38051         LDKAnnouncementSignatures this_ptr_conv;
38052         this_ptr_conv.inner = untag_ptr(this_ptr);
38053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38055         this_ptr_conv.is_owned = false;
38056         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
38057 }
38058
38059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38060         LDKAnnouncementSignatures this_ptr_conv;
38061         this_ptr_conv.inner = untag_ptr(this_ptr);
38062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38064         this_ptr_conv.is_owned = false;
38065         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
38067         return ret_arr;
38068 }
38069
38070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
38077         CHECK((*env)->GetArrayLength(env, val) == 64);
38078         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38079         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
38080 }
38081
38082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38083         LDKAnnouncementSignatures this_ptr_conv;
38084         this_ptr_conv.inner = untag_ptr(this_ptr);
38085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38087         this_ptr_conv.is_owned = false;
38088         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
38090         return ret_arr;
38091 }
38092
38093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38094         LDKAnnouncementSignatures this_ptr_conv;
38095         this_ptr_conv.inner = untag_ptr(this_ptr);
38096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38098         this_ptr_conv.is_owned = false;
38099         LDKSignature val_ref;
38100         CHECK((*env)->GetArrayLength(env, val) == 64);
38101         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38102         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
38103 }
38104
38105 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) {
38106         LDKThirtyTwoBytes channel_id_arg_ref;
38107         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
38108         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
38109         LDKSignature node_signature_arg_ref;
38110         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
38111         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
38112         LDKSignature bitcoin_signature_arg_ref;
38113         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
38114         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
38115         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
38116         int64_t ret_ref = 0;
38117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38119         return ret_ref;
38120 }
38121
38122 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
38123         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
38124         int64_t ret_ref = 0;
38125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38127         return ret_ref;
38128 }
38129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38130         LDKAnnouncementSignatures arg_conv;
38131         arg_conv.inner = untag_ptr(arg);
38132         arg_conv.is_owned = ptr_is_owned(arg);
38133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38134         arg_conv.is_owned = false;
38135         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
38136         return ret_conv;
38137 }
38138
38139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38140         LDKAnnouncementSignatures orig_conv;
38141         orig_conv.inner = untag_ptr(orig);
38142         orig_conv.is_owned = ptr_is_owned(orig);
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38144         orig_conv.is_owned = false;
38145         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
38146         int64_t ret_ref = 0;
38147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38149         return ret_ref;
38150 }
38151
38152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38153         LDKAnnouncementSignatures a_conv;
38154         a_conv.inner = untag_ptr(a);
38155         a_conv.is_owned = ptr_is_owned(a);
38156         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38157         a_conv.is_owned = false;
38158         LDKAnnouncementSignatures b_conv;
38159         b_conv.inner = untag_ptr(b);
38160         b_conv.is_owned = ptr_is_owned(b);
38161         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38162         b_conv.is_owned = false;
38163         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
38164         return ret_conv;
38165 }
38166
38167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38168         if (!ptr_is_owned(this_ptr)) return;
38169         void* this_ptr_ptr = untag_ptr(this_ptr);
38170         CHECK_ACCESS(this_ptr_ptr);
38171         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
38172         FREE(untag_ptr(this_ptr));
38173         NetAddress_free(this_ptr_conv);
38174 }
38175
38176 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
38177         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38178         *ret_copy = NetAddress_clone(arg);
38179         int64_t ret_ref = tag_ptr(ret_copy, true);
38180         return ret_ref;
38181 }
38182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38183         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
38184         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
38185         return ret_conv;
38186 }
38187
38188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38189         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
38190         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38191         *ret_copy = NetAddress_clone(orig_conv);
38192         int64_t ret_ref = tag_ptr(ret_copy, true);
38193         return ret_ref;
38194 }
38195
38196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38197         LDKFourBytes addr_ref;
38198         CHECK((*env)->GetArrayLength(env, addr) == 4);
38199         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
38200         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38201         *ret_copy = NetAddress_ipv4(addr_ref, port);
38202         int64_t ret_ref = tag_ptr(ret_copy, true);
38203         return ret_ref;
38204 }
38205
38206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38207         LDKSixteenBytes addr_ref;
38208         CHECK((*env)->GetArrayLength(env, addr) == 16);
38209         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
38210         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38211         *ret_copy = NetAddress_ipv6(addr_ref, port);
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_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
38217         LDKTwelveBytes a_ref;
38218         CHECK((*env)->GetArrayLength(env, a) == 12);
38219         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
38220         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38221         *ret_copy = NetAddress_onion_v2(a_ref);
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_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
38227         LDKThirtyTwoBytes ed25519_pubkey_ref;
38228         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
38229         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
38230         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38231         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, 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_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
38237         LDKHostname hostname_conv;
38238         hostname_conv.inner = untag_ptr(hostname);
38239         hostname_conv.is_owned = ptr_is_owned(hostname);
38240         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
38241         hostname_conv = Hostname_clone(&hostname_conv);
38242         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38243         *ret_copy = NetAddress_hostname(hostname_conv, port);
38244         int64_t ret_ref = tag_ptr(ret_copy, true);
38245         return ret_ref;
38246 }
38247
38248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38249         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
38250         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
38251         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
38252         return ret_conv;
38253 }
38254
38255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
38256         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
38257         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
38258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38260         CVec_u8Z_free(ret_var);
38261         return ret_arr;
38262 }
38263
38264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38265         LDKu8slice ser_ref;
38266         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38267         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38268         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
38269         *ret_conv = NetAddress_read(ser_ref);
38270         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38271         return tag_ptr(ret_conv, true);
38272 }
38273
38274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38275         if (!ptr_is_owned(this_ptr)) return;
38276         void* this_ptr_ptr = untag_ptr(this_ptr);
38277         CHECK_ACCESS(this_ptr_ptr);
38278         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
38279         FREE(untag_ptr(this_ptr));
38280         UnsignedGossipMessage_free(this_ptr_conv);
38281 }
38282
38283 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
38284         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38285         *ret_copy = UnsignedGossipMessage_clone(arg);
38286         int64_t ret_ref = tag_ptr(ret_copy, true);
38287         return ret_ref;
38288 }
38289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38290         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
38291         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
38292         return ret_conv;
38293 }
38294
38295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38296         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
38297         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38298         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
38299         int64_t ret_ref = tag_ptr(ret_copy, true);
38300         return ret_ref;
38301 }
38302
38303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38304         LDKUnsignedChannelAnnouncement a_conv;
38305         a_conv.inner = untag_ptr(a);
38306         a_conv.is_owned = ptr_is_owned(a);
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38308         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
38309         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38310         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
38311         int64_t ret_ref = tag_ptr(ret_copy, true);
38312         return ret_ref;
38313 }
38314
38315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1update(JNIEnv *env, jclass clz, int64_t a) {
38316         LDKUnsignedChannelUpdate a_conv;
38317         a_conv.inner = untag_ptr(a);
38318         a_conv.is_owned = ptr_is_owned(a);
38319         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38320         a_conv = UnsignedChannelUpdate_clone(&a_conv);
38321         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38322         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
38323         int64_t ret_ref = tag_ptr(ret_copy, true);
38324         return ret_ref;
38325 }
38326
38327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1node_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38328         LDKUnsignedNodeAnnouncement a_conv;
38329         a_conv.inner = untag_ptr(a);
38330         a_conv.is_owned = ptr_is_owned(a);
38331         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38332         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
38333         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38334         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
38335         int64_t ret_ref = tag_ptr(ret_copy, true);
38336         return ret_ref;
38337 }
38338
38339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38340         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
38341         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
38342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38344         CVec_u8Z_free(ret_var);
38345         return ret_arr;
38346 }
38347
38348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38349         LDKUnsignedNodeAnnouncement this_obj_conv;
38350         this_obj_conv.inner = untag_ptr(this_obj);
38351         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38353         UnsignedNodeAnnouncement_free(this_obj_conv);
38354 }
38355
38356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38357         LDKUnsignedNodeAnnouncement this_ptr_conv;
38358         this_ptr_conv.inner = untag_ptr(this_ptr);
38359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38361         this_ptr_conv.is_owned = false;
38362         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
38363         int64_t ret_ref = 0;
38364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38366         return ret_ref;
38367 }
38368
38369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38370         LDKUnsignedNodeAnnouncement this_ptr_conv;
38371         this_ptr_conv.inner = untag_ptr(this_ptr);
38372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38374         this_ptr_conv.is_owned = false;
38375         LDKNodeFeatures val_conv;
38376         val_conv.inner = untag_ptr(val);
38377         val_conv.is_owned = ptr_is_owned(val);
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38379         val_conv = NodeFeatures_clone(&val_conv);
38380         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
38381 }
38382
38383 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38384         LDKUnsignedNodeAnnouncement this_ptr_conv;
38385         this_ptr_conv.inner = untag_ptr(this_ptr);
38386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38388         this_ptr_conv.is_owned = false;
38389         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
38390         return ret_conv;
38391 }
38392
38393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38394         LDKUnsignedNodeAnnouncement this_ptr_conv;
38395         this_ptr_conv.inner = untag_ptr(this_ptr);
38396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38398         this_ptr_conv.is_owned = false;
38399         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
38400 }
38401
38402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38403         LDKUnsignedNodeAnnouncement this_ptr_conv;
38404         this_ptr_conv.inner = untag_ptr(this_ptr);
38405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38407         this_ptr_conv.is_owned = false;
38408         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
38409         int64_t ret_ref = 0;
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38412         return ret_ref;
38413 }
38414
38415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38416         LDKUnsignedNodeAnnouncement this_ptr_conv;
38417         this_ptr_conv.inner = untag_ptr(this_ptr);
38418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38420         this_ptr_conv.is_owned = false;
38421         LDKNodeId val_conv;
38422         val_conv.inner = untag_ptr(val);
38423         val_conv.is_owned = ptr_is_owned(val);
38424         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38425         val_conv = NodeId_clone(&val_conv);
38426         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
38427 }
38428
38429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38430         LDKUnsignedNodeAnnouncement this_ptr_conv;
38431         this_ptr_conv.inner = untag_ptr(this_ptr);
38432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38434         this_ptr_conv.is_owned = false;
38435         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38436         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
38437         return ret_arr;
38438 }
38439
38440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38441         LDKUnsignedNodeAnnouncement this_ptr_conv;
38442         this_ptr_conv.inner = untag_ptr(this_ptr);
38443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38445         this_ptr_conv.is_owned = false;
38446         LDKThreeBytes val_ref;
38447         CHECK((*env)->GetArrayLength(env, val) == 3);
38448         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38449         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
38450 }
38451
38452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
38453         LDKUnsignedNodeAnnouncement this_ptr_conv;
38454         this_ptr_conv.inner = untag_ptr(this_ptr);
38455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38457         this_ptr_conv.is_owned = false;
38458         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
38459         int64_t ret_ref = 0;
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38462         return ret_ref;
38463 }
38464
38465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38466         LDKUnsignedNodeAnnouncement this_ptr_conv;
38467         this_ptr_conv.inner = untag_ptr(this_ptr);
38468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38470         this_ptr_conv.is_owned = false;
38471         LDKNodeAlias val_conv;
38472         val_conv.inner = untag_ptr(val);
38473         val_conv.is_owned = ptr_is_owned(val);
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38475         val_conv = NodeAlias_clone(&val_conv);
38476         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
38477 }
38478
38479 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
38480         LDKUnsignedNodeAnnouncement this_ptr_conv;
38481         this_ptr_conv.inner = untag_ptr(this_ptr);
38482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38484         this_ptr_conv.is_owned = false;
38485         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
38486         int64_tArray ret_arr = NULL;
38487         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38488         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38489         for (size_t m = 0; m < ret_var.datalen; m++) {
38490                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38491                 *ret_conv_12_copy = ret_var.data[m];
38492                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
38493                 ret_arr_ptr[m] = ret_conv_12_ref;
38494         }
38495         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38496         FREE(ret_var.data);
38497         return ret_arr;
38498 }
38499
38500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38501         LDKUnsignedNodeAnnouncement this_ptr_conv;
38502         this_ptr_conv.inner = untag_ptr(this_ptr);
38503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38505         this_ptr_conv.is_owned = false;
38506         LDKCVec_NetAddressZ val_constr;
38507         val_constr.datalen = (*env)->GetArrayLength(env, val);
38508         if (val_constr.datalen > 0)
38509                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38510         else
38511                 val_constr.data = NULL;
38512         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38513         for (size_t m = 0; m < val_constr.datalen; m++) {
38514                 int64_t val_conv_12 = val_vals[m];
38515                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
38516                 CHECK_ACCESS(val_conv_12_ptr);
38517                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38518                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
38519                 val_constr.data[m] = val_conv_12_conv;
38520         }
38521         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38522         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
38523 }
38524
38525 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
38526         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
38527         int64_t ret_ref = 0;
38528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38530         return ret_ref;
38531 }
38532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38533         LDKUnsignedNodeAnnouncement arg_conv;
38534         arg_conv.inner = untag_ptr(arg);
38535         arg_conv.is_owned = ptr_is_owned(arg);
38536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38537         arg_conv.is_owned = false;
38538         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
38539         return ret_conv;
38540 }
38541
38542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38543         LDKUnsignedNodeAnnouncement orig_conv;
38544         orig_conv.inner = untag_ptr(orig);
38545         orig_conv.is_owned = ptr_is_owned(orig);
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38547         orig_conv.is_owned = false;
38548         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
38549         int64_t ret_ref = 0;
38550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38552         return ret_ref;
38553 }
38554
38555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38556         LDKUnsignedNodeAnnouncement a_conv;
38557         a_conv.inner = untag_ptr(a);
38558         a_conv.is_owned = ptr_is_owned(a);
38559         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38560         a_conv.is_owned = false;
38561         LDKUnsignedNodeAnnouncement b_conv;
38562         b_conv.inner = untag_ptr(b);
38563         b_conv.is_owned = ptr_is_owned(b);
38564         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38565         b_conv.is_owned = false;
38566         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
38567         return ret_conv;
38568 }
38569
38570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38571         LDKNodeAnnouncement this_obj_conv;
38572         this_obj_conv.inner = untag_ptr(this_obj);
38573         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38575         NodeAnnouncement_free(this_obj_conv);
38576 }
38577
38578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38579         LDKNodeAnnouncement this_ptr_conv;
38580         this_ptr_conv.inner = untag_ptr(this_ptr);
38581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38583         this_ptr_conv.is_owned = false;
38584         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
38586         return ret_arr;
38587 }
38588
38589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38590         LDKNodeAnnouncement this_ptr_conv;
38591         this_ptr_conv.inner = untag_ptr(this_ptr);
38592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38594         this_ptr_conv.is_owned = false;
38595         LDKSignature val_ref;
38596         CHECK((*env)->GetArrayLength(env, val) == 64);
38597         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38598         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
38599 }
38600
38601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38602         LDKNodeAnnouncement this_ptr_conv;
38603         this_ptr_conv.inner = untag_ptr(this_ptr);
38604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38606         this_ptr_conv.is_owned = false;
38607         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
38608         int64_t ret_ref = 0;
38609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38610         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38611         return ret_ref;
38612 }
38613
38614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38615         LDKNodeAnnouncement this_ptr_conv;
38616         this_ptr_conv.inner = untag_ptr(this_ptr);
38617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38619         this_ptr_conv.is_owned = false;
38620         LDKUnsignedNodeAnnouncement val_conv;
38621         val_conv.inner = untag_ptr(val);
38622         val_conv.is_owned = ptr_is_owned(val);
38623         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38624         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
38625         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
38626 }
38627
38628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38629         LDKSignature signature_arg_ref;
38630         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38631         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38632         LDKUnsignedNodeAnnouncement contents_arg_conv;
38633         contents_arg_conv.inner = untag_ptr(contents_arg);
38634         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38635         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38636         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
38637         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
38638         int64_t ret_ref = 0;
38639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38640         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38641         return ret_ref;
38642 }
38643
38644 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
38645         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
38646         int64_t ret_ref = 0;
38647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38649         return ret_ref;
38650 }
38651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38652         LDKNodeAnnouncement arg_conv;
38653         arg_conv.inner = untag_ptr(arg);
38654         arg_conv.is_owned = ptr_is_owned(arg);
38655         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38656         arg_conv.is_owned = false;
38657         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
38658         return ret_conv;
38659 }
38660
38661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38662         LDKNodeAnnouncement orig_conv;
38663         orig_conv.inner = untag_ptr(orig);
38664         orig_conv.is_owned = ptr_is_owned(orig);
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38666         orig_conv.is_owned = false;
38667         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
38668         int64_t ret_ref = 0;
38669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38671         return ret_ref;
38672 }
38673
38674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38675         LDKNodeAnnouncement a_conv;
38676         a_conv.inner = untag_ptr(a);
38677         a_conv.is_owned = ptr_is_owned(a);
38678         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38679         a_conv.is_owned = false;
38680         LDKNodeAnnouncement b_conv;
38681         b_conv.inner = untag_ptr(b);
38682         b_conv.is_owned = ptr_is_owned(b);
38683         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38684         b_conv.is_owned = false;
38685         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
38686         return ret_conv;
38687 }
38688
38689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38690         LDKUnsignedChannelAnnouncement this_obj_conv;
38691         this_obj_conv.inner = untag_ptr(this_obj);
38692         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38694         UnsignedChannelAnnouncement_free(this_obj_conv);
38695 }
38696
38697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38698         LDKUnsignedChannelAnnouncement this_ptr_conv;
38699         this_ptr_conv.inner = untag_ptr(this_ptr);
38700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38702         this_ptr_conv.is_owned = false;
38703         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
38704         int64_t ret_ref = 0;
38705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38707         return ret_ref;
38708 }
38709
38710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38711         LDKUnsignedChannelAnnouncement this_ptr_conv;
38712         this_ptr_conv.inner = untag_ptr(this_ptr);
38713         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38715         this_ptr_conv.is_owned = false;
38716         LDKChannelFeatures val_conv;
38717         val_conv.inner = untag_ptr(val);
38718         val_conv.is_owned = ptr_is_owned(val);
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38720         val_conv = ChannelFeatures_clone(&val_conv);
38721         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
38722 }
38723
38724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38725         LDKUnsignedChannelAnnouncement this_ptr_conv;
38726         this_ptr_conv.inner = untag_ptr(this_ptr);
38727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38729         this_ptr_conv.is_owned = false;
38730         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38731         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
38732         return ret_arr;
38733 }
38734
38735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38736         LDKUnsignedChannelAnnouncement this_ptr_conv;
38737         this_ptr_conv.inner = untag_ptr(this_ptr);
38738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38740         this_ptr_conv.is_owned = false;
38741         LDKThirtyTwoBytes val_ref;
38742         CHECK((*env)->GetArrayLength(env, val) == 32);
38743         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38744         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
38745 }
38746
38747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38748         LDKUnsignedChannelAnnouncement this_ptr_conv;
38749         this_ptr_conv.inner = untag_ptr(this_ptr);
38750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38752         this_ptr_conv.is_owned = false;
38753         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
38754         return ret_conv;
38755 }
38756
38757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38758         LDKUnsignedChannelAnnouncement this_ptr_conv;
38759         this_ptr_conv.inner = untag_ptr(this_ptr);
38760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38762         this_ptr_conv.is_owned = false;
38763         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
38764 }
38765
38766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38767         LDKUnsignedChannelAnnouncement this_ptr_conv;
38768         this_ptr_conv.inner = untag_ptr(this_ptr);
38769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38771         this_ptr_conv.is_owned = false;
38772         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
38773         int64_t ret_ref = 0;
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38776         return ret_ref;
38777 }
38778
38779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38780         LDKUnsignedChannelAnnouncement this_ptr_conv;
38781         this_ptr_conv.inner = untag_ptr(this_ptr);
38782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38784         this_ptr_conv.is_owned = false;
38785         LDKNodeId val_conv;
38786         val_conv.inner = untag_ptr(val);
38787         val_conv.is_owned = ptr_is_owned(val);
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38789         val_conv = NodeId_clone(&val_conv);
38790         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
38791 }
38792
38793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38794         LDKUnsignedChannelAnnouncement this_ptr_conv;
38795         this_ptr_conv.inner = untag_ptr(this_ptr);
38796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38798         this_ptr_conv.is_owned = false;
38799         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
38800         int64_t ret_ref = 0;
38801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38803         return ret_ref;
38804 }
38805
38806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38807         LDKUnsignedChannelAnnouncement this_ptr_conv;
38808         this_ptr_conv.inner = untag_ptr(this_ptr);
38809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38811         this_ptr_conv.is_owned = false;
38812         LDKNodeId val_conv;
38813         val_conv.inner = untag_ptr(val);
38814         val_conv.is_owned = ptr_is_owned(val);
38815         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38816         val_conv = NodeId_clone(&val_conv);
38817         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
38818 }
38819
38820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38821         LDKUnsignedChannelAnnouncement this_ptr_conv;
38822         this_ptr_conv.inner = untag_ptr(this_ptr);
38823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38825         this_ptr_conv.is_owned = false;
38826         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
38827         int64_t ret_ref = 0;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38830         return ret_ref;
38831 }
38832
38833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38834         LDKUnsignedChannelAnnouncement this_ptr_conv;
38835         this_ptr_conv.inner = untag_ptr(this_ptr);
38836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38838         this_ptr_conv.is_owned = false;
38839         LDKNodeId val_conv;
38840         val_conv.inner = untag_ptr(val);
38841         val_conv.is_owned = ptr_is_owned(val);
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38843         val_conv = NodeId_clone(&val_conv);
38844         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
38845 }
38846
38847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38848         LDKUnsignedChannelAnnouncement this_ptr_conv;
38849         this_ptr_conv.inner = untag_ptr(this_ptr);
38850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38852         this_ptr_conv.is_owned = false;
38853         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
38854         int64_t ret_ref = 0;
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38857         return ret_ref;
38858 }
38859
38860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38861         LDKUnsignedChannelAnnouncement this_ptr_conv;
38862         this_ptr_conv.inner = untag_ptr(this_ptr);
38863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38865         this_ptr_conv.is_owned = false;
38866         LDKNodeId val_conv;
38867         val_conv.inner = untag_ptr(val);
38868         val_conv.is_owned = ptr_is_owned(val);
38869         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38870         val_conv = NodeId_clone(&val_conv);
38871         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
38872 }
38873
38874 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38875         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38876         int64_t ret_ref = 0;
38877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38878         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38879         return ret_ref;
38880 }
38881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38882         LDKUnsignedChannelAnnouncement arg_conv;
38883         arg_conv.inner = untag_ptr(arg);
38884         arg_conv.is_owned = ptr_is_owned(arg);
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38886         arg_conv.is_owned = false;
38887         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38888         return ret_conv;
38889 }
38890
38891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38892         LDKUnsignedChannelAnnouncement orig_conv;
38893         orig_conv.inner = untag_ptr(orig);
38894         orig_conv.is_owned = ptr_is_owned(orig);
38895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38896         orig_conv.is_owned = false;
38897         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38898         int64_t ret_ref = 0;
38899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38901         return ret_ref;
38902 }
38903
38904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38905         LDKUnsignedChannelAnnouncement a_conv;
38906         a_conv.inner = untag_ptr(a);
38907         a_conv.is_owned = ptr_is_owned(a);
38908         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38909         a_conv.is_owned = false;
38910         LDKUnsignedChannelAnnouncement b_conv;
38911         b_conv.inner = untag_ptr(b);
38912         b_conv.is_owned = ptr_is_owned(b);
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38914         b_conv.is_owned = false;
38915         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38916         return ret_conv;
38917 }
38918
38919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38920         LDKChannelAnnouncement this_obj_conv;
38921         this_obj_conv.inner = untag_ptr(this_obj);
38922         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38924         ChannelAnnouncement_free(this_obj_conv);
38925 }
38926
38927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38928         LDKChannelAnnouncement this_ptr_conv;
38929         this_ptr_conv.inner = untag_ptr(this_ptr);
38930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38932         this_ptr_conv.is_owned = false;
38933         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38935         return ret_arr;
38936 }
38937
38938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38939         LDKChannelAnnouncement this_ptr_conv;
38940         this_ptr_conv.inner = untag_ptr(this_ptr);
38941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38943         this_ptr_conv.is_owned = false;
38944         LDKSignature val_ref;
38945         CHECK((*env)->GetArrayLength(env, val) == 64);
38946         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38947         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38948 }
38949
38950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38951         LDKChannelAnnouncement this_ptr_conv;
38952         this_ptr_conv.inner = untag_ptr(this_ptr);
38953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38955         this_ptr_conv.is_owned = false;
38956         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38958         return ret_arr;
38959 }
38960
38961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38962         LDKChannelAnnouncement this_ptr_conv;
38963         this_ptr_conv.inner = untag_ptr(this_ptr);
38964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38966         this_ptr_conv.is_owned = false;
38967         LDKSignature val_ref;
38968         CHECK((*env)->GetArrayLength(env, val) == 64);
38969         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38970         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38971 }
38972
38973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38974         LDKChannelAnnouncement this_ptr_conv;
38975         this_ptr_conv.inner = untag_ptr(this_ptr);
38976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38978         this_ptr_conv.is_owned = false;
38979         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38981         return ret_arr;
38982 }
38983
38984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38985         LDKChannelAnnouncement this_ptr_conv;
38986         this_ptr_conv.inner = untag_ptr(this_ptr);
38987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38989         this_ptr_conv.is_owned = false;
38990         LDKSignature val_ref;
38991         CHECK((*env)->GetArrayLength(env, val) == 64);
38992         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38993         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
38994 }
38995
38996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38997         LDKChannelAnnouncement this_ptr_conv;
38998         this_ptr_conv.inner = untag_ptr(this_ptr);
38999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39001         this_ptr_conv.is_owned = false;
39002         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
39004         return ret_arr;
39005 }
39006
39007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39008         LDKChannelAnnouncement this_ptr_conv;
39009         this_ptr_conv.inner = untag_ptr(this_ptr);
39010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39012         this_ptr_conv.is_owned = false;
39013         LDKSignature val_ref;
39014         CHECK((*env)->GetArrayLength(env, val) == 64);
39015         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39016         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
39017 }
39018
39019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39020         LDKChannelAnnouncement this_ptr_conv;
39021         this_ptr_conv.inner = untag_ptr(this_ptr);
39022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39024         this_ptr_conv.is_owned = false;
39025         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
39026         int64_t ret_ref = 0;
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39029         return ret_ref;
39030 }
39031
39032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39033         LDKChannelAnnouncement this_ptr_conv;
39034         this_ptr_conv.inner = untag_ptr(this_ptr);
39035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39037         this_ptr_conv.is_owned = false;
39038         LDKUnsignedChannelAnnouncement val_conv;
39039         val_conv.inner = untag_ptr(val);
39040         val_conv.is_owned = ptr_is_owned(val);
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39042         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
39043         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
39044 }
39045
39046 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) {
39047         LDKSignature node_signature_1_arg_ref;
39048         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
39049         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
39050         LDKSignature node_signature_2_arg_ref;
39051         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
39052         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
39053         LDKSignature bitcoin_signature_1_arg_ref;
39054         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
39055         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
39056         LDKSignature bitcoin_signature_2_arg_ref;
39057         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
39058         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
39059         LDKUnsignedChannelAnnouncement contents_arg_conv;
39060         contents_arg_conv.inner = untag_ptr(contents_arg);
39061         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39062         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39063         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
39064         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);
39065         int64_t ret_ref = 0;
39066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39068         return ret_ref;
39069 }
39070
39071 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
39072         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
39073         int64_t ret_ref = 0;
39074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39076         return ret_ref;
39077 }
39078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39079         LDKChannelAnnouncement arg_conv;
39080         arg_conv.inner = untag_ptr(arg);
39081         arg_conv.is_owned = ptr_is_owned(arg);
39082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39083         arg_conv.is_owned = false;
39084         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
39085         return ret_conv;
39086 }
39087
39088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39089         LDKChannelAnnouncement orig_conv;
39090         orig_conv.inner = untag_ptr(orig);
39091         orig_conv.is_owned = ptr_is_owned(orig);
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39093         orig_conv.is_owned = false;
39094         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
39095         int64_t ret_ref = 0;
39096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39098         return ret_ref;
39099 }
39100
39101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39102         LDKChannelAnnouncement a_conv;
39103         a_conv.inner = untag_ptr(a);
39104         a_conv.is_owned = ptr_is_owned(a);
39105         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39106         a_conv.is_owned = false;
39107         LDKChannelAnnouncement b_conv;
39108         b_conv.inner = untag_ptr(b);
39109         b_conv.is_owned = ptr_is_owned(b);
39110         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39111         b_conv.is_owned = false;
39112         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
39113         return ret_conv;
39114 }
39115
39116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39117         LDKUnsignedChannelUpdate this_obj_conv;
39118         this_obj_conv.inner = untag_ptr(this_obj);
39119         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39121         UnsignedChannelUpdate_free(this_obj_conv);
39122 }
39123
39124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39125         LDKUnsignedChannelUpdate this_ptr_conv;
39126         this_ptr_conv.inner = untag_ptr(this_ptr);
39127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39129         this_ptr_conv.is_owned = false;
39130         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39131         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
39132         return ret_arr;
39133 }
39134
39135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39136         LDKUnsignedChannelUpdate this_ptr_conv;
39137         this_ptr_conv.inner = untag_ptr(this_ptr);
39138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39140         this_ptr_conv.is_owned = false;
39141         LDKThirtyTwoBytes val_ref;
39142         CHECK((*env)->GetArrayLength(env, val) == 32);
39143         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39144         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
39145 }
39146
39147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39148         LDKUnsignedChannelUpdate this_ptr_conv;
39149         this_ptr_conv.inner = untag_ptr(this_ptr);
39150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39152         this_ptr_conv.is_owned = false;
39153         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
39154         return ret_conv;
39155 }
39156
39157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39158         LDKUnsignedChannelUpdate this_ptr_conv;
39159         this_ptr_conv.inner = untag_ptr(this_ptr);
39160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39162         this_ptr_conv.is_owned = false;
39163         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
39164 }
39165
39166 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39167         LDKUnsignedChannelUpdate this_ptr_conv;
39168         this_ptr_conv.inner = untag_ptr(this_ptr);
39169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39171         this_ptr_conv.is_owned = false;
39172         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
39173         return ret_conv;
39174 }
39175
39176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39177         LDKUnsignedChannelUpdate this_ptr_conv;
39178         this_ptr_conv.inner = untag_ptr(this_ptr);
39179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39181         this_ptr_conv.is_owned = false;
39182         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
39183 }
39184
39185 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
39186         LDKUnsignedChannelUpdate this_ptr_conv;
39187         this_ptr_conv.inner = untag_ptr(this_ptr);
39188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39190         this_ptr_conv.is_owned = false;
39191         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
39192         return ret_conv;
39193 }
39194
39195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
39196         LDKUnsignedChannelUpdate this_ptr_conv;
39197         this_ptr_conv.inner = untag_ptr(this_ptr);
39198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39200         this_ptr_conv.is_owned = false;
39201         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
39202 }
39203
39204 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39205         LDKUnsignedChannelUpdate this_ptr_conv;
39206         this_ptr_conv.inner = untag_ptr(this_ptr);
39207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39209         this_ptr_conv.is_owned = false;
39210         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
39211         return ret_conv;
39212 }
39213
39214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39215         LDKUnsignedChannelUpdate this_ptr_conv;
39216         this_ptr_conv.inner = untag_ptr(this_ptr);
39217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39219         this_ptr_conv.is_owned = false;
39220         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
39221 }
39222
39223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39224         LDKUnsignedChannelUpdate this_ptr_conv;
39225         this_ptr_conv.inner = untag_ptr(this_ptr);
39226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39228         this_ptr_conv.is_owned = false;
39229         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
39230         return ret_conv;
39231 }
39232
39233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39234         LDKUnsignedChannelUpdate this_ptr_conv;
39235         this_ptr_conv.inner = untag_ptr(this_ptr);
39236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39238         this_ptr_conv.is_owned = false;
39239         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
39240 }
39241
39242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39243         LDKUnsignedChannelUpdate this_ptr_conv;
39244         this_ptr_conv.inner = untag_ptr(this_ptr);
39245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39247         this_ptr_conv.is_owned = false;
39248         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
39249         return ret_conv;
39250 }
39251
39252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39253         LDKUnsignedChannelUpdate this_ptr_conv;
39254         this_ptr_conv.inner = untag_ptr(this_ptr);
39255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39257         this_ptr_conv.is_owned = false;
39258         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
39259 }
39260
39261 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39262         LDKUnsignedChannelUpdate this_ptr_conv;
39263         this_ptr_conv.inner = untag_ptr(this_ptr);
39264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39266         this_ptr_conv.is_owned = false;
39267         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
39268         return ret_conv;
39269 }
39270
39271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39272         LDKUnsignedChannelUpdate this_ptr_conv;
39273         this_ptr_conv.inner = untag_ptr(this_ptr);
39274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39276         this_ptr_conv.is_owned = false;
39277         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
39278 }
39279
39280 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39281         LDKUnsignedChannelUpdate this_ptr_conv;
39282         this_ptr_conv.inner = untag_ptr(this_ptr);
39283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39285         this_ptr_conv.is_owned = false;
39286         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
39287         return ret_conv;
39288 }
39289
39290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39291         LDKUnsignedChannelUpdate this_ptr_conv;
39292         this_ptr_conv.inner = untag_ptr(this_ptr);
39293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39295         this_ptr_conv.is_owned = false;
39296         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
39297 }
39298
39299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39300         LDKUnsignedChannelUpdate this_ptr_conv;
39301         this_ptr_conv.inner = untag_ptr(this_ptr);
39302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39304         this_ptr_conv.is_owned = false;
39305         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
39306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39308         CVec_u8Z_free(ret_var);
39309         return ret_arr;
39310 }
39311
39312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39313         LDKUnsignedChannelUpdate this_ptr_conv;
39314         this_ptr_conv.inner = untag_ptr(this_ptr);
39315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39317         this_ptr_conv.is_owned = false;
39318         LDKCVec_u8Z val_ref;
39319         val_ref.datalen = (*env)->GetArrayLength(env, val);
39320         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39321         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39322         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
39323 }
39324
39325 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) {
39326         LDKThirtyTwoBytes chain_hash_arg_ref;
39327         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39328         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39329         LDKCVec_u8Z excess_data_arg_ref;
39330         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
39331         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39332         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
39333         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);
39334         int64_t ret_ref = 0;
39335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39336         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39337         return ret_ref;
39338 }
39339
39340 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
39341         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
39342         int64_t ret_ref = 0;
39343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39345         return ret_ref;
39346 }
39347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39348         LDKUnsignedChannelUpdate arg_conv;
39349         arg_conv.inner = untag_ptr(arg);
39350         arg_conv.is_owned = ptr_is_owned(arg);
39351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39352         arg_conv.is_owned = false;
39353         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
39354         return ret_conv;
39355 }
39356
39357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39358         LDKUnsignedChannelUpdate orig_conv;
39359         orig_conv.inner = untag_ptr(orig);
39360         orig_conv.is_owned = ptr_is_owned(orig);
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39362         orig_conv.is_owned = false;
39363         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
39364         int64_t ret_ref = 0;
39365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39367         return ret_ref;
39368 }
39369
39370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39371         LDKUnsignedChannelUpdate a_conv;
39372         a_conv.inner = untag_ptr(a);
39373         a_conv.is_owned = ptr_is_owned(a);
39374         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39375         a_conv.is_owned = false;
39376         LDKUnsignedChannelUpdate b_conv;
39377         b_conv.inner = untag_ptr(b);
39378         b_conv.is_owned = ptr_is_owned(b);
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39380         b_conv.is_owned = false;
39381         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
39382         return ret_conv;
39383 }
39384
39385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39386         LDKChannelUpdate this_obj_conv;
39387         this_obj_conv.inner = untag_ptr(this_obj);
39388         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39390         ChannelUpdate_free(this_obj_conv);
39391 }
39392
39393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
39394         LDKChannelUpdate this_ptr_conv;
39395         this_ptr_conv.inner = untag_ptr(this_ptr);
39396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39398         this_ptr_conv.is_owned = false;
39399         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
39401         return ret_arr;
39402 }
39403
39404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39405         LDKChannelUpdate this_ptr_conv;
39406         this_ptr_conv.inner = untag_ptr(this_ptr);
39407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39409         this_ptr_conv.is_owned = false;
39410         LDKSignature val_ref;
39411         CHECK((*env)->GetArrayLength(env, val) == 64);
39412         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39413         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
39414 }
39415
39416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39417         LDKChannelUpdate this_ptr_conv;
39418         this_ptr_conv.inner = untag_ptr(this_ptr);
39419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39421         this_ptr_conv.is_owned = false;
39422         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
39423         int64_t ret_ref = 0;
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39426         return ret_ref;
39427 }
39428
39429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39430         LDKChannelUpdate this_ptr_conv;
39431         this_ptr_conv.inner = untag_ptr(this_ptr);
39432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39434         this_ptr_conv.is_owned = false;
39435         LDKUnsignedChannelUpdate val_conv;
39436         val_conv.inner = untag_ptr(val);
39437         val_conv.is_owned = ptr_is_owned(val);
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39439         val_conv = UnsignedChannelUpdate_clone(&val_conv);
39440         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
39441 }
39442
39443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
39444         LDKSignature signature_arg_ref;
39445         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
39446         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
39447         LDKUnsignedChannelUpdate contents_arg_conv;
39448         contents_arg_conv.inner = untag_ptr(contents_arg);
39449         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39450         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39451         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
39452         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
39453         int64_t ret_ref = 0;
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39456         return ret_ref;
39457 }
39458
39459 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
39460         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
39461         int64_t ret_ref = 0;
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39464         return ret_ref;
39465 }
39466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39467         LDKChannelUpdate arg_conv;
39468         arg_conv.inner = untag_ptr(arg);
39469         arg_conv.is_owned = ptr_is_owned(arg);
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39471         arg_conv.is_owned = false;
39472         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
39473         return ret_conv;
39474 }
39475
39476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39477         LDKChannelUpdate orig_conv;
39478         orig_conv.inner = untag_ptr(orig);
39479         orig_conv.is_owned = ptr_is_owned(orig);
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39481         orig_conv.is_owned = false;
39482         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
39483         int64_t ret_ref = 0;
39484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39486         return ret_ref;
39487 }
39488
39489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39490         LDKChannelUpdate a_conv;
39491         a_conv.inner = untag_ptr(a);
39492         a_conv.is_owned = ptr_is_owned(a);
39493         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39494         a_conv.is_owned = false;
39495         LDKChannelUpdate b_conv;
39496         b_conv.inner = untag_ptr(b);
39497         b_conv.is_owned = ptr_is_owned(b);
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39499         b_conv.is_owned = false;
39500         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
39501         return ret_conv;
39502 }
39503
39504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39505         LDKQueryChannelRange this_obj_conv;
39506         this_obj_conv.inner = untag_ptr(this_obj);
39507         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39509         QueryChannelRange_free(this_obj_conv);
39510 }
39511
39512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39513         LDKQueryChannelRange this_ptr_conv;
39514         this_ptr_conv.inner = untag_ptr(this_ptr);
39515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39517         this_ptr_conv.is_owned = false;
39518         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
39520         return ret_arr;
39521 }
39522
39523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39524         LDKQueryChannelRange this_ptr_conv;
39525         this_ptr_conv.inner = untag_ptr(this_ptr);
39526         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39528         this_ptr_conv.is_owned = false;
39529         LDKThirtyTwoBytes val_ref;
39530         CHECK((*env)->GetArrayLength(env, val) == 32);
39531         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39532         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39533 }
39534
39535 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39536         LDKQueryChannelRange this_ptr_conv;
39537         this_ptr_conv.inner = untag_ptr(this_ptr);
39538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39540         this_ptr_conv.is_owned = false;
39541         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
39542         return ret_conv;
39543 }
39544
39545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39546         LDKQueryChannelRange this_ptr_conv;
39547         this_ptr_conv.inner = untag_ptr(this_ptr);
39548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39550         this_ptr_conv.is_owned = false;
39551         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
39552 }
39553
39554 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39555         LDKQueryChannelRange this_ptr_conv;
39556         this_ptr_conv.inner = untag_ptr(this_ptr);
39557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39559         this_ptr_conv.is_owned = false;
39560         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
39561         return ret_conv;
39562 }
39563
39564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39565         LDKQueryChannelRange this_ptr_conv;
39566         this_ptr_conv.inner = untag_ptr(this_ptr);
39567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39569         this_ptr_conv.is_owned = false;
39570         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39571 }
39572
39573 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) {
39574         LDKThirtyTwoBytes chain_hash_arg_ref;
39575         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39576         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39577         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
39578         int64_t ret_ref = 0;
39579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39580         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39581         return ret_ref;
39582 }
39583
39584 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
39585         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
39586         int64_t ret_ref = 0;
39587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39589         return ret_ref;
39590 }
39591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39592         LDKQueryChannelRange arg_conv;
39593         arg_conv.inner = untag_ptr(arg);
39594         arg_conv.is_owned = ptr_is_owned(arg);
39595         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39596         arg_conv.is_owned = false;
39597         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
39598         return ret_conv;
39599 }
39600
39601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39602         LDKQueryChannelRange orig_conv;
39603         orig_conv.inner = untag_ptr(orig);
39604         orig_conv.is_owned = ptr_is_owned(orig);
39605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39606         orig_conv.is_owned = false;
39607         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
39608         int64_t ret_ref = 0;
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39610         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39611         return ret_ref;
39612 }
39613
39614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39615         LDKQueryChannelRange a_conv;
39616         a_conv.inner = untag_ptr(a);
39617         a_conv.is_owned = ptr_is_owned(a);
39618         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39619         a_conv.is_owned = false;
39620         LDKQueryChannelRange b_conv;
39621         b_conv.inner = untag_ptr(b);
39622         b_conv.is_owned = ptr_is_owned(b);
39623         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39624         b_conv.is_owned = false;
39625         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
39626         return ret_conv;
39627 }
39628
39629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39630         LDKReplyChannelRange this_obj_conv;
39631         this_obj_conv.inner = untag_ptr(this_obj);
39632         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39634         ReplyChannelRange_free(this_obj_conv);
39635 }
39636
39637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39638         LDKReplyChannelRange this_ptr_conv;
39639         this_ptr_conv.inner = untag_ptr(this_ptr);
39640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39642         this_ptr_conv.is_owned = false;
39643         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39644         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
39645         return ret_arr;
39646 }
39647
39648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39649         LDKReplyChannelRange this_ptr_conv;
39650         this_ptr_conv.inner = untag_ptr(this_ptr);
39651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39653         this_ptr_conv.is_owned = false;
39654         LDKThirtyTwoBytes val_ref;
39655         CHECK((*env)->GetArrayLength(env, val) == 32);
39656         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39657         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39658 }
39659
39660 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39661         LDKReplyChannelRange this_ptr_conv;
39662         this_ptr_conv.inner = untag_ptr(this_ptr);
39663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39665         this_ptr_conv.is_owned = false;
39666         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
39667         return ret_conv;
39668 }
39669
39670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39671         LDKReplyChannelRange this_ptr_conv;
39672         this_ptr_conv.inner = untag_ptr(this_ptr);
39673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39675         this_ptr_conv.is_owned = false;
39676         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
39677 }
39678
39679 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39680         LDKReplyChannelRange this_ptr_conv;
39681         this_ptr_conv.inner = untag_ptr(this_ptr);
39682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39684         this_ptr_conv.is_owned = false;
39685         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
39686         return ret_conv;
39687 }
39688
39689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39690         LDKReplyChannelRange this_ptr_conv;
39691         this_ptr_conv.inner = untag_ptr(this_ptr);
39692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39694         this_ptr_conv.is_owned = false;
39695         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39696 }
39697
39698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
39699         LDKReplyChannelRange this_ptr_conv;
39700         this_ptr_conv.inner = untag_ptr(this_ptr);
39701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39703         this_ptr_conv.is_owned = false;
39704         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
39705         return ret_conv;
39706 }
39707
39708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39709         LDKReplyChannelRange this_ptr_conv;
39710         this_ptr_conv.inner = untag_ptr(this_ptr);
39711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39713         this_ptr_conv.is_owned = false;
39714         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
39715 }
39716
39717 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39718         LDKReplyChannelRange this_ptr_conv;
39719         this_ptr_conv.inner = untag_ptr(this_ptr);
39720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39722         this_ptr_conv.is_owned = false;
39723         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
39724         int64_tArray ret_arr = NULL;
39725         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39726         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39727         for (size_t g = 0; g < ret_var.datalen; g++) {
39728                 int64_t ret_conv_6_conv = ret_var.data[g];
39729                 ret_arr_ptr[g] = ret_conv_6_conv;
39730         }
39731         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39732         FREE(ret_var.data);
39733         return ret_arr;
39734 }
39735
39736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39737         LDKReplyChannelRange this_ptr_conv;
39738         this_ptr_conv.inner = untag_ptr(this_ptr);
39739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39741         this_ptr_conv.is_owned = false;
39742         LDKCVec_u64Z val_constr;
39743         val_constr.datalen = (*env)->GetArrayLength(env, val);
39744         if (val_constr.datalen > 0)
39745                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39746         else
39747                 val_constr.data = NULL;
39748         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39749         for (size_t g = 0; g < val_constr.datalen; g++) {
39750                 int64_t val_conv_6 = val_vals[g];
39751                 val_constr.data[g] = val_conv_6;
39752         }
39753         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39754         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
39755 }
39756
39757 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) {
39758         LDKThirtyTwoBytes chain_hash_arg_ref;
39759         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39760         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39761         LDKCVec_u64Z short_channel_ids_arg_constr;
39762         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39763         if (short_channel_ids_arg_constr.datalen > 0)
39764                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39765         else
39766                 short_channel_ids_arg_constr.data = NULL;
39767         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39768         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39769                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39770                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39771         }
39772         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39773         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
39774         int64_t ret_ref = 0;
39775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39777         return ret_ref;
39778 }
39779
39780 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
39781         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
39782         int64_t ret_ref = 0;
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39785         return ret_ref;
39786 }
39787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39788         LDKReplyChannelRange arg_conv;
39789         arg_conv.inner = untag_ptr(arg);
39790         arg_conv.is_owned = ptr_is_owned(arg);
39791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39792         arg_conv.is_owned = false;
39793         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
39794         return ret_conv;
39795 }
39796
39797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39798         LDKReplyChannelRange orig_conv;
39799         orig_conv.inner = untag_ptr(orig);
39800         orig_conv.is_owned = ptr_is_owned(orig);
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39802         orig_conv.is_owned = false;
39803         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
39804         int64_t ret_ref = 0;
39805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39807         return ret_ref;
39808 }
39809
39810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39811         LDKReplyChannelRange a_conv;
39812         a_conv.inner = untag_ptr(a);
39813         a_conv.is_owned = ptr_is_owned(a);
39814         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39815         a_conv.is_owned = false;
39816         LDKReplyChannelRange b_conv;
39817         b_conv.inner = untag_ptr(b);
39818         b_conv.is_owned = ptr_is_owned(b);
39819         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39820         b_conv.is_owned = false;
39821         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
39822         return ret_conv;
39823 }
39824
39825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39826         LDKQueryShortChannelIds this_obj_conv;
39827         this_obj_conv.inner = untag_ptr(this_obj);
39828         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39830         QueryShortChannelIds_free(this_obj_conv);
39831 }
39832
39833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39834         LDKQueryShortChannelIds this_ptr_conv;
39835         this_ptr_conv.inner = untag_ptr(this_ptr);
39836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39838         this_ptr_conv.is_owned = false;
39839         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39840         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39841         return ret_arr;
39842 }
39843
39844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39845         LDKQueryShortChannelIds this_ptr_conv;
39846         this_ptr_conv.inner = untag_ptr(this_ptr);
39847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39849         this_ptr_conv.is_owned = false;
39850         LDKThirtyTwoBytes val_ref;
39851         CHECK((*env)->GetArrayLength(env, val) == 32);
39852         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39853         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39854 }
39855
39856 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39857         LDKQueryShortChannelIds this_ptr_conv;
39858         this_ptr_conv.inner = untag_ptr(this_ptr);
39859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39861         this_ptr_conv.is_owned = false;
39862         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39863         int64_tArray ret_arr = NULL;
39864         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39865         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39866         for (size_t g = 0; g < ret_var.datalen; g++) {
39867                 int64_t ret_conv_6_conv = ret_var.data[g];
39868                 ret_arr_ptr[g] = ret_conv_6_conv;
39869         }
39870         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39871         FREE(ret_var.data);
39872         return ret_arr;
39873 }
39874
39875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39876         LDKQueryShortChannelIds this_ptr_conv;
39877         this_ptr_conv.inner = untag_ptr(this_ptr);
39878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39880         this_ptr_conv.is_owned = false;
39881         LDKCVec_u64Z val_constr;
39882         val_constr.datalen = (*env)->GetArrayLength(env, val);
39883         if (val_constr.datalen > 0)
39884                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39885         else
39886                 val_constr.data = NULL;
39887         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39888         for (size_t g = 0; g < val_constr.datalen; g++) {
39889                 int64_t val_conv_6 = val_vals[g];
39890                 val_constr.data[g] = val_conv_6;
39891         }
39892         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39893         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39894 }
39895
39896 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) {
39897         LDKThirtyTwoBytes chain_hash_arg_ref;
39898         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39899         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39900         LDKCVec_u64Z short_channel_ids_arg_constr;
39901         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39902         if (short_channel_ids_arg_constr.datalen > 0)
39903                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39904         else
39905                 short_channel_ids_arg_constr.data = NULL;
39906         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39907         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39908                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39909                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39910         }
39911         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39912         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39913         int64_t ret_ref = 0;
39914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39916         return ret_ref;
39917 }
39918
39919 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39920         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39921         int64_t ret_ref = 0;
39922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39924         return ret_ref;
39925 }
39926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39927         LDKQueryShortChannelIds arg_conv;
39928         arg_conv.inner = untag_ptr(arg);
39929         arg_conv.is_owned = ptr_is_owned(arg);
39930         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39931         arg_conv.is_owned = false;
39932         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39933         return ret_conv;
39934 }
39935
39936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39937         LDKQueryShortChannelIds orig_conv;
39938         orig_conv.inner = untag_ptr(orig);
39939         orig_conv.is_owned = ptr_is_owned(orig);
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39941         orig_conv.is_owned = false;
39942         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39943         int64_t ret_ref = 0;
39944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39945         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39946         return ret_ref;
39947 }
39948
39949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39950         LDKQueryShortChannelIds a_conv;
39951         a_conv.inner = untag_ptr(a);
39952         a_conv.is_owned = ptr_is_owned(a);
39953         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39954         a_conv.is_owned = false;
39955         LDKQueryShortChannelIds b_conv;
39956         b_conv.inner = untag_ptr(b);
39957         b_conv.is_owned = ptr_is_owned(b);
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39959         b_conv.is_owned = false;
39960         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39961         return ret_conv;
39962 }
39963
39964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39965         LDKReplyShortChannelIdsEnd this_obj_conv;
39966         this_obj_conv.inner = untag_ptr(this_obj);
39967         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39969         ReplyShortChannelIdsEnd_free(this_obj_conv);
39970 }
39971
39972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39973         LDKReplyShortChannelIdsEnd this_ptr_conv;
39974         this_ptr_conv.inner = untag_ptr(this_ptr);
39975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39977         this_ptr_conv.is_owned = false;
39978         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39979         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39980         return ret_arr;
39981 }
39982
39983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39984         LDKReplyShortChannelIdsEnd this_ptr_conv;
39985         this_ptr_conv.inner = untag_ptr(this_ptr);
39986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39988         this_ptr_conv.is_owned = false;
39989         LDKThirtyTwoBytes val_ref;
39990         CHECK((*env)->GetArrayLength(env, val) == 32);
39991         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39992         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
39993 }
39994
39995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
39996         LDKReplyShortChannelIdsEnd this_ptr_conv;
39997         this_ptr_conv.inner = untag_ptr(this_ptr);
39998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40000         this_ptr_conv.is_owned = false;
40001         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
40002         return ret_conv;
40003 }
40004
40005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40006         LDKReplyShortChannelIdsEnd this_ptr_conv;
40007         this_ptr_conv.inner = untag_ptr(this_ptr);
40008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40010         this_ptr_conv.is_owned = false;
40011         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
40012 }
40013
40014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
40015         LDKThirtyTwoBytes chain_hash_arg_ref;
40016         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40017         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40018         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
40019         int64_t ret_ref = 0;
40020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40022         return ret_ref;
40023 }
40024
40025 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
40026         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
40027         int64_t ret_ref = 0;
40028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40030         return ret_ref;
40031 }
40032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40033         LDKReplyShortChannelIdsEnd arg_conv;
40034         arg_conv.inner = untag_ptr(arg);
40035         arg_conv.is_owned = ptr_is_owned(arg);
40036         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40037         arg_conv.is_owned = false;
40038         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
40039         return ret_conv;
40040 }
40041
40042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40043         LDKReplyShortChannelIdsEnd orig_conv;
40044         orig_conv.inner = untag_ptr(orig);
40045         orig_conv.is_owned = ptr_is_owned(orig);
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40047         orig_conv.is_owned = false;
40048         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
40049         int64_t ret_ref = 0;
40050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40052         return ret_ref;
40053 }
40054
40055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40056         LDKReplyShortChannelIdsEnd a_conv;
40057         a_conv.inner = untag_ptr(a);
40058         a_conv.is_owned = ptr_is_owned(a);
40059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40060         a_conv.is_owned = false;
40061         LDKReplyShortChannelIdsEnd b_conv;
40062         b_conv.inner = untag_ptr(b);
40063         b_conv.is_owned = ptr_is_owned(b);
40064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40065         b_conv.is_owned = false;
40066         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
40067         return ret_conv;
40068 }
40069
40070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40071         LDKGossipTimestampFilter this_obj_conv;
40072         this_obj_conv.inner = untag_ptr(this_obj);
40073         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40075         GossipTimestampFilter_free(this_obj_conv);
40076 }
40077
40078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
40079         LDKGossipTimestampFilter this_ptr_conv;
40080         this_ptr_conv.inner = untag_ptr(this_ptr);
40081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40083         this_ptr_conv.is_owned = false;
40084         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
40086         return ret_arr;
40087 }
40088
40089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40090         LDKGossipTimestampFilter this_ptr_conv;
40091         this_ptr_conv.inner = untag_ptr(this_ptr);
40092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40094         this_ptr_conv.is_owned = false;
40095         LDKThirtyTwoBytes val_ref;
40096         CHECK((*env)->GetArrayLength(env, val) == 32);
40097         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40098         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
40099 }
40100
40101 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40102         LDKGossipTimestampFilter this_ptr_conv;
40103         this_ptr_conv.inner = untag_ptr(this_ptr);
40104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40106         this_ptr_conv.is_owned = false;
40107         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
40108         return ret_conv;
40109 }
40110
40111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40112         LDKGossipTimestampFilter this_ptr_conv;
40113         this_ptr_conv.inner = untag_ptr(this_ptr);
40114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40116         this_ptr_conv.is_owned = false;
40117         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
40118 }
40119
40120 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
40121         LDKGossipTimestampFilter this_ptr_conv;
40122         this_ptr_conv.inner = untag_ptr(this_ptr);
40123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40125         this_ptr_conv.is_owned = false;
40126         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
40127         return ret_conv;
40128 }
40129
40130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40131         LDKGossipTimestampFilter this_ptr_conv;
40132         this_ptr_conv.inner = untag_ptr(this_ptr);
40133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40135         this_ptr_conv.is_owned = false;
40136         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
40137 }
40138
40139 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) {
40140         LDKThirtyTwoBytes chain_hash_arg_ref;
40141         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40142         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40143         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
40144         int64_t ret_ref = 0;
40145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40147         return ret_ref;
40148 }
40149
40150 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
40151         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
40152         int64_t ret_ref = 0;
40153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40155         return ret_ref;
40156 }
40157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40158         LDKGossipTimestampFilter arg_conv;
40159         arg_conv.inner = untag_ptr(arg);
40160         arg_conv.is_owned = ptr_is_owned(arg);
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40162         arg_conv.is_owned = false;
40163         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
40164         return ret_conv;
40165 }
40166
40167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40168         LDKGossipTimestampFilter orig_conv;
40169         orig_conv.inner = untag_ptr(orig);
40170         orig_conv.is_owned = ptr_is_owned(orig);
40171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40172         orig_conv.is_owned = false;
40173         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
40174         int64_t ret_ref = 0;
40175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40177         return ret_ref;
40178 }
40179
40180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40181         LDKGossipTimestampFilter a_conv;
40182         a_conv.inner = untag_ptr(a);
40183         a_conv.is_owned = ptr_is_owned(a);
40184         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40185         a_conv.is_owned = false;
40186         LDKGossipTimestampFilter b_conv;
40187         b_conv.inner = untag_ptr(b);
40188         b_conv.is_owned = ptr_is_owned(b);
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40190         b_conv.is_owned = false;
40191         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
40192         return ret_conv;
40193 }
40194
40195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40196         if (!ptr_is_owned(this_ptr)) return;
40197         void* this_ptr_ptr = untag_ptr(this_ptr);
40198         CHECK_ACCESS(this_ptr_ptr);
40199         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
40200         FREE(untag_ptr(this_ptr));
40201         ErrorAction_free(this_ptr_conv);
40202 }
40203
40204 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
40205         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40206         *ret_copy = ErrorAction_clone(arg);
40207         int64_t ret_ref = tag_ptr(ret_copy, true);
40208         return ret_ref;
40209 }
40210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40211         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
40212         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
40213         return ret_conv;
40214 }
40215
40216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40217         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
40218         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40219         *ret_copy = ErrorAction_clone(orig_conv);
40220         int64_t ret_ref = tag_ptr(ret_copy, true);
40221         return ret_ref;
40222 }
40223
40224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
40225         LDKErrorMessage msg_conv;
40226         msg_conv.inner = untag_ptr(msg);
40227         msg_conv.is_owned = ptr_is_owned(msg);
40228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40229         msg_conv = ErrorMessage_clone(&msg_conv);
40230         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40231         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
40232         int64_t ret_ref = tag_ptr(ret_copy, true);
40233         return ret_ref;
40234 }
40235
40236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
40237         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40238         *ret_copy = ErrorAction_ignore_error();
40239         int64_t ret_ref = tag_ptr(ret_copy, true);
40240         return ret_ref;
40241 }
40242
40243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
40244         LDKLevel a_conv = LDKLevel_from_java(env, a);
40245         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40246         *ret_copy = ErrorAction_ignore_and_log(a_conv);
40247         int64_t ret_ref = tag_ptr(ret_copy, true);
40248         return ret_ref;
40249 }
40250
40251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
40252         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40253         *ret_copy = ErrorAction_ignore_duplicate_gossip();
40254         int64_t ret_ref = tag_ptr(ret_copy, true);
40255         return ret_ref;
40256 }
40257
40258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
40259         LDKErrorMessage msg_conv;
40260         msg_conv.inner = untag_ptr(msg);
40261         msg_conv.is_owned = ptr_is_owned(msg);
40262         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40263         msg_conv = ErrorMessage_clone(&msg_conv);
40264         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40265         *ret_copy = ErrorAction_send_error_message(msg_conv);
40266         int64_t ret_ref = tag_ptr(ret_copy, true);
40267         return ret_ref;
40268 }
40269
40270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
40271         LDKWarningMessage msg_conv;
40272         msg_conv.inner = untag_ptr(msg);
40273         msg_conv.is_owned = ptr_is_owned(msg);
40274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40275         msg_conv = WarningMessage_clone(&msg_conv);
40276         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
40277         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40278         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
40279         int64_t ret_ref = tag_ptr(ret_copy, true);
40280         return ret_ref;
40281 }
40282
40283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40284         LDKLightningError this_obj_conv;
40285         this_obj_conv.inner = untag_ptr(this_obj);
40286         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40288         LightningError_free(this_obj_conv);
40289 }
40290
40291 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
40292         LDKLightningError this_ptr_conv;
40293         this_ptr_conv.inner = untag_ptr(this_ptr);
40294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40296         this_ptr_conv.is_owned = false;
40297         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
40298         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40299         Str_free(ret_str);
40300         return ret_conv;
40301 }
40302
40303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
40304         LDKLightningError this_ptr_conv;
40305         this_ptr_conv.inner = untag_ptr(this_ptr);
40306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40308         this_ptr_conv.is_owned = false;
40309         LDKStr val_conv = java_to_owned_str(env, val);
40310         LightningError_set_err(&this_ptr_conv, val_conv);
40311 }
40312
40313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
40314         LDKLightningError this_ptr_conv;
40315         this_ptr_conv.inner = untag_ptr(this_ptr);
40316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40318         this_ptr_conv.is_owned = false;
40319         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40320         *ret_copy = LightningError_get_action(&this_ptr_conv);
40321         int64_t ret_ref = tag_ptr(ret_copy, true);
40322         return ret_ref;
40323 }
40324
40325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40326         LDKLightningError this_ptr_conv;
40327         this_ptr_conv.inner = untag_ptr(this_ptr);
40328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40330         this_ptr_conv.is_owned = false;
40331         void* val_ptr = untag_ptr(val);
40332         CHECK_ACCESS(val_ptr);
40333         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
40334         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
40335         LightningError_set_action(&this_ptr_conv, val_conv);
40336 }
40337
40338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
40339         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
40340         void* action_arg_ptr = untag_ptr(action_arg);
40341         CHECK_ACCESS(action_arg_ptr);
40342         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
40343         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
40344         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
40345         int64_t ret_ref = 0;
40346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40348         return ret_ref;
40349 }
40350
40351 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
40352         LDKLightningError ret_var = LightningError_clone(arg);
40353         int64_t ret_ref = 0;
40354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40356         return ret_ref;
40357 }
40358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40359         LDKLightningError arg_conv;
40360         arg_conv.inner = untag_ptr(arg);
40361         arg_conv.is_owned = ptr_is_owned(arg);
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40363         arg_conv.is_owned = false;
40364         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
40365         return ret_conv;
40366 }
40367
40368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40369         LDKLightningError orig_conv;
40370         orig_conv.inner = untag_ptr(orig);
40371         orig_conv.is_owned = ptr_is_owned(orig);
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40373         orig_conv.is_owned = false;
40374         LDKLightningError ret_var = LightningError_clone(&orig_conv);
40375         int64_t ret_ref = 0;
40376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40378         return ret_ref;
40379 }
40380
40381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40382         LDKCommitmentUpdate this_obj_conv;
40383         this_obj_conv.inner = untag_ptr(this_obj);
40384         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40386         CommitmentUpdate_free(this_obj_conv);
40387 }
40388
40389 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40390         LDKCommitmentUpdate this_ptr_conv;
40391         this_ptr_conv.inner = untag_ptr(this_ptr);
40392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40394         this_ptr_conv.is_owned = false;
40395         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
40396         int64_tArray ret_arr = NULL;
40397         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40398         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40399         for (size_t p = 0; p < ret_var.datalen; p++) {
40400                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
40401                 int64_t ret_conv_15_ref = 0;
40402                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
40403                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
40404                 ret_arr_ptr[p] = ret_conv_15_ref;
40405         }
40406         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40407         FREE(ret_var.data);
40408         return ret_arr;
40409 }
40410
40411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40412         LDKCommitmentUpdate this_ptr_conv;
40413         this_ptr_conv.inner = untag_ptr(this_ptr);
40414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40416         this_ptr_conv.is_owned = false;
40417         LDKCVec_UpdateAddHTLCZ val_constr;
40418         val_constr.datalen = (*env)->GetArrayLength(env, val);
40419         if (val_constr.datalen > 0)
40420                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40421         else
40422                 val_constr.data = NULL;
40423         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40424         for (size_t p = 0; p < val_constr.datalen; p++) {
40425                 int64_t val_conv_15 = val_vals[p];
40426                 LDKUpdateAddHTLC val_conv_15_conv;
40427                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
40428                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
40429                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
40430                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
40431                 val_constr.data[p] = val_conv_15_conv;
40432         }
40433         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40434         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
40435 }
40436
40437 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40438         LDKCommitmentUpdate this_ptr_conv;
40439         this_ptr_conv.inner = untag_ptr(this_ptr);
40440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40442         this_ptr_conv.is_owned = false;
40443         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
40444         int64_tArray ret_arr = NULL;
40445         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40446         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40447         for (size_t t = 0; t < ret_var.datalen; t++) {
40448                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
40449                 int64_t ret_conv_19_ref = 0;
40450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
40451                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
40452                 ret_arr_ptr[t] = ret_conv_19_ref;
40453         }
40454         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40455         FREE(ret_var.data);
40456         return ret_arr;
40457 }
40458
40459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40460         LDKCommitmentUpdate this_ptr_conv;
40461         this_ptr_conv.inner = untag_ptr(this_ptr);
40462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40464         this_ptr_conv.is_owned = false;
40465         LDKCVec_UpdateFulfillHTLCZ val_constr;
40466         val_constr.datalen = (*env)->GetArrayLength(env, val);
40467         if (val_constr.datalen > 0)
40468                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40469         else
40470                 val_constr.data = NULL;
40471         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40472         for (size_t t = 0; t < val_constr.datalen; t++) {
40473                 int64_t val_conv_19 = val_vals[t];
40474                 LDKUpdateFulfillHTLC val_conv_19_conv;
40475                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
40476                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
40477                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
40478                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
40479                 val_constr.data[t] = val_conv_19_conv;
40480         }
40481         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40482         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
40483 }
40484
40485 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40486         LDKCommitmentUpdate this_ptr_conv;
40487         this_ptr_conv.inner = untag_ptr(this_ptr);
40488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40490         this_ptr_conv.is_owned = false;
40491         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
40492         int64_tArray ret_arr = NULL;
40493         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40494         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40495         for (size_t q = 0; q < ret_var.datalen; q++) {
40496                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
40497                 int64_t ret_conv_16_ref = 0;
40498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
40499                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
40500                 ret_arr_ptr[q] = ret_conv_16_ref;
40501         }
40502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40503         FREE(ret_var.data);
40504         return ret_arr;
40505 }
40506
40507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40508         LDKCommitmentUpdate this_ptr_conv;
40509         this_ptr_conv.inner = untag_ptr(this_ptr);
40510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40512         this_ptr_conv.is_owned = false;
40513         LDKCVec_UpdateFailHTLCZ val_constr;
40514         val_constr.datalen = (*env)->GetArrayLength(env, val);
40515         if (val_constr.datalen > 0)
40516                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40517         else
40518                 val_constr.data = NULL;
40519         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40520         for (size_t q = 0; q < val_constr.datalen; q++) {
40521                 int64_t val_conv_16 = val_vals[q];
40522                 LDKUpdateFailHTLC val_conv_16_conv;
40523                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
40524                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
40525                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
40526                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
40527                 val_constr.data[q] = val_conv_16_conv;
40528         }
40529         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40530         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
40531 }
40532
40533 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40534         LDKCommitmentUpdate this_ptr_conv;
40535         this_ptr_conv.inner = untag_ptr(this_ptr);
40536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40538         this_ptr_conv.is_owned = false;
40539         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
40540         int64_tArray ret_arr = NULL;
40541         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40542         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40543         for (size_t z = 0; z < ret_var.datalen; z++) {
40544                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
40545                 int64_t ret_conv_25_ref = 0;
40546                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
40547                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
40548                 ret_arr_ptr[z] = ret_conv_25_ref;
40549         }
40550         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40551         FREE(ret_var.data);
40552         return ret_arr;
40553 }
40554
40555 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) {
40556         LDKCommitmentUpdate this_ptr_conv;
40557         this_ptr_conv.inner = untag_ptr(this_ptr);
40558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40560         this_ptr_conv.is_owned = false;
40561         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
40562         val_constr.datalen = (*env)->GetArrayLength(env, val);
40563         if (val_constr.datalen > 0)
40564                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40565         else
40566                 val_constr.data = NULL;
40567         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40568         for (size_t z = 0; z < val_constr.datalen; z++) {
40569                 int64_t val_conv_25 = val_vals[z];
40570                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
40571                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
40572                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
40573                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
40574                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
40575                 val_constr.data[z] = val_conv_25_conv;
40576         }
40577         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40578         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
40579 }
40580
40581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
40582         LDKCommitmentUpdate this_ptr_conv;
40583         this_ptr_conv.inner = untag_ptr(this_ptr);
40584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40586         this_ptr_conv.is_owned = false;
40587         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
40588         int64_t ret_ref = 0;
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40591         return ret_ref;
40592 }
40593
40594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40595         LDKCommitmentUpdate this_ptr_conv;
40596         this_ptr_conv.inner = untag_ptr(this_ptr);
40597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40599         this_ptr_conv.is_owned = false;
40600         LDKUpdateFee val_conv;
40601         val_conv.inner = untag_ptr(val);
40602         val_conv.is_owned = ptr_is_owned(val);
40603         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40604         val_conv = UpdateFee_clone(&val_conv);
40605         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
40606 }
40607
40608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
40609         LDKCommitmentUpdate this_ptr_conv;
40610         this_ptr_conv.inner = untag_ptr(this_ptr);
40611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40613         this_ptr_conv.is_owned = false;
40614         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
40615         int64_t ret_ref = 0;
40616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40618         return ret_ref;
40619 }
40620
40621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40622         LDKCommitmentUpdate this_ptr_conv;
40623         this_ptr_conv.inner = untag_ptr(this_ptr);
40624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40626         this_ptr_conv.is_owned = false;
40627         LDKCommitmentSigned val_conv;
40628         val_conv.inner = untag_ptr(val);
40629         val_conv.is_owned = ptr_is_owned(val);
40630         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40631         val_conv = CommitmentSigned_clone(&val_conv);
40632         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
40633 }
40634
40635 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) {
40636         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
40637         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
40638         if (update_add_htlcs_arg_constr.datalen > 0)
40639                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40640         else
40641                 update_add_htlcs_arg_constr.data = NULL;
40642         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
40643         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
40644                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
40645                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
40646                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
40647                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
40648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
40649                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
40650                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
40651         }
40652         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
40653         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
40654         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
40655         if (update_fulfill_htlcs_arg_constr.datalen > 0)
40656                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40657         else
40658                 update_fulfill_htlcs_arg_constr.data = NULL;
40659         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
40660         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
40661                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
40662                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
40663                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
40664                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
40665                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
40666                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
40667                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
40668         }
40669         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
40670         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
40671         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
40672         if (update_fail_htlcs_arg_constr.datalen > 0)
40673                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40674         else
40675                 update_fail_htlcs_arg_constr.data = NULL;
40676         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
40677         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
40678                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
40679                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
40680                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
40681                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
40682                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
40683                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
40684                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
40685         }
40686         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
40687         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
40688         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
40689         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
40690                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40691         else
40692                 update_fail_malformed_htlcs_arg_constr.data = NULL;
40693         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
40694         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
40695                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
40696                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
40697                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
40698                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
40699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
40700                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
40701                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
40702         }
40703         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
40704         LDKUpdateFee update_fee_arg_conv;
40705         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
40706         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
40707         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
40708         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
40709         LDKCommitmentSigned commitment_signed_arg_conv;
40710         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
40711         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
40712         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
40713         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
40714         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);
40715         int64_t ret_ref = 0;
40716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40718         return ret_ref;
40719 }
40720
40721 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
40722         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
40723         int64_t ret_ref = 0;
40724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40726         return ret_ref;
40727 }
40728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40729         LDKCommitmentUpdate arg_conv;
40730         arg_conv.inner = untag_ptr(arg);
40731         arg_conv.is_owned = ptr_is_owned(arg);
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40733         arg_conv.is_owned = false;
40734         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
40735         return ret_conv;
40736 }
40737
40738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40739         LDKCommitmentUpdate orig_conv;
40740         orig_conv.inner = untag_ptr(orig);
40741         orig_conv.is_owned = ptr_is_owned(orig);
40742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40743         orig_conv.is_owned = false;
40744         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
40745         int64_t ret_ref = 0;
40746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40748         return ret_ref;
40749 }
40750
40751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40752         LDKCommitmentUpdate a_conv;
40753         a_conv.inner = untag_ptr(a);
40754         a_conv.is_owned = ptr_is_owned(a);
40755         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40756         a_conv.is_owned = false;
40757         LDKCommitmentUpdate b_conv;
40758         b_conv.inner = untag_ptr(b);
40759         b_conv.is_owned = ptr_is_owned(b);
40760         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40761         b_conv.is_owned = false;
40762         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
40763         return ret_conv;
40764 }
40765
40766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40767         if (!ptr_is_owned(this_ptr)) return;
40768         void* this_ptr_ptr = untag_ptr(this_ptr);
40769         CHECK_ACCESS(this_ptr_ptr);
40770         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
40771         FREE(untag_ptr(this_ptr));
40772         ChannelMessageHandler_free(this_ptr_conv);
40773 }
40774
40775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40776         if (!ptr_is_owned(this_ptr)) return;
40777         void* this_ptr_ptr = untag_ptr(this_ptr);
40778         CHECK_ACCESS(this_ptr_ptr);
40779         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
40780         FREE(untag_ptr(this_ptr));
40781         RoutingMessageHandler_free(this_ptr_conv);
40782 }
40783
40784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40785         if (!ptr_is_owned(this_ptr)) return;
40786         void* this_ptr_ptr = untag_ptr(this_ptr);
40787         CHECK_ACCESS(this_ptr_ptr);
40788         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
40789         FREE(untag_ptr(this_ptr));
40790         OnionMessageHandler_free(this_ptr_conv);
40791 }
40792
40793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40794         LDKAcceptChannel obj_conv;
40795         obj_conv.inner = untag_ptr(obj);
40796         obj_conv.is_owned = ptr_is_owned(obj);
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40798         obj_conv.is_owned = false;
40799         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
40800         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40801         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40802         CVec_u8Z_free(ret_var);
40803         return ret_arr;
40804 }
40805
40806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40807         LDKu8slice ser_ref;
40808         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40809         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40810         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
40811         *ret_conv = AcceptChannel_read(ser_ref);
40812         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40813         return tag_ptr(ret_conv, true);
40814 }
40815
40816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40817         LDKAnnouncementSignatures obj_conv;
40818         obj_conv.inner = untag_ptr(obj);
40819         obj_conv.is_owned = ptr_is_owned(obj);
40820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40821         obj_conv.is_owned = false;
40822         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
40823         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40824         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40825         CVec_u8Z_free(ret_var);
40826         return ret_arr;
40827 }
40828
40829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40830         LDKu8slice ser_ref;
40831         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40832         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40833         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40834         *ret_conv = AnnouncementSignatures_read(ser_ref);
40835         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40836         return tag_ptr(ret_conv, true);
40837 }
40838
40839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40840         LDKChannelReestablish obj_conv;
40841         obj_conv.inner = untag_ptr(obj);
40842         obj_conv.is_owned = ptr_is_owned(obj);
40843         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40844         obj_conv.is_owned = false;
40845         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40848         CVec_u8Z_free(ret_var);
40849         return ret_arr;
40850 }
40851
40852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40853         LDKu8slice ser_ref;
40854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40856         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40857         *ret_conv = ChannelReestablish_read(ser_ref);
40858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40859         return tag_ptr(ret_conv, true);
40860 }
40861
40862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40863         LDKClosingSigned obj_conv;
40864         obj_conv.inner = untag_ptr(obj);
40865         obj_conv.is_owned = ptr_is_owned(obj);
40866         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40867         obj_conv.is_owned = false;
40868         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40871         CVec_u8Z_free(ret_var);
40872         return ret_arr;
40873 }
40874
40875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40876         LDKu8slice ser_ref;
40877         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40878         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40879         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40880         *ret_conv = ClosingSigned_read(ser_ref);
40881         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40882         return tag_ptr(ret_conv, true);
40883 }
40884
40885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40886         LDKClosingSignedFeeRange obj_conv;
40887         obj_conv.inner = untag_ptr(obj);
40888         obj_conv.is_owned = ptr_is_owned(obj);
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40890         obj_conv.is_owned = false;
40891         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40892         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40893         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40894         CVec_u8Z_free(ret_var);
40895         return ret_arr;
40896 }
40897
40898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40899         LDKu8slice ser_ref;
40900         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40901         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40902         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40903         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40905         return tag_ptr(ret_conv, true);
40906 }
40907
40908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40909         LDKCommitmentSigned obj_conv;
40910         obj_conv.inner = untag_ptr(obj);
40911         obj_conv.is_owned = ptr_is_owned(obj);
40912         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40913         obj_conv.is_owned = false;
40914         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40917         CVec_u8Z_free(ret_var);
40918         return ret_arr;
40919 }
40920
40921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40922         LDKu8slice ser_ref;
40923         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40924         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40925         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40926         *ret_conv = CommitmentSigned_read(ser_ref);
40927         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40928         return tag_ptr(ret_conv, true);
40929 }
40930
40931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40932         LDKFundingCreated obj_conv;
40933         obj_conv.inner = untag_ptr(obj);
40934         obj_conv.is_owned = ptr_is_owned(obj);
40935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40936         obj_conv.is_owned = false;
40937         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40938         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40939         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40940         CVec_u8Z_free(ret_var);
40941         return ret_arr;
40942 }
40943
40944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40945         LDKu8slice ser_ref;
40946         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40947         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40948         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40949         *ret_conv = FundingCreated_read(ser_ref);
40950         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40951         return tag_ptr(ret_conv, true);
40952 }
40953
40954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40955         LDKFundingSigned obj_conv;
40956         obj_conv.inner = untag_ptr(obj);
40957         obj_conv.is_owned = ptr_is_owned(obj);
40958         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40959         obj_conv.is_owned = false;
40960         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40963         CVec_u8Z_free(ret_var);
40964         return ret_arr;
40965 }
40966
40967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40968         LDKu8slice ser_ref;
40969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40971         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40972         *ret_conv = FundingSigned_read(ser_ref);
40973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40974         return tag_ptr(ret_conv, true);
40975 }
40976
40977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40978         LDKChannelReady obj_conv;
40979         obj_conv.inner = untag_ptr(obj);
40980         obj_conv.is_owned = ptr_is_owned(obj);
40981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40982         obj_conv.is_owned = false;
40983         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
40984         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40985         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40986         CVec_u8Z_free(ret_var);
40987         return ret_arr;
40988 }
40989
40990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40991         LDKu8slice ser_ref;
40992         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40993         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40994         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
40995         *ret_conv = ChannelReady_read(ser_ref);
40996         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40997         return tag_ptr(ret_conv, true);
40998 }
40999
41000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
41001         LDKInit obj_conv;
41002         obj_conv.inner = untag_ptr(obj);
41003         obj_conv.is_owned = ptr_is_owned(obj);
41004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41005         obj_conv.is_owned = false;
41006         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
41007         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41008         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41009         CVec_u8Z_free(ret_var);
41010         return ret_arr;
41011 }
41012
41013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41014         LDKu8slice ser_ref;
41015         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41016         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41017         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
41018         *ret_conv = Init_read(ser_ref);
41019         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41020         return tag_ptr(ret_conv, true);
41021 }
41022
41023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
41024         LDKOpenChannel obj_conv;
41025         obj_conv.inner = untag_ptr(obj);
41026         obj_conv.is_owned = ptr_is_owned(obj);
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41028         obj_conv.is_owned = false;
41029         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
41030         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41031         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41032         CVec_u8Z_free(ret_var);
41033         return ret_arr;
41034 }
41035
41036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41037         LDKu8slice ser_ref;
41038         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41039         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41040         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
41041         *ret_conv = OpenChannel_read(ser_ref);
41042         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41043         return tag_ptr(ret_conv, true);
41044 }
41045
41046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
41047         LDKRevokeAndACK obj_conv;
41048         obj_conv.inner = untag_ptr(obj);
41049         obj_conv.is_owned = ptr_is_owned(obj);
41050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41051         obj_conv.is_owned = false;
41052         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
41053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41055         CVec_u8Z_free(ret_var);
41056         return ret_arr;
41057 }
41058
41059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41060         LDKu8slice ser_ref;
41061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41063         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
41064         *ret_conv = RevokeAndACK_read(ser_ref);
41065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41066         return tag_ptr(ret_conv, true);
41067 }
41068
41069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
41070         LDKShutdown obj_conv;
41071         obj_conv.inner = untag_ptr(obj);
41072         obj_conv.is_owned = ptr_is_owned(obj);
41073         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41074         obj_conv.is_owned = false;
41075         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
41076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41078         CVec_u8Z_free(ret_var);
41079         return ret_arr;
41080 }
41081
41082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41083         LDKu8slice ser_ref;
41084         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41085         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41086         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
41087         *ret_conv = Shutdown_read(ser_ref);
41088         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41089         return tag_ptr(ret_conv, true);
41090 }
41091
41092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41093         LDKUpdateFailHTLC obj_conv;
41094         obj_conv.inner = untag_ptr(obj);
41095         obj_conv.is_owned = ptr_is_owned(obj);
41096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41097         obj_conv.is_owned = false;
41098         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
41099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41101         CVec_u8Z_free(ret_var);
41102         return ret_arr;
41103 }
41104
41105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41106         LDKu8slice ser_ref;
41107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41109         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
41110         *ret_conv = UpdateFailHTLC_read(ser_ref);
41111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41112         return tag_ptr(ret_conv, true);
41113 }
41114
41115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41116         LDKUpdateFailMalformedHTLC obj_conv;
41117         obj_conv.inner = untag_ptr(obj);
41118         obj_conv.is_owned = ptr_is_owned(obj);
41119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41120         obj_conv.is_owned = false;
41121         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
41122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41124         CVec_u8Z_free(ret_var);
41125         return ret_arr;
41126 }
41127
41128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41129         LDKu8slice ser_ref;
41130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41132         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
41133         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
41134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41135         return tag_ptr(ret_conv, true);
41136 }
41137
41138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
41139         LDKUpdateFee obj_conv;
41140         obj_conv.inner = untag_ptr(obj);
41141         obj_conv.is_owned = ptr_is_owned(obj);
41142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41143         obj_conv.is_owned = false;
41144         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
41145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41147         CVec_u8Z_free(ret_var);
41148         return ret_arr;
41149 }
41150
41151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41152         LDKu8slice ser_ref;
41153         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41154         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41155         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
41156         *ret_conv = UpdateFee_read(ser_ref);
41157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41158         return tag_ptr(ret_conv, true);
41159 }
41160
41161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41162         LDKUpdateFulfillHTLC obj_conv;
41163         obj_conv.inner = untag_ptr(obj);
41164         obj_conv.is_owned = ptr_is_owned(obj);
41165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41166         obj_conv.is_owned = false;
41167         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
41168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41170         CVec_u8Z_free(ret_var);
41171         return ret_arr;
41172 }
41173
41174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41175         LDKu8slice ser_ref;
41176         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41177         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41178         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
41179         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
41180         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41181         return tag_ptr(ret_conv, true);
41182 }
41183
41184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41185         LDKUpdateAddHTLC obj_conv;
41186         obj_conv.inner = untag_ptr(obj);
41187         obj_conv.is_owned = ptr_is_owned(obj);
41188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41189         obj_conv.is_owned = false;
41190         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
41191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41193         CVec_u8Z_free(ret_var);
41194         return ret_arr;
41195 }
41196
41197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41198         LDKu8slice ser_ref;
41199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41201         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
41202         *ret_conv = UpdateAddHTLC_read(ser_ref);
41203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41204         return tag_ptr(ret_conv, true);
41205 }
41206
41207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41208         LDKu8slice ser_ref;
41209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41211         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
41212         *ret_conv = OnionMessage_read(ser_ref);
41213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41214         return tag_ptr(ret_conv, true);
41215 }
41216
41217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41218         LDKOnionMessage obj_conv;
41219         obj_conv.inner = untag_ptr(obj);
41220         obj_conv.is_owned = ptr_is_owned(obj);
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41222         obj_conv.is_owned = false;
41223         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
41224         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41225         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41226         CVec_u8Z_free(ret_var);
41227         return ret_arr;
41228 }
41229
41230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
41231         LDKPing obj_conv;
41232         obj_conv.inner = untag_ptr(obj);
41233         obj_conv.is_owned = ptr_is_owned(obj);
41234         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41235         obj_conv.is_owned = false;
41236         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
41237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41239         CVec_u8Z_free(ret_var);
41240         return ret_arr;
41241 }
41242
41243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41244         LDKu8slice ser_ref;
41245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41247         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
41248         *ret_conv = Ping_read(ser_ref);
41249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41250         return tag_ptr(ret_conv, true);
41251 }
41252
41253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
41254         LDKPong obj_conv;
41255         obj_conv.inner = untag_ptr(obj);
41256         obj_conv.is_owned = ptr_is_owned(obj);
41257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41258         obj_conv.is_owned = false;
41259         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
41260         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41261         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41262         CVec_u8Z_free(ret_var);
41263         return ret_arr;
41264 }
41265
41266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41267         LDKu8slice ser_ref;
41268         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41269         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41270         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
41271         *ret_conv = Pong_read(ser_ref);
41272         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41273         return tag_ptr(ret_conv, true);
41274 }
41275
41276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41277         LDKUnsignedChannelAnnouncement obj_conv;
41278         obj_conv.inner = untag_ptr(obj);
41279         obj_conv.is_owned = ptr_is_owned(obj);
41280         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41281         obj_conv.is_owned = false;
41282         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
41283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41285         CVec_u8Z_free(ret_var);
41286         return ret_arr;
41287 }
41288
41289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41290         LDKu8slice ser_ref;
41291         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41292         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41293         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
41294         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
41295         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41296         return tag_ptr(ret_conv, true);
41297 }
41298
41299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41300         LDKChannelAnnouncement obj_conv;
41301         obj_conv.inner = untag_ptr(obj);
41302         obj_conv.is_owned = ptr_is_owned(obj);
41303         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41304         obj_conv.is_owned = false;
41305         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
41306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41308         CVec_u8Z_free(ret_var);
41309         return ret_arr;
41310 }
41311
41312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41313         LDKu8slice ser_ref;
41314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41316         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
41317         *ret_conv = ChannelAnnouncement_read(ser_ref);
41318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41319         return tag_ptr(ret_conv, true);
41320 }
41321
41322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41323         LDKUnsignedChannelUpdate obj_conv;
41324         obj_conv.inner = untag_ptr(obj);
41325         obj_conv.is_owned = ptr_is_owned(obj);
41326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41327         obj_conv.is_owned = false;
41328         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
41329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41331         CVec_u8Z_free(ret_var);
41332         return ret_arr;
41333 }
41334
41335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41336         LDKu8slice ser_ref;
41337         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41338         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41339         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
41340         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
41341         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41342         return tag_ptr(ret_conv, true);
41343 }
41344
41345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41346         LDKChannelUpdate obj_conv;
41347         obj_conv.inner = untag_ptr(obj);
41348         obj_conv.is_owned = ptr_is_owned(obj);
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41350         obj_conv.is_owned = false;
41351         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
41352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41354         CVec_u8Z_free(ret_var);
41355         return ret_arr;
41356 }
41357
41358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41359         LDKu8slice ser_ref;
41360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41362         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
41363         *ret_conv = ChannelUpdate_read(ser_ref);
41364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41365         return tag_ptr(ret_conv, true);
41366 }
41367
41368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41369         LDKErrorMessage obj_conv;
41370         obj_conv.inner = untag_ptr(obj);
41371         obj_conv.is_owned = ptr_is_owned(obj);
41372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41373         obj_conv.is_owned = false;
41374         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
41375         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41376         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41377         CVec_u8Z_free(ret_var);
41378         return ret_arr;
41379 }
41380
41381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41382         LDKu8slice ser_ref;
41383         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41384         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41385         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
41386         *ret_conv = ErrorMessage_read(ser_ref);
41387         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41388         return tag_ptr(ret_conv, true);
41389 }
41390
41391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41392         LDKWarningMessage obj_conv;
41393         obj_conv.inner = untag_ptr(obj);
41394         obj_conv.is_owned = ptr_is_owned(obj);
41395         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41396         obj_conv.is_owned = false;
41397         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
41398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41400         CVec_u8Z_free(ret_var);
41401         return ret_arr;
41402 }
41403
41404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41405         LDKu8slice ser_ref;
41406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41408         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
41409         *ret_conv = WarningMessage_read(ser_ref);
41410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41411         return tag_ptr(ret_conv, true);
41412 }
41413
41414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41415         LDKUnsignedNodeAnnouncement obj_conv;
41416         obj_conv.inner = untag_ptr(obj);
41417         obj_conv.is_owned = ptr_is_owned(obj);
41418         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41419         obj_conv.is_owned = false;
41420         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
41421         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41422         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41423         CVec_u8Z_free(ret_var);
41424         return ret_arr;
41425 }
41426
41427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41428         LDKu8slice ser_ref;
41429         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41430         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41431         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
41432         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
41433         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41434         return tag_ptr(ret_conv, true);
41435 }
41436
41437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41438         LDKNodeAnnouncement obj_conv;
41439         obj_conv.inner = untag_ptr(obj);
41440         obj_conv.is_owned = ptr_is_owned(obj);
41441         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41442         obj_conv.is_owned = false;
41443         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
41444         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41445         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41446         CVec_u8Z_free(ret_var);
41447         return ret_arr;
41448 }
41449
41450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41451         LDKu8slice ser_ref;
41452         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41453         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41454         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
41455         *ret_conv = NodeAnnouncement_read(ser_ref);
41456         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41457         return tag_ptr(ret_conv, true);
41458 }
41459
41460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41461         LDKu8slice ser_ref;
41462         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41463         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41464         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
41465         *ret_conv = QueryShortChannelIds_read(ser_ref);
41466         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41467         return tag_ptr(ret_conv, true);
41468 }
41469
41470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
41471         LDKQueryShortChannelIds obj_conv;
41472         obj_conv.inner = untag_ptr(obj);
41473         obj_conv.is_owned = ptr_is_owned(obj);
41474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41475         obj_conv.is_owned = false;
41476         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
41477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41479         CVec_u8Z_free(ret_var);
41480         return ret_arr;
41481 }
41482
41483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
41484         LDKReplyShortChannelIdsEnd obj_conv;
41485         obj_conv.inner = untag_ptr(obj);
41486         obj_conv.is_owned = ptr_is_owned(obj);
41487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41488         obj_conv.is_owned = false;
41489         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
41490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41492         CVec_u8Z_free(ret_var);
41493         return ret_arr;
41494 }
41495
41496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41497         LDKu8slice ser_ref;
41498         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41499         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41500         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
41501         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
41502         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41503         return tag_ptr(ret_conv, true);
41504 }
41505
41506 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
41507         LDKQueryChannelRange this_arg_conv;
41508         this_arg_conv.inner = untag_ptr(this_arg);
41509         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41511         this_arg_conv.is_owned = false;
41512         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
41513         return ret_conv;
41514 }
41515
41516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41517         LDKQueryChannelRange obj_conv;
41518         obj_conv.inner = untag_ptr(obj);
41519         obj_conv.is_owned = ptr_is_owned(obj);
41520         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41521         obj_conv.is_owned = false;
41522         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
41523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41525         CVec_u8Z_free(ret_var);
41526         return ret_arr;
41527 }
41528
41529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41530         LDKu8slice ser_ref;
41531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41533         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
41534         *ret_conv = QueryChannelRange_read(ser_ref);
41535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41536         return tag_ptr(ret_conv, true);
41537 }
41538
41539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41540         LDKu8slice ser_ref;
41541         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41542         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41543         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
41544         *ret_conv = ReplyChannelRange_read(ser_ref);
41545         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41546         return tag_ptr(ret_conv, true);
41547 }
41548
41549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41550         LDKReplyChannelRange obj_conv;
41551         obj_conv.inner = untag_ptr(obj);
41552         obj_conv.is_owned = ptr_is_owned(obj);
41553         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41554         obj_conv.is_owned = false;
41555         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
41556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41558         CVec_u8Z_free(ret_var);
41559         return ret_arr;
41560 }
41561
41562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
41563         LDKGossipTimestampFilter obj_conv;
41564         obj_conv.inner = untag_ptr(obj);
41565         obj_conv.is_owned = ptr_is_owned(obj);
41566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41567         obj_conv.is_owned = false;
41568         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
41569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41571         CVec_u8Z_free(ret_var);
41572         return ret_arr;
41573 }
41574
41575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41576         LDKu8slice ser_ref;
41577         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41578         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41579         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
41580         *ret_conv = GossipTimestampFilter_read(ser_ref);
41581         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41582         return tag_ptr(ret_conv, true);
41583 }
41584
41585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41586         if (!ptr_is_owned(this_ptr)) return;
41587         void* this_ptr_ptr = untag_ptr(this_ptr);
41588         CHECK_ACCESS(this_ptr_ptr);
41589         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
41590         FREE(untag_ptr(this_ptr));
41591         CustomMessageHandler_free(this_ptr_conv);
41592 }
41593
41594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41595         LDKIgnoringMessageHandler this_obj_conv;
41596         this_obj_conv.inner = untag_ptr(this_obj);
41597         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41599         IgnoringMessageHandler_free(this_obj_conv);
41600 }
41601
41602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
41603         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
41604         int64_t ret_ref = 0;
41605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41607         return ret_ref;
41608 }
41609
41610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41611         LDKIgnoringMessageHandler this_arg_conv;
41612         this_arg_conv.inner = untag_ptr(this_arg);
41613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41615         this_arg_conv.is_owned = false;
41616         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41617         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41618         return tag_ptr(ret_ret, true);
41619 }
41620
41621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41622         LDKIgnoringMessageHandler this_arg_conv;
41623         this_arg_conv.inner = untag_ptr(this_arg);
41624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41626         this_arg_conv.is_owned = false;
41627         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41628         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
41629         return tag_ptr(ret_ret, true);
41630 }
41631
41632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41633         LDKIgnoringMessageHandler this_arg_conv;
41634         this_arg_conv.inner = untag_ptr(this_arg);
41635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41637         this_arg_conv.is_owned = false;
41638         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
41639         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
41640         return tag_ptr(ret_ret, true);
41641 }
41642
41643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41644         LDKIgnoringMessageHandler this_arg_conv;
41645         this_arg_conv.inner = untag_ptr(this_arg);
41646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41648         this_arg_conv.is_owned = false;
41649         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
41650         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
41651         return tag_ptr(ret_ret, true);
41652 }
41653
41654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41655         LDKIgnoringMessageHandler this_arg_conv;
41656         this_arg_conv.inner = untag_ptr(this_arg);
41657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41659         this_arg_conv.is_owned = false;
41660         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
41661         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
41662         return tag_ptr(ret_ret, true);
41663 }
41664
41665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
41666         LDKIgnoringMessageHandler this_arg_conv;
41667         this_arg_conv.inner = untag_ptr(this_arg);
41668         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41670         this_arg_conv.is_owned = false;
41671         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
41672         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
41673         return tag_ptr(ret_ret, true);
41674 }
41675
41676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41677         LDKIgnoringMessageHandler this_arg_conv;
41678         this_arg_conv.inner = untag_ptr(this_arg);
41679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41681         this_arg_conv.is_owned = false;
41682         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
41683         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
41684         return tag_ptr(ret_ret, true);
41685 }
41686
41687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41688         LDKErroringMessageHandler this_obj_conv;
41689         this_obj_conv.inner = untag_ptr(this_obj);
41690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41692         ErroringMessageHandler_free(this_obj_conv);
41693 }
41694
41695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
41696         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
41697         int64_t ret_ref = 0;
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41700         return ret_ref;
41701 }
41702
41703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41704         LDKErroringMessageHandler this_arg_conv;
41705         this_arg_conv.inner = untag_ptr(this_arg);
41706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41708         this_arg_conv.is_owned = false;
41709         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41710         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41711         return tag_ptr(ret_ret, true);
41712 }
41713
41714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41715         LDKErroringMessageHandler this_arg_conv;
41716         this_arg_conv.inner = untag_ptr(this_arg);
41717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41719         this_arg_conv.is_owned = false;
41720         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
41721         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
41722         return tag_ptr(ret_ret, true);
41723 }
41724
41725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41726         LDKMessageHandler this_obj_conv;
41727         this_obj_conv.inner = untag_ptr(this_obj);
41728         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41730         MessageHandler_free(this_obj_conv);
41731 }
41732
41733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41734         LDKMessageHandler this_ptr_conv;
41735         this_ptr_conv.inner = untag_ptr(this_ptr);
41736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41738         this_ptr_conv.is_owned = false;
41739         // WARNING: This object doesn't live past this scope, needs clone!
41740         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
41741         return ret_ret;
41742 }
41743
41744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41745         LDKMessageHandler this_ptr_conv;
41746         this_ptr_conv.inner = untag_ptr(this_ptr);
41747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41749         this_ptr_conv.is_owned = false;
41750         void* val_ptr = untag_ptr(val);
41751         CHECK_ACCESS(val_ptr);
41752         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
41753         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
41754                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41755                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
41756         }
41757         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
41758 }
41759
41760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41761         LDKMessageHandler this_ptr_conv;
41762         this_ptr_conv.inner = untag_ptr(this_ptr);
41763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41765         this_ptr_conv.is_owned = false;
41766         // WARNING: This object doesn't live past this scope, needs clone!
41767         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
41768         return ret_ret;
41769 }
41770
41771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41772         LDKMessageHandler this_ptr_conv;
41773         this_ptr_conv.inner = untag_ptr(this_ptr);
41774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41776         this_ptr_conv.is_owned = false;
41777         void* val_ptr = untag_ptr(val);
41778         CHECK_ACCESS(val_ptr);
41779         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
41780         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41782                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
41783         }
41784         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
41785 }
41786
41787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41788         LDKMessageHandler this_ptr_conv;
41789         this_ptr_conv.inner = untag_ptr(this_ptr);
41790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41792         this_ptr_conv.is_owned = false;
41793         // WARNING: This object doesn't live past this scope, needs clone!
41794         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
41795         return ret_ret;
41796 }
41797
41798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41799         LDKMessageHandler this_ptr_conv;
41800         this_ptr_conv.inner = untag_ptr(this_ptr);
41801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41803         this_ptr_conv.is_owned = false;
41804         void* val_ptr = untag_ptr(val);
41805         CHECK_ACCESS(val_ptr);
41806         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
41807         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
41808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41809                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
41810         }
41811         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
41812 }
41813
41814 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) {
41815         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
41816         CHECK_ACCESS(chan_handler_arg_ptr);
41817         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
41818         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
41819                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41820                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
41821         }
41822         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
41823         CHECK_ACCESS(route_handler_arg_ptr);
41824         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
41825         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41827                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
41828         }
41829         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41830         CHECK_ACCESS(onion_message_handler_arg_ptr);
41831         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41832         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41833                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41834                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41835         }
41836         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41837         int64_t ret_ref = 0;
41838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41840         return ret_ref;
41841 }
41842
41843 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41844         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41845         *ret_ret = SocketDescriptor_clone(arg);
41846         return tag_ptr(ret_ret, true);
41847 }
41848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41849         void* arg_ptr = untag_ptr(arg);
41850         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41851         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41852         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41853         return ret_conv;
41854 }
41855
41856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41857         void* orig_ptr = untag_ptr(orig);
41858         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41859         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41860         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41861         *ret_ret = SocketDescriptor_clone(orig_conv);
41862         return tag_ptr(ret_ret, true);
41863 }
41864
41865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41866         if (!ptr_is_owned(this_ptr)) return;
41867         void* this_ptr_ptr = untag_ptr(this_ptr);
41868         CHECK_ACCESS(this_ptr_ptr);
41869         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41870         FREE(untag_ptr(this_ptr));
41871         SocketDescriptor_free(this_ptr_conv);
41872 }
41873
41874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41875         LDKPeerHandleError this_obj_conv;
41876         this_obj_conv.inner = untag_ptr(this_obj);
41877         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41879         PeerHandleError_free(this_obj_conv);
41880 }
41881
41882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz) {
41883         LDKPeerHandleError ret_var = PeerHandleError_new();
41884         int64_t ret_ref = 0;
41885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41887         return ret_ref;
41888 }
41889
41890 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41891         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41892         int64_t ret_ref = 0;
41893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41895         return ret_ref;
41896 }
41897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41898         LDKPeerHandleError arg_conv;
41899         arg_conv.inner = untag_ptr(arg);
41900         arg_conv.is_owned = ptr_is_owned(arg);
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41902         arg_conv.is_owned = false;
41903         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41904         return ret_conv;
41905 }
41906
41907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41908         LDKPeerHandleError orig_conv;
41909         orig_conv.inner = untag_ptr(orig);
41910         orig_conv.is_owned = ptr_is_owned(orig);
41911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41912         orig_conv.is_owned = false;
41913         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41914         int64_t ret_ref = 0;
41915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41917         return ret_ref;
41918 }
41919
41920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41921         LDKPeerManager this_obj_conv;
41922         this_obj_conv.inner = untag_ptr(this_obj);
41923         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41925         PeerManager_free(this_obj_conv);
41926 }
41927
41928 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) {
41929         LDKMessageHandler message_handler_conv;
41930         message_handler_conv.inner = untag_ptr(message_handler);
41931         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41932         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41933         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41934         
41935         uint8_t ephemeral_random_data_arr[32];
41936         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41937         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41938         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41939         void* logger_ptr = untag_ptr(logger);
41940         CHECK_ACCESS(logger_ptr);
41941         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41942         if (logger_conv.free == LDKLogger_JCalls_free) {
41943                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41944                 LDKLogger_JCalls_cloned(&logger_conv);
41945         }
41946         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41947         CHECK_ACCESS(custom_message_handler_ptr);
41948         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41949         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41950                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41951                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41952         }
41953         void* node_signer_ptr = untag_ptr(node_signer);
41954         CHECK_ACCESS(node_signer_ptr);
41955         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
41956         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
41957                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41958                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
41959         }
41960         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv, node_signer_conv);
41961         int64_t ret_ref = 0;
41962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41964         return ret_ref;
41965 }
41966
41967 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41968         LDKPeerManager this_arg_conv;
41969         this_arg_conv.inner = untag_ptr(this_arg);
41970         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41972         this_arg_conv.is_owned = false;
41973         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41974         int64_tArray ret_arr = NULL;
41975         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41976         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41977         for (size_t o = 0; o < ret_var.datalen; o++) {
41978                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
41979                 *ret_conv_40_conv = ret_var.data[o];
41980                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
41981         }
41982         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41983         FREE(ret_var.data);
41984         return ret_arr;
41985 }
41986
41987 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) {
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         LDKPublicKey their_node_id_ref;
41994         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
41995         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
41996         void* descriptor_ptr = untag_ptr(descriptor);
41997         CHECK_ACCESS(descriptor_ptr);
41998         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41999         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42001                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42002         }
42003         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42004         CHECK_ACCESS(remote_network_address_ptr);
42005         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42006         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
42007         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
42008         return tag_ptr(ret_conv, true);
42009 }
42010
42011 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) {
42012         LDKPeerManager this_arg_conv;
42013         this_arg_conv.inner = untag_ptr(this_arg);
42014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42016         this_arg_conv.is_owned = false;
42017         void* descriptor_ptr = untag_ptr(descriptor);
42018         CHECK_ACCESS(descriptor_ptr);
42019         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42020         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42022                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42023         }
42024         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42025         CHECK_ACCESS(remote_network_address_ptr);
42026         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42027         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42028         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
42029         return tag_ptr(ret_conv, true);
42030 }
42031
42032 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) {
42033         LDKPeerManager this_arg_conv;
42034         this_arg_conv.inner = untag_ptr(this_arg);
42035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42037         this_arg_conv.is_owned = false;
42038         void* descriptor_ptr = untag_ptr(descriptor);
42039         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42040         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42041         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42042         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
42043         return tag_ptr(ret_conv, true);
42044 }
42045
42046 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) {
42047         LDKPeerManager this_arg_conv;
42048         this_arg_conv.inner = untag_ptr(this_arg);
42049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42051         this_arg_conv.is_owned = false;
42052         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
42053         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
42054         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
42055         LDKu8slice data_ref;
42056         data_ref.datalen = (*env)->GetArrayLength(env, data);
42057         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
42058         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
42059         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
42060         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
42061         return tag_ptr(ret_conv, true);
42062 }
42063
42064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
42065         LDKPeerManager this_arg_conv;
42066         this_arg_conv.inner = untag_ptr(this_arg);
42067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42069         this_arg_conv.is_owned = false;
42070         PeerManager_process_events(&this_arg_conv);
42071 }
42072
42073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
42074         LDKPeerManager this_arg_conv;
42075         this_arg_conv.inner = untag_ptr(this_arg);
42076         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42078         this_arg_conv.is_owned = false;
42079         void* descriptor_ptr = untag_ptr(descriptor);
42080         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42081         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42082         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
42083 }
42084
42085 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) {
42086         LDKPeerManager this_arg_conv;
42087         this_arg_conv.inner = untag_ptr(this_arg);
42088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42090         this_arg_conv.is_owned = false;
42091         LDKPublicKey node_id_ref;
42092         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42093         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42094         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
42095 }
42096
42097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
42098         LDKPeerManager this_arg_conv;
42099         this_arg_conv.inner = untag_ptr(this_arg);
42100         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42102         this_arg_conv.is_owned = false;
42103         PeerManager_disconnect_all_peers(&this_arg_conv);
42104 }
42105
42106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
42107         LDKPeerManager this_arg_conv;
42108         this_arg_conv.inner = untag_ptr(this_arg);
42109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42111         this_arg_conv.is_owned = false;
42112         PeerManager_timer_tick_occurred(&this_arg_conv);
42113 }
42114
42115 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) {
42116         LDKPeerManager this_arg_conv;
42117         this_arg_conv.inner = untag_ptr(this_arg);
42118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42120         this_arg_conv.is_owned = false;
42121         LDKThreeBytes rgb_ref;
42122         CHECK((*env)->GetArrayLength(env, rgb) == 3);
42123         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
42124         LDKThirtyTwoBytes alias_ref;
42125         CHECK((*env)->GetArrayLength(env, alias) == 32);
42126         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
42127         LDKCVec_NetAddressZ addresses_constr;
42128         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
42129         if (addresses_constr.datalen > 0)
42130                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42131         else
42132                 addresses_constr.data = NULL;
42133         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
42134         for (size_t m = 0; m < addresses_constr.datalen; m++) {
42135                 int64_t addresses_conv_12 = addresses_vals[m];
42136                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
42137                 CHECK_ACCESS(addresses_conv_12_ptr);
42138                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
42139                 addresses_constr.data[m] = addresses_conv_12_conv;
42140         }
42141         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
42142         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
42143 }
42144
42145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42146         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
42147         return ret_conv;
42148 }
42149
42150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42151         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
42152         return ret_conv;
42153 }
42154
42155 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42156         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
42157         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
42158         return ret_conv;
42159 }
42160
42161 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
42162         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
42163         return ret_conv;
42164 }
42165
42166 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
42167         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
42168         return ret_conv;
42169 }
42170
42171 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
42172         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
42173         return ret_conv;
42174 }
42175
42176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
42177         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
42178         return ret_conv;
42179 }
42180
42181 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
42182         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
42183         return ret_conv;
42184 }
42185
42186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42187         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
42188         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
42189         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
42190         return ret_conv;
42191 }
42192
42193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
42194         LDKWitness witness_ref;
42195         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
42196         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
42197         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
42198         witness_ref.data_is_owned = true;
42199         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
42200         *ret_copy = HTLCClaim_from_witness(witness_ref);
42201         int64_t ret_ref = tag_ptr(ret_copy, true);
42202         return ret_ref;
42203 }
42204
42205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
42206         uint8_t commitment_seed_arr[32];
42207         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
42208         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
42209         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
42210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
42212         return ret_arr;
42213 }
42214
42215 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) {
42216         LDKCVec_u8Z to_holder_script_ref;
42217         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42218         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42219         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42220         LDKCVec_u8Z to_counterparty_script_ref;
42221         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42222         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42223         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42224         LDKOutPoint funding_outpoint_conv;
42225         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42226         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42227         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42228         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42229         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);
42230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42232         Transaction_free(ret_var);
42233         return ret_arr;
42234 }
42235
42236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42237         LDKCounterpartyCommitmentSecrets this_obj_conv;
42238         this_obj_conv.inner = untag_ptr(this_obj);
42239         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42241         CounterpartyCommitmentSecrets_free(this_obj_conv);
42242 }
42243
42244 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
42245         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
42246         int64_t ret_ref = 0;
42247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42249         return ret_ref;
42250 }
42251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42252         LDKCounterpartyCommitmentSecrets arg_conv;
42253         arg_conv.inner = untag_ptr(arg);
42254         arg_conv.is_owned = ptr_is_owned(arg);
42255         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42256         arg_conv.is_owned = false;
42257         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
42258         return ret_conv;
42259 }
42260
42261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42262         LDKCounterpartyCommitmentSecrets orig_conv;
42263         orig_conv.inner = untag_ptr(orig);
42264         orig_conv.is_owned = ptr_is_owned(orig);
42265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42266         orig_conv.is_owned = false;
42267         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
42268         int64_t ret_ref = 0;
42269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42271         return ret_ref;
42272 }
42273
42274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
42275         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
42276         int64_t ret_ref = 0;
42277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42279         return ret_ref;
42280 }
42281
42282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42283         LDKCounterpartyCommitmentSecrets this_arg_conv;
42284         this_arg_conv.inner = untag_ptr(this_arg);
42285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42287         this_arg_conv.is_owned = false;
42288         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
42289         return ret_conv;
42290 }
42291
42292 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) {
42293         LDKCounterpartyCommitmentSecrets this_arg_conv;
42294         this_arg_conv.inner = untag_ptr(this_arg);
42295         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42297         this_arg_conv.is_owned = false;
42298         LDKThirtyTwoBytes secret_ref;
42299         CHECK((*env)->GetArrayLength(env, secret) == 32);
42300         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
42301         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
42302         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
42303         return tag_ptr(ret_conv, true);
42304 }
42305
42306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
42307         LDKCounterpartyCommitmentSecrets this_arg_conv;
42308         this_arg_conv.inner = untag_ptr(this_arg);
42309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42311         this_arg_conv.is_owned = false;
42312         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
42314         return ret_arr;
42315 }
42316
42317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
42318         LDKCounterpartyCommitmentSecrets obj_conv;
42319         obj_conv.inner = untag_ptr(obj);
42320         obj_conv.is_owned = ptr_is_owned(obj);
42321         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42322         obj_conv.is_owned = false;
42323         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
42324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42326         CVec_u8Z_free(ret_var);
42327         return ret_arr;
42328 }
42329
42330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42331         LDKu8slice ser_ref;
42332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42334         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
42335         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
42336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42337         return tag_ptr(ret_conv, true);
42338 }
42339
42340 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) {
42341         LDKPublicKey per_commitment_point_ref;
42342         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42343         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42344         uint8_t base_secret_arr[32];
42345         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
42346         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
42347         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
42348         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
42350         return ret_arr;
42351 }
42352
42353 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) {
42354         LDKPublicKey per_commitment_point_ref;
42355         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42356         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42357         LDKPublicKey base_point_ref;
42358         CHECK((*env)->GetArrayLength(env, base_point) == 33);
42359         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
42360         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42361         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
42362         return ret_arr;
42363 }
42364
42365 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) {
42366         uint8_t per_commitment_secret_arr[32];
42367         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
42368         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
42369         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
42370         uint8_t countersignatory_revocation_base_secret_arr[32];
42371         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
42372         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
42373         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
42374         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
42376         return ret_arr;
42377 }
42378
42379 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) {
42380         LDKPublicKey per_commitment_point_ref;
42381         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42382         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42383         LDKPublicKey countersignatory_revocation_base_point_ref;
42384         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
42385         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
42386         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42387         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
42388         return ret_arr;
42389 }
42390
42391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42392         LDKTxCreationKeys this_obj_conv;
42393         this_obj_conv.inner = untag_ptr(this_obj);
42394         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42396         TxCreationKeys_free(this_obj_conv);
42397 }
42398
42399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42400         LDKTxCreationKeys this_ptr_conv;
42401         this_ptr_conv.inner = untag_ptr(this_ptr);
42402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42404         this_ptr_conv.is_owned = false;
42405         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
42407         return ret_arr;
42408 }
42409
42410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42411         LDKTxCreationKeys this_ptr_conv;
42412         this_ptr_conv.inner = untag_ptr(this_ptr);
42413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42415         this_ptr_conv.is_owned = false;
42416         LDKPublicKey val_ref;
42417         CHECK((*env)->GetArrayLength(env, val) == 33);
42418         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42419         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
42420 }
42421
42422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42423         LDKTxCreationKeys this_ptr_conv;
42424         this_ptr_conv.inner = untag_ptr(this_ptr);
42425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42427         this_ptr_conv.is_owned = false;
42428         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
42430         return ret_arr;
42431 }
42432
42433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42434         LDKTxCreationKeys this_ptr_conv;
42435         this_ptr_conv.inner = untag_ptr(this_ptr);
42436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42438         this_ptr_conv.is_owned = false;
42439         LDKPublicKey val_ref;
42440         CHECK((*env)->GetArrayLength(env, val) == 33);
42441         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42442         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
42443 }
42444
42445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42446         LDKTxCreationKeys this_ptr_conv;
42447         this_ptr_conv.inner = untag_ptr(this_ptr);
42448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42450         this_ptr_conv.is_owned = false;
42451         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
42453         return ret_arr;
42454 }
42455
42456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42457         LDKTxCreationKeys this_ptr_conv;
42458         this_ptr_conv.inner = untag_ptr(this_ptr);
42459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42461         this_ptr_conv.is_owned = false;
42462         LDKPublicKey val_ref;
42463         CHECK((*env)->GetArrayLength(env, val) == 33);
42464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42465         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
42466 }
42467
42468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42469         LDKTxCreationKeys this_ptr_conv;
42470         this_ptr_conv.inner = untag_ptr(this_ptr);
42471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42473         this_ptr_conv.is_owned = false;
42474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
42476         return ret_arr;
42477 }
42478
42479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42480         LDKTxCreationKeys this_ptr_conv;
42481         this_ptr_conv.inner = untag_ptr(this_ptr);
42482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42484         this_ptr_conv.is_owned = false;
42485         LDKPublicKey val_ref;
42486         CHECK((*env)->GetArrayLength(env, val) == 33);
42487         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42488         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
42489 }
42490
42491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42492         LDKTxCreationKeys this_ptr_conv;
42493         this_ptr_conv.inner = untag_ptr(this_ptr);
42494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42496         this_ptr_conv.is_owned = false;
42497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
42499         return ret_arr;
42500 }
42501
42502 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) {
42503         LDKTxCreationKeys this_ptr_conv;
42504         this_ptr_conv.inner = untag_ptr(this_ptr);
42505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42507         this_ptr_conv.is_owned = false;
42508         LDKPublicKey val_ref;
42509         CHECK((*env)->GetArrayLength(env, val) == 33);
42510         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42511         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
42512 }
42513
42514 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) {
42515         LDKPublicKey per_commitment_point_arg_ref;
42516         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
42517         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
42518         LDKPublicKey revocation_key_arg_ref;
42519         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
42520         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
42521         LDKPublicKey broadcaster_htlc_key_arg_ref;
42522         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
42523         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
42524         LDKPublicKey countersignatory_htlc_key_arg_ref;
42525         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
42526         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
42527         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
42528         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
42529         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
42530         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);
42531         int64_t ret_ref = 0;
42532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42534         return ret_ref;
42535 }
42536
42537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42538         LDKTxCreationKeys a_conv;
42539         a_conv.inner = untag_ptr(a);
42540         a_conv.is_owned = ptr_is_owned(a);
42541         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42542         a_conv.is_owned = false;
42543         LDKTxCreationKeys b_conv;
42544         b_conv.inner = untag_ptr(b);
42545         b_conv.is_owned = ptr_is_owned(b);
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42547         b_conv.is_owned = false;
42548         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
42549         return ret_conv;
42550 }
42551
42552 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
42553         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
42554         int64_t ret_ref = 0;
42555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42557         return ret_ref;
42558 }
42559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42560         LDKTxCreationKeys arg_conv;
42561         arg_conv.inner = untag_ptr(arg);
42562         arg_conv.is_owned = ptr_is_owned(arg);
42563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42564         arg_conv.is_owned = false;
42565         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
42566         return ret_conv;
42567 }
42568
42569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42570         LDKTxCreationKeys orig_conv;
42571         orig_conv.inner = untag_ptr(orig);
42572         orig_conv.is_owned = ptr_is_owned(orig);
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42574         orig_conv.is_owned = false;
42575         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
42576         int64_t ret_ref = 0;
42577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42579         return ret_ref;
42580 }
42581
42582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42583         LDKTxCreationKeys obj_conv;
42584         obj_conv.inner = untag_ptr(obj);
42585         obj_conv.is_owned = ptr_is_owned(obj);
42586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42587         obj_conv.is_owned = false;
42588         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
42589         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42590         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42591         CVec_u8Z_free(ret_var);
42592         return ret_arr;
42593 }
42594
42595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42596         LDKu8slice ser_ref;
42597         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42598         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42599         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
42600         *ret_conv = TxCreationKeys_read(ser_ref);
42601         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42602         return tag_ptr(ret_conv, true);
42603 }
42604
42605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42606         LDKChannelPublicKeys this_obj_conv;
42607         this_obj_conv.inner = untag_ptr(this_obj);
42608         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42610         ChannelPublicKeys_free(this_obj_conv);
42611 }
42612
42613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42614         LDKChannelPublicKeys this_ptr_conv;
42615         this_ptr_conv.inner = untag_ptr(this_ptr);
42616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42618         this_ptr_conv.is_owned = false;
42619         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
42621         return ret_arr;
42622 }
42623
42624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42625         LDKChannelPublicKeys this_ptr_conv;
42626         this_ptr_conv.inner = untag_ptr(this_ptr);
42627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42629         this_ptr_conv.is_owned = false;
42630         LDKPublicKey val_ref;
42631         CHECK((*env)->GetArrayLength(env, val) == 33);
42632         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42633         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
42634 }
42635
42636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42637         LDKChannelPublicKeys this_ptr_conv;
42638         this_ptr_conv.inner = untag_ptr(this_ptr);
42639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42641         this_ptr_conv.is_owned = false;
42642         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42643         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
42644         return ret_arr;
42645 }
42646
42647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42648         LDKChannelPublicKeys this_ptr_conv;
42649         this_ptr_conv.inner = untag_ptr(this_ptr);
42650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42652         this_ptr_conv.is_owned = false;
42653         LDKPublicKey val_ref;
42654         CHECK((*env)->GetArrayLength(env, val) == 33);
42655         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42656         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
42657 }
42658
42659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42660         LDKChannelPublicKeys this_ptr_conv;
42661         this_ptr_conv.inner = untag_ptr(this_ptr);
42662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42664         this_ptr_conv.is_owned = false;
42665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
42667         return ret_arr;
42668 }
42669
42670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42671         LDKChannelPublicKeys this_ptr_conv;
42672         this_ptr_conv.inner = untag_ptr(this_ptr);
42673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42675         this_ptr_conv.is_owned = false;
42676         LDKPublicKey val_ref;
42677         CHECK((*env)->GetArrayLength(env, val) == 33);
42678         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42679         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
42680 }
42681
42682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42683         LDKChannelPublicKeys this_ptr_conv;
42684         this_ptr_conv.inner = untag_ptr(this_ptr);
42685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42687         this_ptr_conv.is_owned = false;
42688         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
42690         return ret_arr;
42691 }
42692
42693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42694         LDKChannelPublicKeys this_ptr_conv;
42695         this_ptr_conv.inner = untag_ptr(this_ptr);
42696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42698         this_ptr_conv.is_owned = false;
42699         LDKPublicKey val_ref;
42700         CHECK((*env)->GetArrayLength(env, val) == 33);
42701         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42702         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
42703 }
42704
42705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42706         LDKChannelPublicKeys this_ptr_conv;
42707         this_ptr_conv.inner = untag_ptr(this_ptr);
42708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42710         this_ptr_conv.is_owned = false;
42711         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42712         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
42713         return ret_arr;
42714 }
42715
42716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42717         LDKChannelPublicKeys this_ptr_conv;
42718         this_ptr_conv.inner = untag_ptr(this_ptr);
42719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42721         this_ptr_conv.is_owned = false;
42722         LDKPublicKey val_ref;
42723         CHECK((*env)->GetArrayLength(env, val) == 33);
42724         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42725         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
42726 }
42727
42728 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) {
42729         LDKPublicKey funding_pubkey_arg_ref;
42730         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
42731         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
42732         LDKPublicKey revocation_basepoint_arg_ref;
42733         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
42734         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
42735         LDKPublicKey payment_point_arg_ref;
42736         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
42737         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
42738         LDKPublicKey delayed_payment_basepoint_arg_ref;
42739         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
42740         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
42741         LDKPublicKey htlc_basepoint_arg_ref;
42742         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
42743         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
42744         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);
42745         int64_t ret_ref = 0;
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42748         return ret_ref;
42749 }
42750
42751 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
42752         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
42753         int64_t ret_ref = 0;
42754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42756         return ret_ref;
42757 }
42758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42759         LDKChannelPublicKeys arg_conv;
42760         arg_conv.inner = untag_ptr(arg);
42761         arg_conv.is_owned = ptr_is_owned(arg);
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42763         arg_conv.is_owned = false;
42764         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
42765         return ret_conv;
42766 }
42767
42768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42769         LDKChannelPublicKeys orig_conv;
42770         orig_conv.inner = untag_ptr(orig);
42771         orig_conv.is_owned = ptr_is_owned(orig);
42772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42773         orig_conv.is_owned = false;
42774         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
42775         int64_t ret_ref = 0;
42776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42778         return ret_ref;
42779 }
42780
42781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42782         LDKChannelPublicKeys a_conv;
42783         a_conv.inner = untag_ptr(a);
42784         a_conv.is_owned = ptr_is_owned(a);
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42786         a_conv.is_owned = false;
42787         LDKChannelPublicKeys b_conv;
42788         b_conv.inner = untag_ptr(b);
42789         b_conv.is_owned = ptr_is_owned(b);
42790         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42791         b_conv.is_owned = false;
42792         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
42793         return ret_conv;
42794 }
42795
42796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42797         LDKChannelPublicKeys obj_conv;
42798         obj_conv.inner = untag_ptr(obj);
42799         obj_conv.is_owned = ptr_is_owned(obj);
42800         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42801         obj_conv.is_owned = false;
42802         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
42803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42805         CVec_u8Z_free(ret_var);
42806         return ret_arr;
42807 }
42808
42809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42810         LDKu8slice ser_ref;
42811         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42812         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42813         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
42814         *ret_conv = ChannelPublicKeys_read(ser_ref);
42815         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42816         return tag_ptr(ret_conv, true);
42817 }
42818
42819 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) {
42820         LDKPublicKey per_commitment_point_ref;
42821         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42822         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42823         LDKPublicKey broadcaster_delayed_payment_base_ref;
42824         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42825         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42826         LDKPublicKey broadcaster_htlc_base_ref;
42827         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42828         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42829         LDKPublicKey countersignatory_revocation_base_ref;
42830         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42831         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42832         LDKPublicKey countersignatory_htlc_base_ref;
42833         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42834         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42835         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);
42836         int64_t ret_ref = 0;
42837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42839         return ret_ref;
42840 }
42841
42842 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) {
42843         LDKPublicKey per_commitment_point_ref;
42844         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42845         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42846         LDKChannelPublicKeys broadcaster_keys_conv;
42847         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42848         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42849         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42850         broadcaster_keys_conv.is_owned = false;
42851         LDKChannelPublicKeys countersignatory_keys_conv;
42852         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42853         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42854         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42855         countersignatory_keys_conv.is_owned = false;
42856         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42857         int64_t ret_ref = 0;
42858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42860         return ret_ref;
42861 }
42862
42863 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) {
42864         LDKPublicKey revocation_key_ref;
42865         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42866         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42867         LDKPublicKey broadcaster_delayed_payment_key_ref;
42868         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42869         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42870         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42873         CVec_u8Z_free(ret_var);
42874         return ret_arr;
42875 }
42876
42877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42878         LDKHTLCOutputInCommitment this_obj_conv;
42879         this_obj_conv.inner = untag_ptr(this_obj);
42880         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42882         HTLCOutputInCommitment_free(this_obj_conv);
42883 }
42884
42885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42886         LDKHTLCOutputInCommitment this_ptr_conv;
42887         this_ptr_conv.inner = untag_ptr(this_ptr);
42888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42890         this_ptr_conv.is_owned = false;
42891         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42892         return ret_conv;
42893 }
42894
42895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42896         LDKHTLCOutputInCommitment this_ptr_conv;
42897         this_ptr_conv.inner = untag_ptr(this_ptr);
42898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42900         this_ptr_conv.is_owned = false;
42901         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42902 }
42903
42904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42905         LDKHTLCOutputInCommitment this_ptr_conv;
42906         this_ptr_conv.inner = untag_ptr(this_ptr);
42907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42909         this_ptr_conv.is_owned = false;
42910         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42911         return ret_conv;
42912 }
42913
42914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42915         LDKHTLCOutputInCommitment this_ptr_conv;
42916         this_ptr_conv.inner = untag_ptr(this_ptr);
42917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42919         this_ptr_conv.is_owned = false;
42920         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42921 }
42922
42923 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42924         LDKHTLCOutputInCommitment this_ptr_conv;
42925         this_ptr_conv.inner = untag_ptr(this_ptr);
42926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42928         this_ptr_conv.is_owned = false;
42929         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42930         return ret_conv;
42931 }
42932
42933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42934         LDKHTLCOutputInCommitment this_ptr_conv;
42935         this_ptr_conv.inner = untag_ptr(this_ptr);
42936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42938         this_ptr_conv.is_owned = false;
42939         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42940 }
42941
42942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42943         LDKHTLCOutputInCommitment this_ptr_conv;
42944         this_ptr_conv.inner = untag_ptr(this_ptr);
42945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42947         this_ptr_conv.is_owned = false;
42948         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42950         return ret_arr;
42951 }
42952
42953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
42960         CHECK((*env)->GetArrayLength(env, val) == 32);
42961         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42962         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42963 }
42964
42965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42966         LDKHTLCOutputInCommitment this_ptr_conv;
42967         this_ptr_conv.inner = untag_ptr(this_ptr);
42968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42970         this_ptr_conv.is_owned = false;
42971         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42972         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42973         int64_t ret_ref = tag_ptr(ret_copy, true);
42974         return ret_ref;
42975 }
42976
42977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42978         LDKHTLCOutputInCommitment this_ptr_conv;
42979         this_ptr_conv.inner = untag_ptr(this_ptr);
42980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42982         this_ptr_conv.is_owned = false;
42983         void* val_ptr = untag_ptr(val);
42984         CHECK_ACCESS(val_ptr);
42985         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
42986         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
42987         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
42988 }
42989
42990 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) {
42991         LDKThirtyTwoBytes payment_hash_arg_ref;
42992         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
42993         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
42994         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
42995         CHECK_ACCESS(transaction_output_index_arg_ptr);
42996         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
42997         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
42998         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
42999         int64_t ret_ref = 0;
43000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43002         return ret_ref;
43003 }
43004
43005 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
43006         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
43007         int64_t ret_ref = 0;
43008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43010         return ret_ref;
43011 }
43012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43013         LDKHTLCOutputInCommitment arg_conv;
43014         arg_conv.inner = untag_ptr(arg);
43015         arg_conv.is_owned = ptr_is_owned(arg);
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43017         arg_conv.is_owned = false;
43018         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
43019         return ret_conv;
43020 }
43021
43022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43023         LDKHTLCOutputInCommitment orig_conv;
43024         orig_conv.inner = untag_ptr(orig);
43025         orig_conv.is_owned = ptr_is_owned(orig);
43026         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43027         orig_conv.is_owned = false;
43028         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
43029         int64_t ret_ref = 0;
43030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43032         return ret_ref;
43033 }
43034
43035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43036         LDKHTLCOutputInCommitment a_conv;
43037         a_conv.inner = untag_ptr(a);
43038         a_conv.is_owned = ptr_is_owned(a);
43039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43040         a_conv.is_owned = false;
43041         LDKHTLCOutputInCommitment b_conv;
43042         b_conv.inner = untag_ptr(b);
43043         b_conv.is_owned = ptr_is_owned(b);
43044         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43045         b_conv.is_owned = false;
43046         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
43047         return ret_conv;
43048 }
43049
43050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
43051         LDKHTLCOutputInCommitment obj_conv;
43052         obj_conv.inner = untag_ptr(obj);
43053         obj_conv.is_owned = ptr_is_owned(obj);
43054         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43055         obj_conv.is_owned = false;
43056         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
43057         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43058         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43059         CVec_u8Z_free(ret_var);
43060         return ret_arr;
43061 }
43062
43063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43064         LDKu8slice ser_ref;
43065         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43066         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43067         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
43068         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
43069         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43070         return tag_ptr(ret_conv, true);
43071 }
43072
43073 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) {
43074         LDKHTLCOutputInCommitment htlc_conv;
43075         htlc_conv.inner = untag_ptr(htlc);
43076         htlc_conv.is_owned = ptr_is_owned(htlc);
43077         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43078         htlc_conv.is_owned = false;
43079         LDKTxCreationKeys keys_conv;
43080         keys_conv.inner = untag_ptr(keys);
43081         keys_conv.is_owned = ptr_is_owned(keys);
43082         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
43083         keys_conv.is_owned = false;
43084         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
43085         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43086         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43087         CVec_u8Z_free(ret_var);
43088         return ret_arr;
43089 }
43090
43091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
43092         LDKPublicKey broadcaster_ref;
43093         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
43094         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
43095         LDKPublicKey countersignatory_ref;
43096         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
43097         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
43098         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
43099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43101         CVec_u8Z_free(ret_var);
43102         return ret_arr;
43103 }
43104
43105 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) {
43106         uint8_t commitment_txid_arr[32];
43107         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
43108         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
43109         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
43110         LDKHTLCOutputInCommitment htlc_conv;
43111         htlc_conv.inner = untag_ptr(htlc);
43112         htlc_conv.is_owned = ptr_is_owned(htlc);
43113         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43114         htlc_conv.is_owned = false;
43115         LDKPublicKey broadcaster_delayed_payment_key_ref;
43116         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
43117         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
43118         LDKPublicKey revocation_key_ref;
43119         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
43120         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
43121         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);
43122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43124         Transaction_free(ret_var);
43125         return ret_arr;
43126 }
43127
43128 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) {
43129         LDKSignature local_sig_ref;
43130         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
43131         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
43132         LDKSignature remote_sig_ref;
43133         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
43134         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
43135         LDKThirtyTwoBytes preimage_ref;
43136         CHECK((*env)->GetArrayLength(env, preimage) == 32);
43137         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
43138         LDKu8slice redeem_script_ref;
43139         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
43140         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
43141         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
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         Witness_free(ret_var);
43145         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
43146         return ret_arr;
43147 }
43148
43149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
43150         LDKPublicKey payment_point_ref;
43151         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
43152         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
43153         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
43154         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43155         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43156         CVec_u8Z_free(ret_var);
43157         return ret_arr;
43158 }
43159
43160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
43161         LDKPublicKey funding_pubkey_ref;
43162         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
43163         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
43164         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
43165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43167         CVec_u8Z_free(ret_var);
43168         return ret_arr;
43169 }
43170
43171 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) {
43172         LDKPublicKey funding_key_ref;
43173         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
43174         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
43175         LDKSignature funding_sig_ref;
43176         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
43177         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
43178         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
43179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43181         Witness_free(ret_var);
43182         return ret_arr;
43183 }
43184
43185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43186         LDKChannelTransactionParameters this_obj_conv;
43187         this_obj_conv.inner = untag_ptr(this_obj);
43188         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43190         ChannelTransactionParameters_free(this_obj_conv);
43191 }
43192
43193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43194         LDKChannelTransactionParameters this_ptr_conv;
43195         this_ptr_conv.inner = untag_ptr(this_ptr);
43196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43198         this_ptr_conv.is_owned = false;
43199         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
43200         int64_t ret_ref = 0;
43201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43203         return ret_ref;
43204 }
43205
43206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43207         LDKChannelTransactionParameters this_ptr_conv;
43208         this_ptr_conv.inner = untag_ptr(this_ptr);
43209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43211         this_ptr_conv.is_owned = false;
43212         LDKChannelPublicKeys val_conv;
43213         val_conv.inner = untag_ptr(val);
43214         val_conv.is_owned = ptr_is_owned(val);
43215         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43216         val_conv = ChannelPublicKeys_clone(&val_conv);
43217         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
43218 }
43219
43220 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43221         LDKChannelTransactionParameters this_ptr_conv;
43222         this_ptr_conv.inner = untag_ptr(this_ptr);
43223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43225         this_ptr_conv.is_owned = false;
43226         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
43227         return ret_conv;
43228 }
43229
43230 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) {
43231         LDKChannelTransactionParameters this_ptr_conv;
43232         this_ptr_conv.inner = untag_ptr(this_ptr);
43233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43235         this_ptr_conv.is_owned = false;
43236         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
43237 }
43238
43239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
43240         LDKChannelTransactionParameters this_ptr_conv;
43241         this_ptr_conv.inner = untag_ptr(this_ptr);
43242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43244         this_ptr_conv.is_owned = false;
43245         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
43246         return ret_conv;
43247 }
43248
43249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43250         LDKChannelTransactionParameters this_ptr_conv;
43251         this_ptr_conv.inner = untag_ptr(this_ptr);
43252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43254         this_ptr_conv.is_owned = false;
43255         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
43256 }
43257
43258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
43259         LDKChannelTransactionParameters this_ptr_conv;
43260         this_ptr_conv.inner = untag_ptr(this_ptr);
43261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43263         this_ptr_conv.is_owned = false;
43264         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
43265         int64_t ret_ref = 0;
43266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43268         return ret_ref;
43269 }
43270
43271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43272         LDKChannelTransactionParameters this_ptr_conv;
43273         this_ptr_conv.inner = untag_ptr(this_ptr);
43274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43276         this_ptr_conv.is_owned = false;
43277         LDKCounterpartyChannelTransactionParameters val_conv;
43278         val_conv.inner = untag_ptr(val);
43279         val_conv.is_owned = ptr_is_owned(val);
43280         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43281         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
43282         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
43283 }
43284
43285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
43286         LDKChannelTransactionParameters this_ptr_conv;
43287         this_ptr_conv.inner = untag_ptr(this_ptr);
43288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43290         this_ptr_conv.is_owned = false;
43291         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
43292         int64_t ret_ref = 0;
43293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43295         return ret_ref;
43296 }
43297
43298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43299         LDKChannelTransactionParameters this_ptr_conv;
43300         this_ptr_conv.inner = untag_ptr(this_ptr);
43301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43303         this_ptr_conv.is_owned = false;
43304         LDKOutPoint val_conv;
43305         val_conv.inner = untag_ptr(val);
43306         val_conv.is_owned = ptr_is_owned(val);
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43308         val_conv = OutPoint_clone(&val_conv);
43309         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
43310 }
43311
43312 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43313         LDKChannelTransactionParameters this_ptr_conv;
43314         this_ptr_conv.inner = untag_ptr(this_ptr);
43315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43317         this_ptr_conv.is_owned = false;
43318         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
43319         return ret_conv;
43320 }
43321
43322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
43323         LDKChannelTransactionParameters this_ptr_conv;
43324         this_ptr_conv.inner = untag_ptr(this_ptr);
43325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43327         this_ptr_conv.is_owned = false;
43328         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43329         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
43330 }
43331
43332 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_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_non_zero_fee_anchors(&this_ptr_conv));
43339         return ret_conv;
43340 }
43341
43342 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) {
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_non_zero_fee_anchors(&this_ptr_conv, val_conv);
43350 }
43351
43352 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) {
43353         LDKChannelPublicKeys holder_pubkeys_arg_conv;
43354         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
43355         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
43356         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
43357         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
43358         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
43359         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
43360         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
43361         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
43362         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
43363         LDKOutPoint funding_outpoint_arg_conv;
43364         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
43365         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
43366         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
43367         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
43368         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
43369         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
43370         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);
43371         int64_t ret_ref = 0;
43372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43374         return ret_ref;
43375 }
43376
43377 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
43378         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
43379         int64_t ret_ref = 0;
43380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43382         return ret_ref;
43383 }
43384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43385         LDKChannelTransactionParameters arg_conv;
43386         arg_conv.inner = untag_ptr(arg);
43387         arg_conv.is_owned = ptr_is_owned(arg);
43388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43389         arg_conv.is_owned = false;
43390         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
43391         return ret_conv;
43392 }
43393
43394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43395         LDKChannelTransactionParameters orig_conv;
43396         orig_conv.inner = untag_ptr(orig);
43397         orig_conv.is_owned = ptr_is_owned(orig);
43398         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43399         orig_conv.is_owned = false;
43400         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
43401         int64_t ret_ref = 0;
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43404         return ret_ref;
43405 }
43406
43407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43408         LDKChannelTransactionParameters a_conv;
43409         a_conv.inner = untag_ptr(a);
43410         a_conv.is_owned = ptr_is_owned(a);
43411         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43412         a_conv.is_owned = false;
43413         LDKChannelTransactionParameters b_conv;
43414         b_conv.inner = untag_ptr(b);
43415         b_conv.is_owned = ptr_is_owned(b);
43416         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43417         b_conv.is_owned = false;
43418         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
43419         return ret_conv;
43420 }
43421
43422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43423         LDKCounterpartyChannelTransactionParameters this_obj_conv;
43424         this_obj_conv.inner = untag_ptr(this_obj);
43425         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43427         CounterpartyChannelTransactionParameters_free(this_obj_conv);
43428 }
43429
43430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43431         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43432         this_ptr_conv.inner = untag_ptr(this_ptr);
43433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43435         this_ptr_conv.is_owned = false;
43436         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
43437         int64_t ret_ref = 0;
43438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43440         return ret_ref;
43441 }
43442
43443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43444         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43445         this_ptr_conv.inner = untag_ptr(this_ptr);
43446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43448         this_ptr_conv.is_owned = false;
43449         LDKChannelPublicKeys val_conv;
43450         val_conv.inner = untag_ptr(val);
43451         val_conv.is_owned = ptr_is_owned(val);
43452         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43453         val_conv = ChannelPublicKeys_clone(&val_conv);
43454         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
43455 }
43456
43457 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43458         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43459         this_ptr_conv.inner = untag_ptr(this_ptr);
43460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43462         this_ptr_conv.is_owned = false;
43463         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
43464         return ret_conv;
43465 }
43466
43467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43468         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43469         this_ptr_conv.inner = untag_ptr(this_ptr);
43470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43472         this_ptr_conv.is_owned = false;
43473         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
43474 }
43475
43476 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) {
43477         LDKChannelPublicKeys pubkeys_arg_conv;
43478         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
43479         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
43480         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
43481         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
43482         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
43483         int64_t ret_ref = 0;
43484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43486         return ret_ref;
43487 }
43488
43489 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
43490         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
43491         int64_t ret_ref = 0;
43492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43494         return ret_ref;
43495 }
43496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43497         LDKCounterpartyChannelTransactionParameters arg_conv;
43498         arg_conv.inner = untag_ptr(arg);
43499         arg_conv.is_owned = ptr_is_owned(arg);
43500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43501         arg_conv.is_owned = false;
43502         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
43503         return ret_conv;
43504 }
43505
43506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43507         LDKCounterpartyChannelTransactionParameters orig_conv;
43508         orig_conv.inner = untag_ptr(orig);
43509         orig_conv.is_owned = ptr_is_owned(orig);
43510         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43511         orig_conv.is_owned = false;
43512         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
43513         int64_t ret_ref = 0;
43514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43516         return ret_ref;
43517 }
43518
43519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43520         LDKCounterpartyChannelTransactionParameters a_conv;
43521         a_conv.inner = untag_ptr(a);
43522         a_conv.is_owned = ptr_is_owned(a);
43523         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43524         a_conv.is_owned = false;
43525         LDKCounterpartyChannelTransactionParameters b_conv;
43526         b_conv.inner = untag_ptr(b);
43527         b_conv.is_owned = ptr_is_owned(b);
43528         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43529         b_conv.is_owned = false;
43530         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
43531         return ret_conv;
43532 }
43533
43534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
43535         LDKChannelTransactionParameters this_arg_conv;
43536         this_arg_conv.inner = untag_ptr(this_arg);
43537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43539         this_arg_conv.is_owned = false;
43540         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
43541         return ret_conv;
43542 }
43543
43544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43545         LDKChannelTransactionParameters this_arg_conv;
43546         this_arg_conv.inner = untag_ptr(this_arg);
43547         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43549         this_arg_conv.is_owned = false;
43550         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
43551         int64_t ret_ref = 0;
43552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43554         return ret_ref;
43555 }
43556
43557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43558         LDKChannelTransactionParameters this_arg_conv;
43559         this_arg_conv.inner = untag_ptr(this_arg);
43560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43562         this_arg_conv.is_owned = false;
43563         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
43564         int64_t ret_ref = 0;
43565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43567         return ret_ref;
43568 }
43569
43570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43571         LDKCounterpartyChannelTransactionParameters obj_conv;
43572         obj_conv.inner = untag_ptr(obj);
43573         obj_conv.is_owned = ptr_is_owned(obj);
43574         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43575         obj_conv.is_owned = false;
43576         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
43577         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43578         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43579         CVec_u8Z_free(ret_var);
43580         return ret_arr;
43581 }
43582
43583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43584         LDKu8slice ser_ref;
43585         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43586         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43587         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
43588         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
43589         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43590         return tag_ptr(ret_conv, true);
43591 }
43592
43593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43594         LDKChannelTransactionParameters obj_conv;
43595         obj_conv.inner = untag_ptr(obj);
43596         obj_conv.is_owned = ptr_is_owned(obj);
43597         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43598         obj_conv.is_owned = false;
43599         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
43600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43602         CVec_u8Z_free(ret_var);
43603         return ret_arr;
43604 }
43605
43606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43607         LDKu8slice ser_ref;
43608         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43609         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43610         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
43611         *ret_conv = ChannelTransactionParameters_read(ser_ref);
43612         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43613         return tag_ptr(ret_conv, true);
43614 }
43615
43616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43617         LDKDirectedChannelTransactionParameters this_obj_conv;
43618         this_obj_conv.inner = untag_ptr(this_obj);
43619         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43621         DirectedChannelTransactionParameters_free(this_obj_conv);
43622 }
43623
43624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43625         LDKDirectedChannelTransactionParameters this_arg_conv;
43626         this_arg_conv.inner = untag_ptr(this_arg);
43627         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43629         this_arg_conv.is_owned = false;
43630         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
43631         int64_t ret_ref = 0;
43632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43634         return ret_ref;
43635 }
43636
43637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43638         LDKDirectedChannelTransactionParameters this_arg_conv;
43639         this_arg_conv.inner = untag_ptr(this_arg);
43640         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43642         this_arg_conv.is_owned = false;
43643         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
43644         int64_t ret_ref = 0;
43645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43647         return ret_ref;
43648 }
43649
43650 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
43651         LDKDirectedChannelTransactionParameters this_arg_conv;
43652         this_arg_conv.inner = untag_ptr(this_arg);
43653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43655         this_arg_conv.is_owned = false;
43656         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
43657         return ret_conv;
43658 }
43659
43660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
43661         LDKDirectedChannelTransactionParameters this_arg_conv;
43662         this_arg_conv.inner = untag_ptr(this_arg);
43663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43665         this_arg_conv.is_owned = false;
43666         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
43667         return ret_conv;
43668 }
43669
43670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(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         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
43677         int64_t ret_ref = 0;
43678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43680         return ret_ref;
43681 }
43682
43683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43684         LDKDirectedChannelTransactionParameters this_arg_conv;
43685         this_arg_conv.inner = untag_ptr(this_arg);
43686         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43688         this_arg_conv.is_owned = false;
43689         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
43690         return ret_conv;
43691 }
43692
43693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43694         LDKHolderCommitmentTransaction this_obj_conv;
43695         this_obj_conv.inner = untag_ptr(this_obj);
43696         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43698         HolderCommitmentTransaction_free(this_obj_conv);
43699 }
43700
43701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
43702         LDKHolderCommitmentTransaction this_ptr_conv;
43703         this_ptr_conv.inner = untag_ptr(this_ptr);
43704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43706         this_ptr_conv.is_owned = false;
43707         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
43709         return ret_arr;
43710 }
43711
43712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43713         LDKHolderCommitmentTransaction this_ptr_conv;
43714         this_ptr_conv.inner = untag_ptr(this_ptr);
43715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43717         this_ptr_conv.is_owned = false;
43718         LDKSignature val_ref;
43719         CHECK((*env)->GetArrayLength(env, val) == 64);
43720         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
43721         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
43722 }
43723
43724 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
43725         LDKHolderCommitmentTransaction this_ptr_conv;
43726         this_ptr_conv.inner = untag_ptr(this_ptr);
43727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43729         this_ptr_conv.is_owned = false;
43730         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
43731         jobjectArray ret_arr = NULL;
43732         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
43733         ;
43734         for (size_t i = 0; i < ret_var.datalen; i++) {
43735                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
43736                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
43737                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
43738         }
43739         
43740         FREE(ret_var.data);
43741         return ret_arr;
43742 }
43743
43744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
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 val_constr;
43751         val_constr.datalen = (*env)->GetArrayLength(env, val);
43752         if (val_constr.datalen > 0)
43753                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43754         else
43755                 val_constr.data = NULL;
43756         for (size_t i = 0; i < val_constr.datalen; i++) {
43757                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
43758                 LDKSignature val_conv_8_ref;
43759                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
43760                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
43761                 val_constr.data[i] = val_conv_8_ref;
43762         }
43763         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
43764 }
43765
43766 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
43767         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
43768         int64_t ret_ref = 0;
43769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43771         return ret_ref;
43772 }
43773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43774         LDKHolderCommitmentTransaction arg_conv;
43775         arg_conv.inner = untag_ptr(arg);
43776         arg_conv.is_owned = ptr_is_owned(arg);
43777         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43778         arg_conv.is_owned = false;
43779         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
43780         return ret_conv;
43781 }
43782
43783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43784         LDKHolderCommitmentTransaction orig_conv;
43785         orig_conv.inner = untag_ptr(orig);
43786         orig_conv.is_owned = ptr_is_owned(orig);
43787         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43788         orig_conv.is_owned = false;
43789         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
43790         int64_t ret_ref = 0;
43791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43793         return ret_ref;
43794 }
43795
43796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43797         LDKHolderCommitmentTransaction obj_conv;
43798         obj_conv.inner = untag_ptr(obj);
43799         obj_conv.is_owned = ptr_is_owned(obj);
43800         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43801         obj_conv.is_owned = false;
43802         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
43803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43805         CVec_u8Z_free(ret_var);
43806         return ret_arr;
43807 }
43808
43809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43810         LDKu8slice ser_ref;
43811         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43812         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43813         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
43814         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
43815         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43816         return tag_ptr(ret_conv, true);
43817 }
43818
43819 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) {
43820         LDKCommitmentTransaction commitment_tx_conv;
43821         commitment_tx_conv.inner = untag_ptr(commitment_tx);
43822         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
43823         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
43824         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
43825         LDKSignature counterparty_sig_ref;
43826         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
43827         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
43828         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
43829         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
43830         if (counterparty_htlc_sigs_constr.datalen > 0)
43831                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43832         else
43833                 counterparty_htlc_sigs_constr.data = NULL;
43834         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
43835                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
43836                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
43837                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
43838                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
43839                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
43840         }
43841         LDKPublicKey holder_funding_key_ref;
43842         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
43843         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
43844         LDKPublicKey counterparty_funding_key_ref;
43845         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43846         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43847         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43848         int64_t ret_ref = 0;
43849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43850         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43851         return ret_ref;
43852 }
43853
43854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43855         LDKBuiltCommitmentTransaction this_obj_conv;
43856         this_obj_conv.inner = untag_ptr(this_obj);
43857         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43859         BuiltCommitmentTransaction_free(this_obj_conv);
43860 }
43861
43862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43863         LDKBuiltCommitmentTransaction this_ptr_conv;
43864         this_ptr_conv.inner = untag_ptr(this_ptr);
43865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43867         this_ptr_conv.is_owned = false;
43868         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43871         Transaction_free(ret_var);
43872         return ret_arr;
43873 }
43874
43875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43876         LDKBuiltCommitmentTransaction this_ptr_conv;
43877         this_ptr_conv.inner = untag_ptr(this_ptr);
43878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43880         this_ptr_conv.is_owned = false;
43881         LDKTransaction val_ref;
43882         val_ref.datalen = (*env)->GetArrayLength(env, val);
43883         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43884         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43885         val_ref.data_is_owned = true;
43886         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43887 }
43888
43889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43890         LDKBuiltCommitmentTransaction this_ptr_conv;
43891         this_ptr_conv.inner = untag_ptr(this_ptr);
43892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43894         this_ptr_conv.is_owned = false;
43895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43897         return ret_arr;
43898 }
43899
43900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43901         LDKBuiltCommitmentTransaction this_ptr_conv;
43902         this_ptr_conv.inner = untag_ptr(this_ptr);
43903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43905         this_ptr_conv.is_owned = false;
43906         LDKThirtyTwoBytes val_ref;
43907         CHECK((*env)->GetArrayLength(env, val) == 32);
43908         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43909         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43910 }
43911
43912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43913         LDKTransaction transaction_arg_ref;
43914         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43915         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43916         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43917         transaction_arg_ref.data_is_owned = true;
43918         LDKThirtyTwoBytes txid_arg_ref;
43919         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43920         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43921         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43922         int64_t ret_ref = 0;
43923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43924         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43925         return ret_ref;
43926 }
43927
43928 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43929         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43930         int64_t ret_ref = 0;
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43933         return ret_ref;
43934 }
43935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43936         LDKBuiltCommitmentTransaction arg_conv;
43937         arg_conv.inner = untag_ptr(arg);
43938         arg_conv.is_owned = ptr_is_owned(arg);
43939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43940         arg_conv.is_owned = false;
43941         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43942         return ret_conv;
43943 }
43944
43945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43946         LDKBuiltCommitmentTransaction orig_conv;
43947         orig_conv.inner = untag_ptr(orig);
43948         orig_conv.is_owned = ptr_is_owned(orig);
43949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43950         orig_conv.is_owned = false;
43951         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43952         int64_t ret_ref = 0;
43953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43955         return ret_ref;
43956 }
43957
43958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43959         LDKBuiltCommitmentTransaction obj_conv;
43960         obj_conv.inner = untag_ptr(obj);
43961         obj_conv.is_owned = ptr_is_owned(obj);
43962         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43963         obj_conv.is_owned = false;
43964         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43965         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43966         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43967         CVec_u8Z_free(ret_var);
43968         return ret_arr;
43969 }
43970
43971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43972         LDKu8slice ser_ref;
43973         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43974         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43975         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43976         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43977         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43978         return tag_ptr(ret_conv, true);
43979 }
43980
43981 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) {
43982         LDKBuiltCommitmentTransaction this_arg_conv;
43983         this_arg_conv.inner = untag_ptr(this_arg);
43984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43986         this_arg_conv.is_owned = false;
43987         LDKu8slice funding_redeemscript_ref;
43988         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43989         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43990         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43991         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43992         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43993         return ret_arr;
43994 }
43995
43996 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) {
43997         LDKBuiltCommitmentTransaction this_arg_conv;
43998         this_arg_conv.inner = untag_ptr(this_arg);
43999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44001         this_arg_conv.is_owned = false;
44002         uint8_t funding_key_arr[32];
44003         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44004         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44005         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44006         LDKu8slice funding_redeemscript_ref;
44007         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44008         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44009         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44010         (*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);
44011         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44012         return ret_arr;
44013 }
44014
44015 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) {
44016         LDKBuiltCommitmentTransaction this_arg_conv;
44017         this_arg_conv.inner = untag_ptr(this_arg);
44018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44020         this_arg_conv.is_owned = false;
44021         uint8_t funding_key_arr[32];
44022         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44023         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44024         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44025         LDKu8slice funding_redeemscript_ref;
44026         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44027         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44028         void* entropy_source_ptr = untag_ptr(entropy_source);
44029         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44030         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44031         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44032         (*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);
44033         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44034         return ret_arr;
44035 }
44036
44037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44038         LDKClosingTransaction this_obj_conv;
44039         this_obj_conv.inner = untag_ptr(this_obj);
44040         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44042         ClosingTransaction_free(this_obj_conv);
44043 }
44044
44045 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
44046         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
44047         int64_t ret_ref = 0;
44048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44050         return ret_ref;
44051 }
44052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44053         LDKClosingTransaction arg_conv;
44054         arg_conv.inner = untag_ptr(arg);
44055         arg_conv.is_owned = ptr_is_owned(arg);
44056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44057         arg_conv.is_owned = false;
44058         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
44059         return ret_conv;
44060 }
44061
44062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44063         LDKClosingTransaction orig_conv;
44064         orig_conv.inner = untag_ptr(orig);
44065         orig_conv.is_owned = ptr_is_owned(orig);
44066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44067         orig_conv.is_owned = false;
44068         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
44069         int64_t ret_ref = 0;
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44072         return ret_ref;
44073 }
44074
44075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
44076         LDKClosingTransaction o_conv;
44077         o_conv.inner = untag_ptr(o);
44078         o_conv.is_owned = ptr_is_owned(o);
44079         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44080         o_conv.is_owned = false;
44081         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
44082         return ret_conv;
44083 }
44084
44085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44086         LDKClosingTransaction a_conv;
44087         a_conv.inner = untag_ptr(a);
44088         a_conv.is_owned = ptr_is_owned(a);
44089         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44090         a_conv.is_owned = false;
44091         LDKClosingTransaction b_conv;
44092         b_conv.inner = untag_ptr(b);
44093         b_conv.is_owned = ptr_is_owned(b);
44094         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44095         b_conv.is_owned = false;
44096         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
44097         return ret_conv;
44098 }
44099
44100 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) {
44101         LDKCVec_u8Z to_holder_script_ref;
44102         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
44103         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
44104         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
44105         LDKCVec_u8Z to_counterparty_script_ref;
44106         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
44107         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
44108         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
44109         LDKOutPoint funding_outpoint_conv;
44110         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44111         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44112         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44113         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44114         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
44115         int64_t ret_ref = 0;
44116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44118         return ret_ref;
44119 }
44120
44121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44122         LDKClosingTransaction this_arg_conv;
44123         this_arg_conv.inner = untag_ptr(this_arg);
44124         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44126         this_arg_conv.is_owned = false;
44127         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
44128         int64_t ret_ref = 0;
44129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44130         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44131         return ret_ref;
44132 }
44133
44134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
44135         LDKClosingTransaction this_arg_conv;
44136         this_arg_conv.inner = untag_ptr(this_arg);
44137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44139         this_arg_conv.is_owned = false;
44140         LDKOutPoint funding_outpoint_conv;
44141         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44142         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44143         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44144         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44145         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
44146         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
44147         return tag_ptr(ret_conv, true);
44148 }
44149
44150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44151         LDKClosingTransaction this_arg_conv;
44152         this_arg_conv.inner = untag_ptr(this_arg);
44153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44155         this_arg_conv.is_owned = false;
44156         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
44157         return ret_conv;
44158 }
44159
44160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44161         LDKClosingTransaction this_arg_conv;
44162         this_arg_conv.inner = untag_ptr(this_arg);
44163         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44165         this_arg_conv.is_owned = false;
44166         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
44167         return ret_conv;
44168 }
44169
44170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(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         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
44177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44179         return ret_arr;
44180 }
44181
44182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44183         LDKClosingTransaction this_arg_conv;
44184         this_arg_conv.inner = untag_ptr(this_arg);
44185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44187         this_arg_conv.is_owned = false;
44188         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
44189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44191         return ret_arr;
44192 }
44193
44194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44195         LDKTrustedClosingTransaction this_obj_conv;
44196         this_obj_conv.inner = untag_ptr(this_obj);
44197         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44199         TrustedClosingTransaction_free(this_obj_conv);
44200 }
44201
44202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44203         LDKTrustedClosingTransaction 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         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&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         Transaction_free(ret_var);
44212         return ret_arr;
44213 }
44214
44215 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) {
44216         LDKTrustedClosingTransaction this_arg_conv;
44217         this_arg_conv.inner = untag_ptr(this_arg);
44218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44220         this_arg_conv.is_owned = false;
44221         LDKu8slice funding_redeemscript_ref;
44222         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44223         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44224         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44225         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44226         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44227         return ret_arr;
44228 }
44229
44230 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) {
44231         LDKTrustedClosingTransaction this_arg_conv;
44232         this_arg_conv.inner = untag_ptr(this_arg);
44233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44235         this_arg_conv.is_owned = false;
44236         uint8_t funding_key_arr[32];
44237         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44238         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44239         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44240         LDKu8slice funding_redeemscript_ref;
44241         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44242         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44243         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44245         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44246         return ret_arr;
44247 }
44248
44249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44250         LDKCommitmentTransaction this_obj_conv;
44251         this_obj_conv.inner = untag_ptr(this_obj);
44252         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44254         CommitmentTransaction_free(this_obj_conv);
44255 }
44256
44257 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
44258         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
44259         int64_t ret_ref = 0;
44260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44262         return ret_ref;
44263 }
44264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44265         LDKCommitmentTransaction arg_conv;
44266         arg_conv.inner = untag_ptr(arg);
44267         arg_conv.is_owned = ptr_is_owned(arg);
44268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44269         arg_conv.is_owned = false;
44270         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
44271         return ret_conv;
44272 }
44273
44274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44275         LDKCommitmentTransaction orig_conv;
44276         orig_conv.inner = untag_ptr(orig);
44277         orig_conv.is_owned = ptr_is_owned(orig);
44278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44279         orig_conv.is_owned = false;
44280         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
44281         int64_t ret_ref = 0;
44282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44283         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44284         return ret_ref;
44285 }
44286
44287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
44288         LDKCommitmentTransaction obj_conv;
44289         obj_conv.inner = untag_ptr(obj);
44290         obj_conv.is_owned = ptr_is_owned(obj);
44291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44292         obj_conv.is_owned = false;
44293         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
44294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44296         CVec_u8Z_free(ret_var);
44297         return ret_arr;
44298 }
44299
44300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44301         LDKu8slice ser_ref;
44302         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44303         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44304         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
44305         *ret_conv = CommitmentTransaction_read(ser_ref);
44306         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44307         return tag_ptr(ret_conv, true);
44308 }
44309
44310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
44311         LDKCommitmentTransaction this_arg_conv;
44312         this_arg_conv.inner = untag_ptr(this_arg);
44313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44315         this_arg_conv.is_owned = false;
44316         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
44317         return ret_conv;
44318 }
44319
44320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44321         LDKCommitmentTransaction this_arg_conv;
44322         this_arg_conv.inner = untag_ptr(this_arg);
44323         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44325         this_arg_conv.is_owned = false;
44326         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
44327         return ret_conv;
44328 }
44329
44330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(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_to_countersignatory_value_sat(&this_arg_conv);
44337         return ret_conv;
44338 }
44339
44340 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(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         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
44347         return ret_conv;
44348 }
44349
44350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(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         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
44357         int64_t ret_ref = 0;
44358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44360         return ret_ref;
44361 }
44362
44363 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) {
44364         LDKCommitmentTransaction this_arg_conv;
44365         this_arg_conv.inner = untag_ptr(this_arg);
44366         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44368         this_arg_conv.is_owned = false;
44369         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44370         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44371         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44372         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44373         channel_parameters_conv.is_owned = false;
44374         LDKChannelPublicKeys broadcaster_keys_conv;
44375         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
44376         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
44377         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
44378         broadcaster_keys_conv.is_owned = false;
44379         LDKChannelPublicKeys countersignatory_keys_conv;
44380         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
44381         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
44382         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
44383         countersignatory_keys_conv.is_owned = false;
44384         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
44385         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
44386         return tag_ptr(ret_conv, true);
44387 }
44388
44389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44390         LDKTrustedCommitmentTransaction this_obj_conv;
44391         this_obj_conv.inner = untag_ptr(this_obj);
44392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44394         TrustedCommitmentTransaction_free(this_obj_conv);
44395 }
44396
44397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
44398         LDKTrustedCommitmentTransaction this_arg_conv;
44399         this_arg_conv.inner = untag_ptr(this_arg);
44400         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44402         this_arg_conv.is_owned = false;
44403         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
44405         return ret_arr;
44406 }
44407
44408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44409         LDKTrustedCommitmentTransaction this_arg_conv;
44410         this_arg_conv.inner = untag_ptr(this_arg);
44411         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44413         this_arg_conv.is_owned = false;
44414         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
44415         int64_t ret_ref = 0;
44416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44418         return ret_ref;
44419 }
44420
44421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
44422         LDKTrustedCommitmentTransaction this_arg_conv;
44423         this_arg_conv.inner = untag_ptr(this_arg);
44424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44426         this_arg_conv.is_owned = false;
44427         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
44428         int64_t ret_ref = 0;
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44431         return ret_ref;
44432 }
44433
44434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
44435         LDKTrustedCommitmentTransaction this_arg_conv;
44436         this_arg_conv.inner = untag_ptr(this_arg);
44437         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44439         this_arg_conv.is_owned = false;
44440         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
44441         return ret_conv;
44442 }
44443
44444 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) {
44445         LDKTrustedCommitmentTransaction this_arg_conv;
44446         this_arg_conv.inner = untag_ptr(this_arg);
44447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44449         this_arg_conv.is_owned = false;
44450         uint8_t htlc_base_key_arr[32];
44451         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
44452         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
44453         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
44454         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44455         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44456         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44457         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44458         channel_parameters_conv.is_owned = false;
44459         void* entropy_source_ptr = untag_ptr(entropy_source);
44460         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44461         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44462         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
44463         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
44464         return tag_ptr(ret_conv, true);
44465 }
44466
44467 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) {
44468         LDKPublicKey broadcaster_payment_basepoint_ref;
44469         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
44470         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
44471         LDKPublicKey countersignatory_payment_basepoint_ref;
44472         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
44473         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
44474         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
44475         return ret_conv;
44476 }
44477
44478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44479         LDKInitFeatures a_conv;
44480         a_conv.inner = untag_ptr(a);
44481         a_conv.is_owned = ptr_is_owned(a);
44482         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44483         a_conv.is_owned = false;
44484         LDKInitFeatures b_conv;
44485         b_conv.inner = untag_ptr(b);
44486         b_conv.is_owned = ptr_is_owned(b);
44487         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44488         b_conv.is_owned = false;
44489         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
44490         return ret_conv;
44491 }
44492
44493 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44494         LDKNodeFeatures a_conv;
44495         a_conv.inner = untag_ptr(a);
44496         a_conv.is_owned = ptr_is_owned(a);
44497         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44498         a_conv.is_owned = false;
44499         LDKNodeFeatures b_conv;
44500         b_conv.inner = untag_ptr(b);
44501         b_conv.is_owned = ptr_is_owned(b);
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44503         b_conv.is_owned = false;
44504         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
44505         return ret_conv;
44506 }
44507
44508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44509         LDKChannelFeatures a_conv;
44510         a_conv.inner = untag_ptr(a);
44511         a_conv.is_owned = ptr_is_owned(a);
44512         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44513         a_conv.is_owned = false;
44514         LDKChannelFeatures b_conv;
44515         b_conv.inner = untag_ptr(b);
44516         b_conv.is_owned = ptr_is_owned(b);
44517         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44518         b_conv.is_owned = false;
44519         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
44520         return ret_conv;
44521 }
44522
44523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44524         LDKInvoiceFeatures a_conv;
44525         a_conv.inner = untag_ptr(a);
44526         a_conv.is_owned = ptr_is_owned(a);
44527         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44528         a_conv.is_owned = false;
44529         LDKInvoiceFeatures b_conv;
44530         b_conv.inner = untag_ptr(b);
44531         b_conv.is_owned = ptr_is_owned(b);
44532         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44533         b_conv.is_owned = false;
44534         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
44535         return ret_conv;
44536 }
44537
44538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44539         LDKOfferFeatures a_conv;
44540         a_conv.inner = untag_ptr(a);
44541         a_conv.is_owned = ptr_is_owned(a);
44542         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44543         a_conv.is_owned = false;
44544         LDKOfferFeatures b_conv;
44545         b_conv.inner = untag_ptr(b);
44546         b_conv.is_owned = ptr_is_owned(b);
44547         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44548         b_conv.is_owned = false;
44549         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
44550         return ret_conv;
44551 }
44552
44553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44554         LDKInvoiceRequestFeatures a_conv;
44555         a_conv.inner = untag_ptr(a);
44556         a_conv.is_owned = ptr_is_owned(a);
44557         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44558         a_conv.is_owned = false;
44559         LDKInvoiceRequestFeatures b_conv;
44560         b_conv.inner = untag_ptr(b);
44561         b_conv.is_owned = ptr_is_owned(b);
44562         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44563         b_conv.is_owned = false;
44564         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
44565         return ret_conv;
44566 }
44567
44568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44569         LDKBolt12InvoiceFeatures a_conv;
44570         a_conv.inner = untag_ptr(a);
44571         a_conv.is_owned = ptr_is_owned(a);
44572         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44573         a_conv.is_owned = false;
44574         LDKBolt12InvoiceFeatures b_conv;
44575         b_conv.inner = untag_ptr(b);
44576         b_conv.is_owned = ptr_is_owned(b);
44577         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44578         b_conv.is_owned = false;
44579         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
44580         return ret_conv;
44581 }
44582
44583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44584         LDKBlindedHopFeatures a_conv;
44585         a_conv.inner = untag_ptr(a);
44586         a_conv.is_owned = ptr_is_owned(a);
44587         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44588         a_conv.is_owned = false;
44589         LDKBlindedHopFeatures b_conv;
44590         b_conv.inner = untag_ptr(b);
44591         b_conv.is_owned = ptr_is_owned(b);
44592         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44593         b_conv.is_owned = false;
44594         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
44595         return ret_conv;
44596 }
44597
44598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44599         LDKChannelTypeFeatures a_conv;
44600         a_conv.inner = untag_ptr(a);
44601         a_conv.is_owned = ptr_is_owned(a);
44602         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44603         a_conv.is_owned = false;
44604         LDKChannelTypeFeatures b_conv;
44605         b_conv.inner = untag_ptr(b);
44606         b_conv.is_owned = ptr_is_owned(b);
44607         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44608         b_conv.is_owned = false;
44609         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
44610         return ret_conv;
44611 }
44612
44613 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
44614         LDKInitFeatures ret_var = InitFeatures_clone(arg);
44615         int64_t ret_ref = 0;
44616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44618         return ret_ref;
44619 }
44620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44621         LDKInitFeatures arg_conv;
44622         arg_conv.inner = untag_ptr(arg);
44623         arg_conv.is_owned = ptr_is_owned(arg);
44624         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44625         arg_conv.is_owned = false;
44626         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
44627         return ret_conv;
44628 }
44629
44630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44631         LDKInitFeatures orig_conv;
44632         orig_conv.inner = untag_ptr(orig);
44633         orig_conv.is_owned = ptr_is_owned(orig);
44634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44635         orig_conv.is_owned = false;
44636         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
44637         int64_t ret_ref = 0;
44638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44640         return ret_ref;
44641 }
44642
44643 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
44644         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
44645         int64_t ret_ref = 0;
44646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44648         return ret_ref;
44649 }
44650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44651         LDKNodeFeatures arg_conv;
44652         arg_conv.inner = untag_ptr(arg);
44653         arg_conv.is_owned = ptr_is_owned(arg);
44654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44655         arg_conv.is_owned = false;
44656         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
44657         return ret_conv;
44658 }
44659
44660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44661         LDKNodeFeatures orig_conv;
44662         orig_conv.inner = untag_ptr(orig);
44663         orig_conv.is_owned = ptr_is_owned(orig);
44664         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44665         orig_conv.is_owned = false;
44666         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
44667         int64_t ret_ref = 0;
44668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44670         return ret_ref;
44671 }
44672
44673 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
44674         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
44675         int64_t ret_ref = 0;
44676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44678         return ret_ref;
44679 }
44680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44681         LDKChannelFeatures arg_conv;
44682         arg_conv.inner = untag_ptr(arg);
44683         arg_conv.is_owned = ptr_is_owned(arg);
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44685         arg_conv.is_owned = false;
44686         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
44687         return ret_conv;
44688 }
44689
44690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44691         LDKChannelFeatures orig_conv;
44692         orig_conv.inner = untag_ptr(orig);
44693         orig_conv.is_owned = ptr_is_owned(orig);
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44695         orig_conv.is_owned = false;
44696         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
44697         int64_t ret_ref = 0;
44698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44700         return ret_ref;
44701 }
44702
44703 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
44704         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
44705         int64_t ret_ref = 0;
44706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44708         return ret_ref;
44709 }
44710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44711         LDKInvoiceFeatures arg_conv;
44712         arg_conv.inner = untag_ptr(arg);
44713         arg_conv.is_owned = ptr_is_owned(arg);
44714         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44715         arg_conv.is_owned = false;
44716         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
44717         return ret_conv;
44718 }
44719
44720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44721         LDKInvoiceFeatures orig_conv;
44722         orig_conv.inner = untag_ptr(orig);
44723         orig_conv.is_owned = ptr_is_owned(orig);
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44725         orig_conv.is_owned = false;
44726         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
44727         int64_t ret_ref = 0;
44728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44730         return ret_ref;
44731 }
44732
44733 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
44734         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
44735         int64_t ret_ref = 0;
44736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44738         return ret_ref;
44739 }
44740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44741         LDKOfferFeatures arg_conv;
44742         arg_conv.inner = untag_ptr(arg);
44743         arg_conv.is_owned = ptr_is_owned(arg);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44745         arg_conv.is_owned = false;
44746         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
44747         return ret_conv;
44748 }
44749
44750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44751         LDKOfferFeatures orig_conv;
44752         orig_conv.inner = untag_ptr(orig);
44753         orig_conv.is_owned = ptr_is_owned(orig);
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44755         orig_conv.is_owned = false;
44756         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
44757         int64_t ret_ref = 0;
44758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44760         return ret_ref;
44761 }
44762
44763 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
44764         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
44765         int64_t ret_ref = 0;
44766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44768         return ret_ref;
44769 }
44770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44771         LDKInvoiceRequestFeatures arg_conv;
44772         arg_conv.inner = untag_ptr(arg);
44773         arg_conv.is_owned = ptr_is_owned(arg);
44774         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44775         arg_conv.is_owned = false;
44776         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
44777         return ret_conv;
44778 }
44779
44780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44781         LDKInvoiceRequestFeatures orig_conv;
44782         orig_conv.inner = untag_ptr(orig);
44783         orig_conv.is_owned = ptr_is_owned(orig);
44784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44785         orig_conv.is_owned = false;
44786         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
44787         int64_t ret_ref = 0;
44788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44790         return ret_ref;
44791 }
44792
44793 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
44794         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
44795         int64_t ret_ref = 0;
44796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44798         return ret_ref;
44799 }
44800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44801         LDKBolt12InvoiceFeatures arg_conv;
44802         arg_conv.inner = untag_ptr(arg);
44803         arg_conv.is_owned = ptr_is_owned(arg);
44804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44805         arg_conv.is_owned = false;
44806         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
44807         return ret_conv;
44808 }
44809
44810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44811         LDKBolt12InvoiceFeatures orig_conv;
44812         orig_conv.inner = untag_ptr(orig);
44813         orig_conv.is_owned = ptr_is_owned(orig);
44814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44815         orig_conv.is_owned = false;
44816         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
44817         int64_t ret_ref = 0;
44818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44820         return ret_ref;
44821 }
44822
44823 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
44824         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
44825         int64_t ret_ref = 0;
44826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44828         return ret_ref;
44829 }
44830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44831         LDKBlindedHopFeatures arg_conv;
44832         arg_conv.inner = untag_ptr(arg);
44833         arg_conv.is_owned = ptr_is_owned(arg);
44834         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44835         arg_conv.is_owned = false;
44836         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
44837         return ret_conv;
44838 }
44839
44840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44841         LDKBlindedHopFeatures orig_conv;
44842         orig_conv.inner = untag_ptr(orig);
44843         orig_conv.is_owned = ptr_is_owned(orig);
44844         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44845         orig_conv.is_owned = false;
44846         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
44847         int64_t ret_ref = 0;
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44850         return ret_ref;
44851 }
44852
44853 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
44854         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
44855         int64_t ret_ref = 0;
44856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44858         return ret_ref;
44859 }
44860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44861         LDKChannelTypeFeatures arg_conv;
44862         arg_conv.inner = untag_ptr(arg);
44863         arg_conv.is_owned = ptr_is_owned(arg);
44864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44865         arg_conv.is_owned = false;
44866         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
44867         return ret_conv;
44868 }
44869
44870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44871         LDKChannelTypeFeatures orig_conv;
44872         orig_conv.inner = untag_ptr(orig);
44873         orig_conv.is_owned = ptr_is_owned(orig);
44874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44875         orig_conv.is_owned = false;
44876         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
44877         int64_t ret_ref = 0;
44878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44880         return ret_ref;
44881 }
44882
44883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44884         LDKInitFeatures this_obj_conv;
44885         this_obj_conv.inner = untag_ptr(this_obj);
44886         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44888         InitFeatures_free(this_obj_conv);
44889 }
44890
44891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44892         LDKNodeFeatures this_obj_conv;
44893         this_obj_conv.inner = untag_ptr(this_obj);
44894         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44896         NodeFeatures_free(this_obj_conv);
44897 }
44898
44899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44900         LDKChannelFeatures this_obj_conv;
44901         this_obj_conv.inner = untag_ptr(this_obj);
44902         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44904         ChannelFeatures_free(this_obj_conv);
44905 }
44906
44907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44908         LDKInvoiceFeatures this_obj_conv;
44909         this_obj_conv.inner = untag_ptr(this_obj);
44910         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44912         InvoiceFeatures_free(this_obj_conv);
44913 }
44914
44915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44916         LDKOfferFeatures this_obj_conv;
44917         this_obj_conv.inner = untag_ptr(this_obj);
44918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44920         OfferFeatures_free(this_obj_conv);
44921 }
44922
44923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44924         LDKInvoiceRequestFeatures this_obj_conv;
44925         this_obj_conv.inner = untag_ptr(this_obj);
44926         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44928         InvoiceRequestFeatures_free(this_obj_conv);
44929 }
44930
44931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44932         LDKBolt12InvoiceFeatures this_obj_conv;
44933         this_obj_conv.inner = untag_ptr(this_obj);
44934         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44936         Bolt12InvoiceFeatures_free(this_obj_conv);
44937 }
44938
44939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44940         LDKBlindedHopFeatures this_obj_conv;
44941         this_obj_conv.inner = untag_ptr(this_obj);
44942         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44944         BlindedHopFeatures_free(this_obj_conv);
44945 }
44946
44947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44948         LDKChannelTypeFeatures this_obj_conv;
44949         this_obj_conv.inner = untag_ptr(this_obj);
44950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44952         ChannelTypeFeatures_free(this_obj_conv);
44953 }
44954
44955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
44956         LDKInitFeatures ret_var = InitFeatures_empty();
44957         int64_t ret_ref = 0;
44958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44960         return ret_ref;
44961 }
44962
44963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44964         LDKInitFeatures this_arg_conv;
44965         this_arg_conv.inner = untag_ptr(this_arg);
44966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44968         this_arg_conv.is_owned = false;
44969         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
44970         return ret_conv;
44971 }
44972
44973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
44974         LDKNodeFeatures ret_var = NodeFeatures_empty();
44975         int64_t ret_ref = 0;
44976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44977         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44978         return ret_ref;
44979 }
44980
44981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44982         LDKNodeFeatures this_arg_conv;
44983         this_arg_conv.inner = untag_ptr(this_arg);
44984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44986         this_arg_conv.is_owned = false;
44987         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
44988         return ret_conv;
44989 }
44990
44991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
44992         LDKChannelFeatures ret_var = ChannelFeatures_empty();
44993         int64_t ret_ref = 0;
44994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44996         return ret_ref;
44997 }
44998
44999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45000         LDKChannelFeatures this_arg_conv;
45001         this_arg_conv.inner = untag_ptr(this_arg);
45002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45004         this_arg_conv.is_owned = false;
45005         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
45006         return ret_conv;
45007 }
45008
45009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45010         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
45011         int64_t ret_ref = 0;
45012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45014         return ret_ref;
45015 }
45016
45017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45018         LDKInvoiceFeatures this_arg_conv;
45019         this_arg_conv.inner = untag_ptr(this_arg);
45020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45022         this_arg_conv.is_owned = false;
45023         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45024         return ret_conv;
45025 }
45026
45027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
45028         LDKOfferFeatures ret_var = OfferFeatures_empty();
45029         int64_t ret_ref = 0;
45030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45032         return ret_ref;
45033 }
45034
45035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45036         LDKOfferFeatures this_arg_conv;
45037         this_arg_conv.inner = untag_ptr(this_arg);
45038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45040         this_arg_conv.is_owned = false;
45041         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
45042         return ret_conv;
45043 }
45044
45045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
45046         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
45047         int64_t ret_ref = 0;
45048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45050         return ret_ref;
45051 }
45052
45053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45054         LDKInvoiceRequestFeatures this_arg_conv;
45055         this_arg_conv.inner = untag_ptr(this_arg);
45056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45058         this_arg_conv.is_owned = false;
45059         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
45060         return ret_conv;
45061 }
45062
45063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45064         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
45065         int64_t ret_ref = 0;
45066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45068         return ret_ref;
45069 }
45070
45071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45072         LDKBolt12InvoiceFeatures this_arg_conv;
45073         this_arg_conv.inner = untag_ptr(this_arg);
45074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45076         this_arg_conv.is_owned = false;
45077         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45078         return ret_conv;
45079 }
45080
45081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1empty(JNIEnv *env, jclass clz) {
45082         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
45083         int64_t ret_ref = 0;
45084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45086         return ret_ref;
45087 }
45088
45089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45090         LDKBlindedHopFeatures this_arg_conv;
45091         this_arg_conv.inner = untag_ptr(this_arg);
45092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45094         this_arg_conv.is_owned = false;
45095         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
45096         return ret_conv;
45097 }
45098
45099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
45100         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
45101         int64_t ret_ref = 0;
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45104         return ret_ref;
45105 }
45106
45107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45108         LDKChannelTypeFeatures this_arg_conv;
45109         this_arg_conv.inner = untag_ptr(this_arg);
45110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45112         this_arg_conv.is_owned = false;
45113         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
45114         return ret_conv;
45115 }
45116
45117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45118         LDKInitFeatures obj_conv;
45119         obj_conv.inner = untag_ptr(obj);
45120         obj_conv.is_owned = ptr_is_owned(obj);
45121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45122         obj_conv.is_owned = false;
45123         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
45124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45126         CVec_u8Z_free(ret_var);
45127         return ret_arr;
45128 }
45129
45130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45131         LDKu8slice ser_ref;
45132         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45133         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45134         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
45135         *ret_conv = InitFeatures_read(ser_ref);
45136         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45137         return tag_ptr(ret_conv, true);
45138 }
45139
45140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45141         LDKChannelFeatures obj_conv;
45142         obj_conv.inner = untag_ptr(obj);
45143         obj_conv.is_owned = ptr_is_owned(obj);
45144         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45145         obj_conv.is_owned = false;
45146         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
45147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45149         CVec_u8Z_free(ret_var);
45150         return ret_arr;
45151 }
45152
45153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45154         LDKu8slice ser_ref;
45155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45157         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
45158         *ret_conv = ChannelFeatures_read(ser_ref);
45159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45160         return tag_ptr(ret_conv, true);
45161 }
45162
45163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45164         LDKNodeFeatures obj_conv;
45165         obj_conv.inner = untag_ptr(obj);
45166         obj_conv.is_owned = ptr_is_owned(obj);
45167         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45168         obj_conv.is_owned = false;
45169         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
45170         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45171         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45172         CVec_u8Z_free(ret_var);
45173         return ret_arr;
45174 }
45175
45176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45177         LDKu8slice ser_ref;
45178         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45179         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45180         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
45181         *ret_conv = NodeFeatures_read(ser_ref);
45182         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45183         return tag_ptr(ret_conv, true);
45184 }
45185
45186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45187         LDKInvoiceFeatures obj_conv;
45188         obj_conv.inner = untag_ptr(obj);
45189         obj_conv.is_owned = ptr_is_owned(obj);
45190         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45191         obj_conv.is_owned = false;
45192         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
45193         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45194         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45195         CVec_u8Z_free(ret_var);
45196         return ret_arr;
45197 }
45198
45199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45200         LDKu8slice ser_ref;
45201         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45202         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45203         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
45204         *ret_conv = InvoiceFeatures_read(ser_ref);
45205         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45206         return tag_ptr(ret_conv, true);
45207 }
45208
45209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45210         LDKBlindedHopFeatures obj_conv;
45211         obj_conv.inner = untag_ptr(obj);
45212         obj_conv.is_owned = ptr_is_owned(obj);
45213         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45214         obj_conv.is_owned = false;
45215         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
45216         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45217         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45218         CVec_u8Z_free(ret_var);
45219         return ret_arr;
45220 }
45221
45222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45223         LDKu8slice ser_ref;
45224         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45225         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45226         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
45227         *ret_conv = BlindedHopFeatures_read(ser_ref);
45228         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45229         return tag_ptr(ret_conv, true);
45230 }
45231
45232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45233         LDKChannelTypeFeatures obj_conv;
45234         obj_conv.inner = untag_ptr(obj);
45235         obj_conv.is_owned = ptr_is_owned(obj);
45236         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45237         obj_conv.is_owned = false;
45238         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
45239         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45240         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45241         CVec_u8Z_free(ret_var);
45242         return ret_arr;
45243 }
45244
45245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45246         LDKu8slice ser_ref;
45247         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45248         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45249         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
45250         *ret_conv = ChannelTypeFeatures_read(ser_ref);
45251         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45252         return tag_ptr(ret_conv, true);
45253 }
45254
45255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45256         LDKInitFeatures this_arg_conv;
45257         this_arg_conv.inner = untag_ptr(this_arg);
45258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45260         this_arg_conv.is_owned = false;
45261         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
45262 }
45263
45264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45265         LDKInitFeatures this_arg_conv;
45266         this_arg_conv.inner = untag_ptr(this_arg);
45267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45269         this_arg_conv.is_owned = false;
45270         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
45271 }
45272
45273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45274         LDKInitFeatures this_arg_conv;
45275         this_arg_conv.inner = untag_ptr(this_arg);
45276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45278         this_arg_conv.is_owned = false;
45279         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
45280         return ret_conv;
45281 }
45282
45283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45284         LDKNodeFeatures this_arg_conv;
45285         this_arg_conv.inner = untag_ptr(this_arg);
45286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45288         this_arg_conv.is_owned = false;
45289         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
45290 }
45291
45292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45293         LDKNodeFeatures this_arg_conv;
45294         this_arg_conv.inner = untag_ptr(this_arg);
45295         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45297         this_arg_conv.is_owned = false;
45298         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
45299 }
45300
45301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45302         LDKNodeFeatures this_arg_conv;
45303         this_arg_conv.inner = untag_ptr(this_arg);
45304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45306         this_arg_conv.is_owned = false;
45307         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
45308         return ret_conv;
45309 }
45310
45311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45312         LDKInitFeatures this_arg_conv;
45313         this_arg_conv.inner = untag_ptr(this_arg);
45314         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45316         this_arg_conv.is_owned = false;
45317         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
45318         return ret_conv;
45319 }
45320
45321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_data_loss_protect(&this_arg_conv);
45328         return ret_conv;
45329 }
45330
45331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(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         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
45338 }
45339
45340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45341         LDKInitFeatures this_arg_conv;
45342         this_arg_conv.inner = untag_ptr(this_arg);
45343         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45345         this_arg_conv.is_owned = false;
45346         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
45347 }
45348
45349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
45350         LDKInitFeatures this_arg_conv;
45351         this_arg_conv.inner = untag_ptr(this_arg);
45352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45354         this_arg_conv.is_owned = false;
45355         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
45356         return ret_conv;
45357 }
45358
45359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45360         LDKInitFeatures this_arg_conv;
45361         this_arg_conv.inner = untag_ptr(this_arg);
45362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45364         this_arg_conv.is_owned = false;
45365         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45366 }
45367
45368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45369         LDKInitFeatures this_arg_conv;
45370         this_arg_conv.inner = untag_ptr(this_arg);
45371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45373         this_arg_conv.is_owned = false;
45374         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45375 }
45376
45377 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45378         LDKInitFeatures this_arg_conv;
45379         this_arg_conv.inner = untag_ptr(this_arg);
45380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45382         this_arg_conv.is_owned = false;
45383         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45384         return ret_conv;
45385 }
45386
45387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45388         LDKNodeFeatures this_arg_conv;
45389         this_arg_conv.inner = untag_ptr(this_arg);
45390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45392         this_arg_conv.is_owned = false;
45393         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45394 }
45395
45396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45397         LDKNodeFeatures this_arg_conv;
45398         this_arg_conv.inner = untag_ptr(this_arg);
45399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45401         this_arg_conv.is_owned = false;
45402         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45403 }
45404
45405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45406         LDKNodeFeatures this_arg_conv;
45407         this_arg_conv.inner = untag_ptr(this_arg);
45408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45410         this_arg_conv.is_owned = false;
45411         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45412         return ret_conv;
45413 }
45414
45415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45416         LDKInitFeatures this_arg_conv;
45417         this_arg_conv.inner = untag_ptr(this_arg);
45418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45420         this_arg_conv.is_owned = false;
45421         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45422         return ret_conv;
45423 }
45424
45425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_upfront_shutdown_script(&this_arg_conv);
45432         return ret_conv;
45433 }
45434
45435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(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         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
45442 }
45443
45444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45445         LDKInitFeatures this_arg_conv;
45446         this_arg_conv.inner = untag_ptr(this_arg);
45447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45449         this_arg_conv.is_owned = false;
45450         InitFeatures_set_gossip_queries_required(&this_arg_conv);
45451 }
45452
45453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45454         LDKInitFeatures this_arg_conv;
45455         this_arg_conv.inner = untag_ptr(this_arg);
45456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45458         this_arg_conv.is_owned = false;
45459         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
45460         return ret_conv;
45461 }
45462
45463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45464         LDKNodeFeatures this_arg_conv;
45465         this_arg_conv.inner = untag_ptr(this_arg);
45466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45468         this_arg_conv.is_owned = false;
45469         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
45470 }
45471
45472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45473         LDKNodeFeatures this_arg_conv;
45474         this_arg_conv.inner = untag_ptr(this_arg);
45475         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45477         this_arg_conv.is_owned = false;
45478         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
45479 }
45480
45481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45482         LDKNodeFeatures this_arg_conv;
45483         this_arg_conv.inner = untag_ptr(this_arg);
45484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45486         this_arg_conv.is_owned = false;
45487         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
45488         return ret_conv;
45489 }
45490
45491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45492         LDKInitFeatures this_arg_conv;
45493         this_arg_conv.inner = untag_ptr(this_arg);
45494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45496         this_arg_conv.is_owned = false;
45497         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
45498         return ret_conv;
45499 }
45500
45501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_gossip_queries(&this_arg_conv);
45508         return ret_conv;
45509 }
45510
45511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(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         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
45518 }
45519
45520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45521         LDKInitFeatures this_arg_conv;
45522         this_arg_conv.inner = untag_ptr(this_arg);
45523         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45525         this_arg_conv.is_owned = false;
45526         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
45527 }
45528
45529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45530         LDKInitFeatures this_arg_conv;
45531         this_arg_conv.inner = untag_ptr(this_arg);
45532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45534         this_arg_conv.is_owned = false;
45535         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
45536         return ret_conv;
45537 }
45538
45539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45540         LDKNodeFeatures this_arg_conv;
45541         this_arg_conv.inner = untag_ptr(this_arg);
45542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45544         this_arg_conv.is_owned = false;
45545         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
45546 }
45547
45548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45549         LDKNodeFeatures this_arg_conv;
45550         this_arg_conv.inner = untag_ptr(this_arg);
45551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45553         this_arg_conv.is_owned = false;
45554         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
45555 }
45556
45557 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45558         LDKNodeFeatures this_arg_conv;
45559         this_arg_conv.inner = untag_ptr(this_arg);
45560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45562         this_arg_conv.is_owned = false;
45563         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
45564         return ret_conv;
45565 }
45566
45567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45568         LDKInvoiceFeatures this_arg_conv;
45569         this_arg_conv.inner = untag_ptr(this_arg);
45570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45572         this_arg_conv.is_owned = false;
45573         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
45574 }
45575
45576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45577         LDKInvoiceFeatures this_arg_conv;
45578         this_arg_conv.inner = untag_ptr(this_arg);
45579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45581         this_arg_conv.is_owned = false;
45582         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
45583 }
45584
45585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45586         LDKInvoiceFeatures this_arg_conv;
45587         this_arg_conv.inner = untag_ptr(this_arg);
45588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45590         this_arg_conv.is_owned = false;
45591         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
45592         return ret_conv;
45593 }
45594
45595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45596         LDKInitFeatures this_arg_conv;
45597         this_arg_conv.inner = untag_ptr(this_arg);
45598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45600         this_arg_conv.is_owned = false;
45601         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
45602         return ret_conv;
45603 }
45604
45605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45606         LDKNodeFeatures 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 = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
45612         return ret_conv;
45613 }
45614
45615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45616         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
45622         return ret_conv;
45623 }
45624
45625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45626         LDKInitFeatures 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         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
45632 }
45633
45634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45635         LDKInitFeatures this_arg_conv;
45636         this_arg_conv.inner = untag_ptr(this_arg);
45637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45639         this_arg_conv.is_owned = false;
45640         InitFeatures_set_static_remote_key_required(&this_arg_conv);
45641 }
45642
45643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45644         LDKInitFeatures this_arg_conv;
45645         this_arg_conv.inner = untag_ptr(this_arg);
45646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45648         this_arg_conv.is_owned = false;
45649         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
45650         return ret_conv;
45651 }
45652
45653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45654         LDKNodeFeatures this_arg_conv;
45655         this_arg_conv.inner = untag_ptr(this_arg);
45656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45658         this_arg_conv.is_owned = false;
45659         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
45660 }
45661
45662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45663         LDKNodeFeatures this_arg_conv;
45664         this_arg_conv.inner = untag_ptr(this_arg);
45665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45667         this_arg_conv.is_owned = false;
45668         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
45669 }
45670
45671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45672         LDKNodeFeatures this_arg_conv;
45673         this_arg_conv.inner = untag_ptr(this_arg);
45674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45676         this_arg_conv.is_owned = false;
45677         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
45678         return ret_conv;
45679 }
45680
45681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45682         LDKChannelTypeFeatures this_arg_conv;
45683         this_arg_conv.inner = untag_ptr(this_arg);
45684         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45686         this_arg_conv.is_owned = false;
45687         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
45688 }
45689
45690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45691         LDKChannelTypeFeatures this_arg_conv;
45692         this_arg_conv.inner = untag_ptr(this_arg);
45693         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45695         this_arg_conv.is_owned = false;
45696         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
45697 }
45698
45699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45700         LDKChannelTypeFeatures this_arg_conv;
45701         this_arg_conv.inner = untag_ptr(this_arg);
45702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45704         this_arg_conv.is_owned = false;
45705         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
45706         return ret_conv;
45707 }
45708
45709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45710         LDKInitFeatures this_arg_conv;
45711         this_arg_conv.inner = untag_ptr(this_arg);
45712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45714         this_arg_conv.is_owned = false;
45715         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
45716         return ret_conv;
45717 }
45718
45719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45720         LDKNodeFeatures 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 = NodeFeatures_requires_static_remote_key(&this_arg_conv);
45726         return ret_conv;
45727 }
45728
45729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45730         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
45736         return ret_conv;
45737 }
45738
45739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45740         LDKInitFeatures 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         InitFeatures_set_payment_secret_optional(&this_arg_conv);
45746 }
45747
45748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45749         LDKInitFeatures this_arg_conv;
45750         this_arg_conv.inner = untag_ptr(this_arg);
45751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45753         this_arg_conv.is_owned = false;
45754         InitFeatures_set_payment_secret_required(&this_arg_conv);
45755 }
45756
45757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45758         LDKInitFeatures this_arg_conv;
45759         this_arg_conv.inner = untag_ptr(this_arg);
45760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45762         this_arg_conv.is_owned = false;
45763         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
45764         return ret_conv;
45765 }
45766
45767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45768         LDKNodeFeatures this_arg_conv;
45769         this_arg_conv.inner = untag_ptr(this_arg);
45770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45772         this_arg_conv.is_owned = false;
45773         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
45774 }
45775
45776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45777         LDKNodeFeatures this_arg_conv;
45778         this_arg_conv.inner = untag_ptr(this_arg);
45779         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45781         this_arg_conv.is_owned = false;
45782         NodeFeatures_set_payment_secret_required(&this_arg_conv);
45783 }
45784
45785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45786         LDKNodeFeatures this_arg_conv;
45787         this_arg_conv.inner = untag_ptr(this_arg);
45788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45790         this_arg_conv.is_owned = false;
45791         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
45792         return ret_conv;
45793 }
45794
45795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45796         LDKInvoiceFeatures this_arg_conv;
45797         this_arg_conv.inner = untag_ptr(this_arg);
45798         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45800         this_arg_conv.is_owned = false;
45801         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
45802 }
45803
45804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45805         LDKInvoiceFeatures this_arg_conv;
45806         this_arg_conv.inner = untag_ptr(this_arg);
45807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45809         this_arg_conv.is_owned = false;
45810         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
45811 }
45812
45813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45814         LDKInvoiceFeatures this_arg_conv;
45815         this_arg_conv.inner = untag_ptr(this_arg);
45816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45818         this_arg_conv.is_owned = false;
45819         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
45820         return ret_conv;
45821 }
45822
45823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45824         LDKInitFeatures this_arg_conv;
45825         this_arg_conv.inner = untag_ptr(this_arg);
45826         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45828         this_arg_conv.is_owned = false;
45829         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
45830         return ret_conv;
45831 }
45832
45833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45834         LDKNodeFeatures 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 = NodeFeatures_requires_payment_secret(&this_arg_conv);
45840         return ret_conv;
45841 }
45842
45843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45844         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
45850         return ret_conv;
45851 }
45852
45853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45854         LDKInitFeatures 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         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
45860 }
45861
45862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45863         LDKInitFeatures this_arg_conv;
45864         this_arg_conv.inner = untag_ptr(this_arg);
45865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45867         this_arg_conv.is_owned = false;
45868         InitFeatures_set_basic_mpp_required(&this_arg_conv);
45869 }
45870
45871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45872         LDKInitFeatures this_arg_conv;
45873         this_arg_conv.inner = untag_ptr(this_arg);
45874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45876         this_arg_conv.is_owned = false;
45877         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
45878         return ret_conv;
45879 }
45880
45881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45882         LDKNodeFeatures this_arg_conv;
45883         this_arg_conv.inner = untag_ptr(this_arg);
45884         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45886         this_arg_conv.is_owned = false;
45887         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
45888 }
45889
45890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45891         LDKNodeFeatures this_arg_conv;
45892         this_arg_conv.inner = untag_ptr(this_arg);
45893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45895         this_arg_conv.is_owned = false;
45896         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
45897 }
45898
45899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45900         LDKNodeFeatures this_arg_conv;
45901         this_arg_conv.inner = untag_ptr(this_arg);
45902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45904         this_arg_conv.is_owned = false;
45905         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
45906         return ret_conv;
45907 }
45908
45909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45910         LDKInvoiceFeatures this_arg_conv;
45911         this_arg_conv.inner = untag_ptr(this_arg);
45912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45914         this_arg_conv.is_owned = false;
45915         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45916 }
45917
45918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45919         LDKInvoiceFeatures this_arg_conv;
45920         this_arg_conv.inner = untag_ptr(this_arg);
45921         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45923         this_arg_conv.is_owned = false;
45924         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45925 }
45926
45927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45928         LDKInvoiceFeatures this_arg_conv;
45929         this_arg_conv.inner = untag_ptr(this_arg);
45930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45932         this_arg_conv.is_owned = false;
45933         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45934         return ret_conv;
45935 }
45936
45937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45938         LDKBolt12InvoiceFeatures this_arg_conv;
45939         this_arg_conv.inner = untag_ptr(this_arg);
45940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45942         this_arg_conv.is_owned = false;
45943         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45944 }
45945
45946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45947         LDKBolt12InvoiceFeatures this_arg_conv;
45948         this_arg_conv.inner = untag_ptr(this_arg);
45949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45951         this_arg_conv.is_owned = false;
45952         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45953 }
45954
45955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45956         LDKBolt12InvoiceFeatures this_arg_conv;
45957         this_arg_conv.inner = untag_ptr(this_arg);
45958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45960         this_arg_conv.is_owned = false;
45961         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45962         return ret_conv;
45963 }
45964
45965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45966         LDKInitFeatures this_arg_conv;
45967         this_arg_conv.inner = untag_ptr(this_arg);
45968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45970         this_arg_conv.is_owned = false;
45971         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
45972         return ret_conv;
45973 }
45974
45975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45976         LDKNodeFeatures 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 = NodeFeatures_requires_basic_mpp(&this_arg_conv);
45982         return ret_conv;
45983 }
45984
45985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45986         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
45992         return ret_conv;
45993 }
45994
45995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45996         LDKBolt12InvoiceFeatures 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 = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46002         return ret_conv;
46003 }
46004
46005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46006         LDKInitFeatures 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         InitFeatures_set_wumbo_optional(&this_arg_conv);
46012 }
46013
46014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46015         LDKInitFeatures this_arg_conv;
46016         this_arg_conv.inner = untag_ptr(this_arg);
46017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46019         this_arg_conv.is_owned = false;
46020         InitFeatures_set_wumbo_required(&this_arg_conv);
46021 }
46022
46023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46024         LDKInitFeatures this_arg_conv;
46025         this_arg_conv.inner = untag_ptr(this_arg);
46026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46028         this_arg_conv.is_owned = false;
46029         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
46030         return ret_conv;
46031 }
46032
46033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46034         LDKNodeFeatures this_arg_conv;
46035         this_arg_conv.inner = untag_ptr(this_arg);
46036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46038         this_arg_conv.is_owned = false;
46039         NodeFeatures_set_wumbo_optional(&this_arg_conv);
46040 }
46041
46042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46043         LDKNodeFeatures this_arg_conv;
46044         this_arg_conv.inner = untag_ptr(this_arg);
46045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46047         this_arg_conv.is_owned = false;
46048         NodeFeatures_set_wumbo_required(&this_arg_conv);
46049 }
46050
46051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46052         LDKNodeFeatures this_arg_conv;
46053         this_arg_conv.inner = untag_ptr(this_arg);
46054         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46056         this_arg_conv.is_owned = false;
46057         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
46058         return ret_conv;
46059 }
46060
46061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46062         LDKInitFeatures this_arg_conv;
46063         this_arg_conv.inner = untag_ptr(this_arg);
46064         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46066         this_arg_conv.is_owned = false;
46067         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
46068         return ret_conv;
46069 }
46070
46071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_wumbo(&this_arg_conv);
46078         return ret_conv;
46079 }
46080
46081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(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         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46088 }
46089
46090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46091         LDKInitFeatures this_arg_conv;
46092         this_arg_conv.inner = untag_ptr(this_arg);
46093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46095         this_arg_conv.is_owned = false;
46096         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46097 }
46098
46099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46100         LDKInitFeatures this_arg_conv;
46101         this_arg_conv.inner = untag_ptr(this_arg);
46102         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46104         this_arg_conv.is_owned = false;
46105         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46106         return ret_conv;
46107 }
46108
46109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46110         LDKNodeFeatures this_arg_conv;
46111         this_arg_conv.inner = untag_ptr(this_arg);
46112         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46114         this_arg_conv.is_owned = false;
46115         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46116 }
46117
46118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46119         LDKNodeFeatures this_arg_conv;
46120         this_arg_conv.inner = untag_ptr(this_arg);
46121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46123         this_arg_conv.is_owned = false;
46124         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46125 }
46126
46127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46128         LDKNodeFeatures this_arg_conv;
46129         this_arg_conv.inner = untag_ptr(this_arg);
46130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46132         this_arg_conv.is_owned = false;
46133         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46134         return ret_conv;
46135 }
46136
46137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46138         LDKChannelTypeFeatures this_arg_conv;
46139         this_arg_conv.inner = untag_ptr(this_arg);
46140         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46142         this_arg_conv.is_owned = false;
46143         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46144 }
46145
46146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46147         LDKChannelTypeFeatures this_arg_conv;
46148         this_arg_conv.inner = untag_ptr(this_arg);
46149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46151         this_arg_conv.is_owned = false;
46152         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46153 }
46154
46155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46156         LDKChannelTypeFeatures this_arg_conv;
46157         this_arg_conv.inner = untag_ptr(this_arg);
46158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46160         this_arg_conv.is_owned = false;
46161         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46162         return ret_conv;
46163 }
46164
46165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46166         LDKInitFeatures this_arg_conv;
46167         this_arg_conv.inner = untag_ptr(this_arg);
46168         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46170         this_arg_conv.is_owned = false;
46171         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46172         return ret_conv;
46173 }
46174
46175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46176         LDKNodeFeatures 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 = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46182         return ret_conv;
46183 }
46184
46185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46186         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46192         return ret_conv;
46193 }
46194
46195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46196         LDKInitFeatures 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         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46202 }
46203
46204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46205         LDKInitFeatures this_arg_conv;
46206         this_arg_conv.inner = untag_ptr(this_arg);
46207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46209         this_arg_conv.is_owned = false;
46210         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46211 }
46212
46213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46214         LDKInitFeatures this_arg_conv;
46215         this_arg_conv.inner = untag_ptr(this_arg);
46216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46218         this_arg_conv.is_owned = false;
46219         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46220         return ret_conv;
46221 }
46222
46223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46224         LDKNodeFeatures this_arg_conv;
46225         this_arg_conv.inner = untag_ptr(this_arg);
46226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46228         this_arg_conv.is_owned = false;
46229         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46230 }
46231
46232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46233         LDKNodeFeatures this_arg_conv;
46234         this_arg_conv.inner = untag_ptr(this_arg);
46235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46237         this_arg_conv.is_owned = false;
46238         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46239 }
46240
46241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46242         LDKNodeFeatures this_arg_conv;
46243         this_arg_conv.inner = untag_ptr(this_arg);
46244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46246         this_arg_conv.is_owned = false;
46247         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46248         return ret_conv;
46249 }
46250
46251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46252         LDKInitFeatures this_arg_conv;
46253         this_arg_conv.inner = untag_ptr(this_arg);
46254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46256         this_arg_conv.is_owned = false;
46257         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46258         return ret_conv;
46259 }
46260
46261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_shutdown_anysegwit(&this_arg_conv);
46268         return ret_conv;
46269 }
46270
46271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(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         InitFeatures_set_onion_messages_optional(&this_arg_conv);
46278 }
46279
46280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46281         LDKInitFeatures this_arg_conv;
46282         this_arg_conv.inner = untag_ptr(this_arg);
46283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46285         this_arg_conv.is_owned = false;
46286         InitFeatures_set_onion_messages_required(&this_arg_conv);
46287 }
46288
46289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46290         LDKInitFeatures this_arg_conv;
46291         this_arg_conv.inner = untag_ptr(this_arg);
46292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46294         this_arg_conv.is_owned = false;
46295         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
46296         return ret_conv;
46297 }
46298
46299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46300         LDKNodeFeatures this_arg_conv;
46301         this_arg_conv.inner = untag_ptr(this_arg);
46302         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46304         this_arg_conv.is_owned = false;
46305         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
46306 }
46307
46308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46309         LDKNodeFeatures this_arg_conv;
46310         this_arg_conv.inner = untag_ptr(this_arg);
46311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46313         this_arg_conv.is_owned = false;
46314         NodeFeatures_set_onion_messages_required(&this_arg_conv);
46315 }
46316
46317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46318         LDKNodeFeatures this_arg_conv;
46319         this_arg_conv.inner = untag_ptr(this_arg);
46320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46322         this_arg_conv.is_owned = false;
46323         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
46324         return ret_conv;
46325 }
46326
46327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46328         LDKInitFeatures this_arg_conv;
46329         this_arg_conv.inner = untag_ptr(this_arg);
46330         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46332         this_arg_conv.is_owned = false;
46333         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
46334         return ret_conv;
46335 }
46336
46337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_onion_messages(&this_arg_conv);
46344         return ret_conv;
46345 }
46346
46347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(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         InitFeatures_set_channel_type_optional(&this_arg_conv);
46354 }
46355
46356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46357         LDKInitFeatures this_arg_conv;
46358         this_arg_conv.inner = untag_ptr(this_arg);
46359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46361         this_arg_conv.is_owned = false;
46362         InitFeatures_set_channel_type_required(&this_arg_conv);
46363 }
46364
46365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46366         LDKInitFeatures this_arg_conv;
46367         this_arg_conv.inner = untag_ptr(this_arg);
46368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46370         this_arg_conv.is_owned = false;
46371         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
46372         return ret_conv;
46373 }
46374
46375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46376         LDKNodeFeatures this_arg_conv;
46377         this_arg_conv.inner = untag_ptr(this_arg);
46378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46380         this_arg_conv.is_owned = false;
46381         NodeFeatures_set_channel_type_optional(&this_arg_conv);
46382 }
46383
46384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46385         LDKNodeFeatures this_arg_conv;
46386         this_arg_conv.inner = untag_ptr(this_arg);
46387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46389         this_arg_conv.is_owned = false;
46390         NodeFeatures_set_channel_type_required(&this_arg_conv);
46391 }
46392
46393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46394         LDKNodeFeatures this_arg_conv;
46395         this_arg_conv.inner = untag_ptr(this_arg);
46396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46398         this_arg_conv.is_owned = false;
46399         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
46400         return ret_conv;
46401 }
46402
46403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46404         LDKInitFeatures this_arg_conv;
46405         this_arg_conv.inner = untag_ptr(this_arg);
46406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46408         this_arg_conv.is_owned = false;
46409         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
46410         return ret_conv;
46411 }
46412
46413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_channel_type(&this_arg_conv);
46420         return ret_conv;
46421 }
46422
46423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(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         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
46430 }
46431
46432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46433         LDKInitFeatures this_arg_conv;
46434         this_arg_conv.inner = untag_ptr(this_arg);
46435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46437         this_arg_conv.is_owned = false;
46438         InitFeatures_set_scid_privacy_required(&this_arg_conv);
46439 }
46440
46441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46442         LDKInitFeatures this_arg_conv;
46443         this_arg_conv.inner = untag_ptr(this_arg);
46444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46446         this_arg_conv.is_owned = false;
46447         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
46448         return ret_conv;
46449 }
46450
46451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46452         LDKNodeFeatures this_arg_conv;
46453         this_arg_conv.inner = untag_ptr(this_arg);
46454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46456         this_arg_conv.is_owned = false;
46457         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
46458 }
46459
46460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46461         LDKNodeFeatures this_arg_conv;
46462         this_arg_conv.inner = untag_ptr(this_arg);
46463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46465         this_arg_conv.is_owned = false;
46466         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
46467 }
46468
46469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46470         LDKNodeFeatures this_arg_conv;
46471         this_arg_conv.inner = untag_ptr(this_arg);
46472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46474         this_arg_conv.is_owned = false;
46475         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
46476         return ret_conv;
46477 }
46478
46479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46480         LDKChannelTypeFeatures this_arg_conv;
46481         this_arg_conv.inner = untag_ptr(this_arg);
46482         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46484         this_arg_conv.is_owned = false;
46485         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
46486 }
46487
46488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46489         LDKChannelTypeFeatures this_arg_conv;
46490         this_arg_conv.inner = untag_ptr(this_arg);
46491         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46493         this_arg_conv.is_owned = false;
46494         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
46495 }
46496
46497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46498         LDKChannelTypeFeatures this_arg_conv;
46499         this_arg_conv.inner = untag_ptr(this_arg);
46500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46502         this_arg_conv.is_owned = false;
46503         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
46504         return ret_conv;
46505 }
46506
46507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46508         LDKInitFeatures this_arg_conv;
46509         this_arg_conv.inner = untag_ptr(this_arg);
46510         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46512         this_arg_conv.is_owned = false;
46513         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
46514         return ret_conv;
46515 }
46516
46517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46518         LDKNodeFeatures 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 = NodeFeatures_requires_scid_privacy(&this_arg_conv);
46524         return ret_conv;
46525 }
46526
46527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46528         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
46534         return ret_conv;
46535 }
46536
46537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46538         LDKInvoiceFeatures 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         InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
46544 }
46545
46546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46547         LDKInvoiceFeatures this_arg_conv;
46548         this_arg_conv.inner = untag_ptr(this_arg);
46549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46551         this_arg_conv.is_owned = false;
46552         InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
46553 }
46554
46555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46556         LDKInvoiceFeatures this_arg_conv;
46557         this_arg_conv.inner = untag_ptr(this_arg);
46558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46560         this_arg_conv.is_owned = false;
46561         jboolean ret_conv = InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
46562         return ret_conv;
46563 }
46564
46565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46566         LDKInvoiceFeatures this_arg_conv;
46567         this_arg_conv.inner = untag_ptr(this_arg);
46568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46570         this_arg_conv.is_owned = false;
46571         jboolean ret_conv = InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
46572         return ret_conv;
46573 }
46574
46575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46576         LDKInitFeatures 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         InitFeatures_set_zero_conf_optional(&this_arg_conv);
46582 }
46583
46584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46585         LDKInitFeatures this_arg_conv;
46586         this_arg_conv.inner = untag_ptr(this_arg);
46587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46589         this_arg_conv.is_owned = false;
46590         InitFeatures_set_zero_conf_required(&this_arg_conv);
46591 }
46592
46593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46594         LDKInitFeatures this_arg_conv;
46595         this_arg_conv.inner = untag_ptr(this_arg);
46596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46598         this_arg_conv.is_owned = false;
46599         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
46600         return ret_conv;
46601 }
46602
46603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46604         LDKNodeFeatures this_arg_conv;
46605         this_arg_conv.inner = untag_ptr(this_arg);
46606         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46608         this_arg_conv.is_owned = false;
46609         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
46610 }
46611
46612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46613         LDKNodeFeatures this_arg_conv;
46614         this_arg_conv.inner = untag_ptr(this_arg);
46615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46617         this_arg_conv.is_owned = false;
46618         NodeFeatures_set_zero_conf_required(&this_arg_conv);
46619 }
46620
46621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46622         LDKNodeFeatures this_arg_conv;
46623         this_arg_conv.inner = untag_ptr(this_arg);
46624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46626         this_arg_conv.is_owned = false;
46627         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
46628         return ret_conv;
46629 }
46630
46631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46632         LDKChannelTypeFeatures this_arg_conv;
46633         this_arg_conv.inner = untag_ptr(this_arg);
46634         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46636         this_arg_conv.is_owned = false;
46637         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
46638 }
46639
46640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46641         LDKChannelTypeFeatures this_arg_conv;
46642         this_arg_conv.inner = untag_ptr(this_arg);
46643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46645         this_arg_conv.is_owned = false;
46646         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
46647 }
46648
46649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46650         LDKChannelTypeFeatures this_arg_conv;
46651         this_arg_conv.inner = untag_ptr(this_arg);
46652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46654         this_arg_conv.is_owned = false;
46655         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
46656         return ret_conv;
46657 }
46658
46659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46660         LDKInitFeatures this_arg_conv;
46661         this_arg_conv.inner = untag_ptr(this_arg);
46662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46664         this_arg_conv.is_owned = false;
46665         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
46666         return ret_conv;
46667 }
46668
46669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46670         LDKNodeFeatures 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 = NodeFeatures_requires_zero_conf(&this_arg_conv);
46676         return ret_conv;
46677 }
46678
46679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46680         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
46686         return ret_conv;
46687 }
46688
46689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(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         NodeFeatures_set_keysend_optional(&this_arg_conv);
46696 }
46697
46698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46699         LDKNodeFeatures this_arg_conv;
46700         this_arg_conv.inner = untag_ptr(this_arg);
46701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46703         this_arg_conv.is_owned = false;
46704         NodeFeatures_set_keysend_required(&this_arg_conv);
46705 }
46706
46707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46708         LDKNodeFeatures this_arg_conv;
46709         this_arg_conv.inner = untag_ptr(this_arg);
46710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46712         this_arg_conv.is_owned = false;
46713         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
46714         return ret_conv;
46715 }
46716
46717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46718         LDKNodeFeatures this_arg_conv;
46719         this_arg_conv.inner = untag_ptr(this_arg);
46720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46722         this_arg_conv.is_owned = false;
46723         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
46724         return ret_conv;
46725 }
46726
46727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46728         LDKShutdownScript this_obj_conv;
46729         this_obj_conv.inner = untag_ptr(this_obj);
46730         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46732         ShutdownScript_free(this_obj_conv);
46733 }
46734
46735 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
46736         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
46737         int64_t ret_ref = 0;
46738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46740         return ret_ref;
46741 }
46742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46743         LDKShutdownScript arg_conv;
46744         arg_conv.inner = untag_ptr(arg);
46745         arg_conv.is_owned = ptr_is_owned(arg);
46746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46747         arg_conv.is_owned = false;
46748         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
46749         return ret_conv;
46750 }
46751
46752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46753         LDKShutdownScript orig_conv;
46754         orig_conv.inner = untag_ptr(orig);
46755         orig_conv.is_owned = ptr_is_owned(orig);
46756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46757         orig_conv.is_owned = false;
46758         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
46759         int64_t ret_ref = 0;
46760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46762         return ret_ref;
46763 }
46764
46765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46766         LDKShutdownScript a_conv;
46767         a_conv.inner = untag_ptr(a);
46768         a_conv.is_owned = ptr_is_owned(a);
46769         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46770         a_conv.is_owned = false;
46771         LDKShutdownScript b_conv;
46772         b_conv.inner = untag_ptr(b);
46773         b_conv.is_owned = ptr_is_owned(b);
46774         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46775         b_conv.is_owned = false;
46776         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
46777         return ret_conv;
46778 }
46779
46780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46781         LDKInvalidShutdownScript this_obj_conv;
46782         this_obj_conv.inner = untag_ptr(this_obj);
46783         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46785         InvalidShutdownScript_free(this_obj_conv);
46786 }
46787
46788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
46789         LDKInvalidShutdownScript this_ptr_conv;
46790         this_ptr_conv.inner = untag_ptr(this_ptr);
46791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46793         this_ptr_conv.is_owned = false;
46794         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
46795         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46796         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46797         return ret_arr;
46798 }
46799
46800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46801         LDKInvalidShutdownScript this_ptr_conv;
46802         this_ptr_conv.inner = untag_ptr(this_ptr);
46803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46805         this_ptr_conv.is_owned = false;
46806         LDKCVec_u8Z val_ref;
46807         val_ref.datalen = (*env)->GetArrayLength(env, val);
46808         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
46809         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
46810         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
46811 }
46812
46813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
46814         LDKCVec_u8Z script_arg_ref;
46815         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
46816         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
46817         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
46818         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
46819         int64_t ret_ref = 0;
46820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46822         return ret_ref;
46823 }
46824
46825 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
46826         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
46827         int64_t ret_ref = 0;
46828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46830         return ret_ref;
46831 }
46832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46833         LDKInvalidShutdownScript arg_conv;
46834         arg_conv.inner = untag_ptr(arg);
46835         arg_conv.is_owned = ptr_is_owned(arg);
46836         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46837         arg_conv.is_owned = false;
46838         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
46839         return ret_conv;
46840 }
46841
46842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46843         LDKInvalidShutdownScript orig_conv;
46844         orig_conv.inner = untag_ptr(orig);
46845         orig_conv.is_owned = ptr_is_owned(orig);
46846         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46847         orig_conv.is_owned = false;
46848         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
46849         int64_t ret_ref = 0;
46850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46851         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46852         return ret_ref;
46853 }
46854
46855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
46856         LDKShutdownScript obj_conv;
46857         obj_conv.inner = untag_ptr(obj);
46858         obj_conv.is_owned = ptr_is_owned(obj);
46859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46860         obj_conv.is_owned = false;
46861         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
46862         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46863         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46864         CVec_u8Z_free(ret_var);
46865         return ret_arr;
46866 }
46867
46868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46869         LDKu8slice ser_ref;
46870         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46871         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46872         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
46873         *ret_conv = ShutdownScript_read(ser_ref);
46874         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46875         return tag_ptr(ret_conv, true);
46876 }
46877
46878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
46879         uint8_t pubkey_hash_arr[20];
46880         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
46881         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
46882         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
46883         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
46884         int64_t ret_ref = 0;
46885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46887         return ret_ref;
46888 }
46889
46890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
46891         uint8_t script_hash_arr[32];
46892         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
46893         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
46894         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
46895         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
46896         int64_t ret_ref = 0;
46897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46899         return ret_ref;
46900 }
46901
46902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46903         
46904         LDKu8slice program_ref;
46905         program_ref.datalen = (*env)->GetArrayLength(env, program);
46906         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
46907         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
46908         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
46909         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
46910         return tag_ptr(ret_conv, true);
46911 }
46912
46913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
46914         LDKShutdownScript this_arg_conv;
46915         this_arg_conv.inner = untag_ptr(this_arg);
46916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46918         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
46919         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
46920         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46921         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46922         CVec_u8Z_free(ret_var);
46923         return ret_arr;
46924 }
46925
46926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
46927         LDKShutdownScript this_arg_conv;
46928         this_arg_conv.inner = untag_ptr(this_arg);
46929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46931         this_arg_conv.is_owned = false;
46932         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
46934         return ret_arr;
46935 }
46936
46937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
46938         LDKShutdownScript this_arg_conv;
46939         this_arg_conv.inner = untag_ptr(this_arg);
46940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46942         this_arg_conv.is_owned = false;
46943         LDKInitFeatures features_conv;
46944         features_conv.inner = untag_ptr(features);
46945         features_conv.is_owned = ptr_is_owned(features);
46946         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46947         features_conv.is_owned = false;
46948         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
46949         return ret_conv;
46950 }
46951
46952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46953         if (!ptr_is_owned(this_ptr)) return;
46954         void* this_ptr_ptr = untag_ptr(this_ptr);
46955         CHECK_ACCESS(this_ptr_ptr);
46956         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
46957         FREE(untag_ptr(this_ptr));
46958         Retry_free(this_ptr_conv);
46959 }
46960
46961 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
46962         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46963         *ret_copy = Retry_clone(arg);
46964         int64_t ret_ref = tag_ptr(ret_copy, true);
46965         return ret_ref;
46966 }
46967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46968         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
46969         int64_t ret_conv = Retry_clone_ptr(arg_conv);
46970         return ret_conv;
46971 }
46972
46973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46974         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
46975         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46976         *ret_copy = Retry_clone(orig_conv);
46977         int64_t ret_ref = tag_ptr(ret_copy, true);
46978         return ret_ref;
46979 }
46980
46981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
46982         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46983         *ret_copy = Retry_attempts(a);
46984         int64_t ret_ref = tag_ptr(ret_copy, true);
46985         return ret_ref;
46986 }
46987
46988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
46989         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46990         *ret_copy = Retry_timeout(a);
46991         int64_t ret_ref = tag_ptr(ret_copy, true);
46992         return ret_ref;
46993 }
46994
46995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46996         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
46997         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
46998         jboolean ret_conv = Retry_eq(a_conv, b_conv);
46999         return ret_conv;
47000 }
47001
47002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47003         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
47004         int64_t ret_conv = Retry_hash(o_conv);
47005         return ret_conv;
47006 }
47007
47008 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47009         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
47010         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_clone(orig_conv));
47011         return ret_conv;
47012 }
47013
47014 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1payment_1expired(JNIEnv *env, jclass clz) {
47015         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_payment_expired());
47016         return ret_conv;
47017 }
47018
47019 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1route_1not_1found(JNIEnv *env, jclass clz) {
47020         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_route_not_found());
47021         return ret_conv;
47022 }
47023
47024 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47025         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_duplicate_payment());
47026         return ret_conv;
47027 }
47028
47029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47030         if (!ptr_is_owned(this_ptr)) return;
47031         void* this_ptr_ptr = untag_ptr(this_ptr);
47032         CHECK_ACCESS(this_ptr_ptr);
47033         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
47034         FREE(untag_ptr(this_ptr));
47035         PaymentSendFailure_free(this_ptr_conv);
47036 }
47037
47038 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
47039         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47040         *ret_copy = PaymentSendFailure_clone(arg);
47041         int64_t ret_ref = tag_ptr(ret_copy, true);
47042         return ret_ref;
47043 }
47044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47045         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
47046         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
47047         return ret_conv;
47048 }
47049
47050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47051         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
47052         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47053         *ret_copy = PaymentSendFailure_clone(orig_conv);
47054         int64_t ret_ref = tag_ptr(ret_copy, true);
47055         return ret_ref;
47056 }
47057
47058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
47059         void* a_ptr = untag_ptr(a);
47060         CHECK_ACCESS(a_ptr);
47061         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
47062         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
47063         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47064         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
47065         int64_t ret_ref = tag_ptr(ret_copy, true);
47066         return ret_ref;
47067 }
47068
47069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
47070         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
47071         a_constr.datalen = (*env)->GetArrayLength(env, a);
47072         if (a_constr.datalen > 0)
47073                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47074         else
47075                 a_constr.data = NULL;
47076         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47077         for (size_t w = 0; w < a_constr.datalen; w++) {
47078                 int64_t a_conv_22 = a_vals[w];
47079                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
47080                 CHECK_ACCESS(a_conv_22_ptr);
47081                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
47082                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
47083                 a_constr.data[w] = a_conv_22_conv;
47084         }
47085         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47086         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47087         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
47088         int64_t ret_ref = tag_ptr(ret_copy, true);
47089         return ret_ref;
47090 }
47091
47092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
47093         LDKCVec_APIErrorZ a_constr;
47094         a_constr.datalen = (*env)->GetArrayLength(env, a);
47095         if (a_constr.datalen > 0)
47096                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
47097         else
47098                 a_constr.data = NULL;
47099         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47100         for (size_t k = 0; k < a_constr.datalen; k++) {
47101                 int64_t a_conv_10 = a_vals[k];
47102                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
47103                 CHECK_ACCESS(a_conv_10_ptr);
47104                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
47105                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
47106                 a_constr.data[k] = a_conv_10_conv;
47107         }
47108         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47109         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47110         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
47111         int64_t ret_ref = tag_ptr(ret_copy, true);
47112         return ret_ref;
47113 }
47114
47115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47116         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47117         *ret_copy = PaymentSendFailure_duplicate_payment();
47118         int64_t ret_ref = tag_ptr(ret_copy, true);
47119         return ret_ref;
47120 }
47121
47122 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) {
47123         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
47124         results_constr.datalen = (*env)->GetArrayLength(env, results);
47125         if (results_constr.datalen > 0)
47126                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47127         else
47128                 results_constr.data = NULL;
47129         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
47130         for (size_t w = 0; w < results_constr.datalen; w++) {
47131                 int64_t results_conv_22 = results_vals[w];
47132                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
47133                 CHECK_ACCESS(results_conv_22_ptr);
47134                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
47135                 results_constr.data[w] = results_conv_22_conv;
47136         }
47137         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
47138         LDKRouteParameters failed_paths_retry_conv;
47139         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
47140         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
47141         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
47142         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
47143         LDKThirtyTwoBytes payment_id_ref;
47144         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
47145         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
47146         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47147         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
47148         int64_t ret_ref = tag_ptr(ret_copy, true);
47149         return ret_ref;
47150 }
47151
47152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47153         LDKRecipientOnionFields this_obj_conv;
47154         this_obj_conv.inner = untag_ptr(this_obj);
47155         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47157         RecipientOnionFields_free(this_obj_conv);
47158 }
47159
47160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
47161         LDKRecipientOnionFields this_ptr_conv;
47162         this_ptr_conv.inner = untag_ptr(this_ptr);
47163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47165         this_ptr_conv.is_owned = false;
47166         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47167         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RecipientOnionFields_get_payment_secret(&this_ptr_conv).data);
47168         return ret_arr;
47169 }
47170
47171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47172         LDKRecipientOnionFields this_ptr_conv;
47173         this_ptr_conv.inner = untag_ptr(this_ptr);
47174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47176         this_ptr_conv.is_owned = false;
47177         LDKThirtyTwoBytes val_ref;
47178         CHECK((*env)->GetArrayLength(env, val) == 32);
47179         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47180         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_ref);
47181 }
47182
47183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr) {
47184         LDKRecipientOnionFields this_ptr_conv;
47185         this_ptr_conv.inner = untag_ptr(this_ptr);
47186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47188         this_ptr_conv.is_owned = false;
47189         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47190         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
47191         int64_t ret_ref = tag_ptr(ret_copy, true);
47192         return ret_ref;
47193 }
47194
47195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47196         LDKRecipientOnionFields this_ptr_conv;
47197         this_ptr_conv.inner = untag_ptr(this_ptr);
47198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47200         this_ptr_conv.is_owned = false;
47201         void* val_ptr = untag_ptr(val);
47202         CHECK_ACCESS(val_ptr);
47203         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
47204         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
47205         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
47206 }
47207
47208 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) {
47209         LDKThirtyTwoBytes payment_secret_arg_ref;
47210         CHECK((*env)->GetArrayLength(env, payment_secret_arg) == 32);
47211         (*env)->GetByteArrayRegion(env, payment_secret_arg, 0, 32, payment_secret_arg_ref.data);
47212         void* payment_metadata_arg_ptr = untag_ptr(payment_metadata_arg);
47213         CHECK_ACCESS(payment_metadata_arg_ptr);
47214         LDKCOption_CVec_u8ZZ payment_metadata_arg_conv = *(LDKCOption_CVec_u8ZZ*)(payment_metadata_arg_ptr);
47215         payment_metadata_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(payment_metadata_arg));
47216         LDKRecipientOnionFields ret_var = RecipientOnionFields_new(payment_secret_arg_ref, payment_metadata_arg_conv);
47217         int64_t ret_ref = 0;
47218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47220         return ret_ref;
47221 }
47222
47223 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
47224         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
47225         int64_t ret_ref = 0;
47226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47227         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47228         return ret_ref;
47229 }
47230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47231         LDKRecipientOnionFields arg_conv;
47232         arg_conv.inner = untag_ptr(arg);
47233         arg_conv.is_owned = ptr_is_owned(arg);
47234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47235         arg_conv.is_owned = false;
47236         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
47237         return ret_conv;
47238 }
47239
47240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47241         LDKRecipientOnionFields orig_conv;
47242         orig_conv.inner = untag_ptr(orig);
47243         orig_conv.is_owned = ptr_is_owned(orig);
47244         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47245         orig_conv.is_owned = false;
47246         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
47247         int64_t ret_ref = 0;
47248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47250         return ret_ref;
47251 }
47252
47253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47254         LDKRecipientOnionFields a_conv;
47255         a_conv.inner = untag_ptr(a);
47256         a_conv.is_owned = ptr_is_owned(a);
47257         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47258         a_conv.is_owned = false;
47259         LDKRecipientOnionFields b_conv;
47260         b_conv.inner = untag_ptr(b);
47261         b_conv.is_owned = ptr_is_owned(b);
47262         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47263         b_conv.is_owned = false;
47264         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
47265         return ret_conv;
47266 }
47267
47268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1write(JNIEnv *env, jclass clz, int64_t obj) {
47269         LDKRecipientOnionFields obj_conv;
47270         obj_conv.inner = untag_ptr(obj);
47271         obj_conv.is_owned = ptr_is_owned(obj);
47272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47273         obj_conv.is_owned = false;
47274         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
47275         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47276         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47277         CVec_u8Z_free(ret_var);
47278         return ret_arr;
47279 }
47280
47281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47282         LDKu8slice ser_ref;
47283         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47284         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47285         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
47286         *ret_conv = RecipientOnionFields_read(ser_ref);
47287         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47288         return tag_ptr(ret_conv, true);
47289 }
47290
47291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1secret_1only(JNIEnv *env, jclass clz, int8_tArray payment_secret) {
47292         LDKThirtyTwoBytes payment_secret_ref;
47293         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
47294         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
47295         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
47296         int64_t ret_ref = 0;
47297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47299         return ret_ref;
47300 }
47301
47302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1spontaneous_1empty(JNIEnv *env, jclass clz) {
47303         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
47304         int64_t ret_ref = 0;
47305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47307         return ret_ref;
47308 }
47309
47310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47311         if (!ptr_is_owned(this_ptr)) return;
47312         void* this_ptr_ptr = untag_ptr(this_ptr);
47313         CHECK_ACCESS(this_ptr_ptr);
47314         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
47315         FREE(untag_ptr(this_ptr));
47316         CustomMessageReader_free(this_ptr_conv);
47317 }
47318
47319 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
47320         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47321         *ret_ret = Type_clone(arg);
47322         return tag_ptr(ret_ret, true);
47323 }
47324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47325         void* arg_ptr = untag_ptr(arg);
47326         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47327         LDKType* arg_conv = (LDKType*)arg_ptr;
47328         int64_t ret_conv = Type_clone_ptr(arg_conv);
47329         return ret_conv;
47330 }
47331
47332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47333         void* orig_ptr = untag_ptr(orig);
47334         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47335         LDKType* orig_conv = (LDKType*)orig_ptr;
47336         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47337         *ret_ret = Type_clone(orig_conv);
47338         return tag_ptr(ret_ret, true);
47339 }
47340
47341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47342         if (!ptr_is_owned(this_ptr)) return;
47343         void* this_ptr_ptr = untag_ptr(this_ptr);
47344         CHECK_ACCESS(this_ptr_ptr);
47345         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
47346         FREE(untag_ptr(this_ptr));
47347         Type_free(this_ptr_conv);
47348 }
47349
47350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47351         LDKUnsignedInvoice this_obj_conv;
47352         this_obj_conv.inner = untag_ptr(this_obj);
47353         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47355         UnsignedInvoice_free(this_obj_conv);
47356 }
47357
47358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47359         LDKUnsignedInvoice this_arg_conv;
47360         this_arg_conv.inner = untag_ptr(this_arg);
47361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47363         this_arg_conv.is_owned = false;
47364         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedInvoice_signing_pubkey(&this_arg_conv).compressed_form);
47366         return ret_arr;
47367 }
47368
47369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47370         LDKBlindedPayInfo this_obj_conv;
47371         this_obj_conv.inner = untag_ptr(this_obj);
47372         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47374         BlindedPayInfo_free(this_obj_conv);
47375 }
47376
47377 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47378         LDKBlindedPayInfo this_ptr_conv;
47379         this_ptr_conv.inner = untag_ptr(this_ptr);
47380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47382         this_ptr_conv.is_owned = false;
47383         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
47384         return ret_conv;
47385 }
47386
47387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47388         LDKBlindedPayInfo this_ptr_conv;
47389         this_ptr_conv.inner = untag_ptr(this_ptr);
47390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47392         this_ptr_conv.is_owned = false;
47393         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
47394 }
47395
47396 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
47397         LDKBlindedPayInfo this_ptr_conv;
47398         this_ptr_conv.inner = untag_ptr(this_ptr);
47399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47401         this_ptr_conv.is_owned = false;
47402         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
47403         return ret_conv;
47404 }
47405
47406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47407         LDKBlindedPayInfo this_ptr_conv;
47408         this_ptr_conv.inner = untag_ptr(this_ptr);
47409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47411         this_ptr_conv.is_owned = false;
47412         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
47413 }
47414
47415 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47416         LDKBlindedPayInfo this_ptr_conv;
47417         this_ptr_conv.inner = untag_ptr(this_ptr);
47418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47420         this_ptr_conv.is_owned = false;
47421         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
47422         return ret_conv;
47423 }
47424
47425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47426         LDKBlindedPayInfo this_ptr_conv;
47427         this_ptr_conv.inner = untag_ptr(this_ptr);
47428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47430         this_ptr_conv.is_owned = false;
47431         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
47432 }
47433
47434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47435         LDKBlindedPayInfo this_ptr_conv;
47436         this_ptr_conv.inner = untag_ptr(this_ptr);
47437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47439         this_ptr_conv.is_owned = false;
47440         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
47441         return ret_conv;
47442 }
47443
47444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47445         LDKBlindedPayInfo this_ptr_conv;
47446         this_ptr_conv.inner = untag_ptr(this_ptr);
47447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47449         this_ptr_conv.is_owned = false;
47450         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
47451 }
47452
47453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47454         LDKBlindedPayInfo this_ptr_conv;
47455         this_ptr_conv.inner = untag_ptr(this_ptr);
47456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47458         this_ptr_conv.is_owned = false;
47459         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
47460         return ret_conv;
47461 }
47462
47463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47464         LDKBlindedPayInfo this_ptr_conv;
47465         this_ptr_conv.inner = untag_ptr(this_ptr);
47466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47468         this_ptr_conv.is_owned = false;
47469         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
47470 }
47471
47472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47473         LDKBlindedPayInfo this_ptr_conv;
47474         this_ptr_conv.inner = untag_ptr(this_ptr);
47475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47477         this_ptr_conv.is_owned = false;
47478         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
47479         int64_t ret_ref = 0;
47480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47482         return ret_ref;
47483 }
47484
47485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47486         LDKBlindedPayInfo this_ptr_conv;
47487         this_ptr_conv.inner = untag_ptr(this_ptr);
47488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47490         this_ptr_conv.is_owned = false;
47491         LDKBlindedHopFeatures val_conv;
47492         val_conv.inner = untag_ptr(val);
47493         val_conv.is_owned = ptr_is_owned(val);
47494         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47495         val_conv = BlindedHopFeatures_clone(&val_conv);
47496         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
47497 }
47498
47499 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) {
47500         LDKBlindedHopFeatures features_arg_conv;
47501         features_arg_conv.inner = untag_ptr(features_arg);
47502         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47503         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47504         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
47505         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);
47506         int64_t ret_ref = 0;
47507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47509         return ret_ref;
47510 }
47511
47512 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
47513         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
47514         int64_t ret_ref = 0;
47515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47517         return ret_ref;
47518 }
47519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47520         LDKBlindedPayInfo arg_conv;
47521         arg_conv.inner = untag_ptr(arg);
47522         arg_conv.is_owned = ptr_is_owned(arg);
47523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47524         arg_conv.is_owned = false;
47525         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
47526         return ret_conv;
47527 }
47528
47529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47530         LDKBlindedPayInfo orig_conv;
47531         orig_conv.inner = untag_ptr(orig);
47532         orig_conv.is_owned = ptr_is_owned(orig);
47533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47534         orig_conv.is_owned = false;
47535         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
47536         int64_t ret_ref = 0;
47537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47539         return ret_ref;
47540 }
47541
47542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1hash(JNIEnv *env, jclass clz, int64_t o) {
47543         LDKBlindedPayInfo o_conv;
47544         o_conv.inner = untag_ptr(o);
47545         o_conv.is_owned = ptr_is_owned(o);
47546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47547         o_conv.is_owned = false;
47548         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
47549         return ret_conv;
47550 }
47551
47552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47553         LDKBlindedPayInfo a_conv;
47554         a_conv.inner = untag_ptr(a);
47555         a_conv.is_owned = ptr_is_owned(a);
47556         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47557         a_conv.is_owned = false;
47558         LDKBlindedPayInfo b_conv;
47559         b_conv.inner = untag_ptr(b);
47560         b_conv.is_owned = ptr_is_owned(b);
47561         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47562         b_conv.is_owned = false;
47563         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
47564         return ret_conv;
47565 }
47566
47567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47568         LDKBlindedPayInfo obj_conv;
47569         obj_conv.inner = untag_ptr(obj);
47570         obj_conv.is_owned = ptr_is_owned(obj);
47571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47572         obj_conv.is_owned = false;
47573         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
47574         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47575         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47576         CVec_u8Z_free(ret_var);
47577         return ret_arr;
47578 }
47579
47580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47581         LDKu8slice ser_ref;
47582         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47583         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47584         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
47585         *ret_conv = BlindedPayInfo_read(ser_ref);
47586         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47587         return tag_ptr(ret_conv, true);
47588 }
47589
47590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47591         LDKUnsignedInvoiceRequest this_obj_conv;
47592         this_obj_conv.inner = untag_ptr(this_obj);
47593         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47595         UnsignedInvoiceRequest_free(this_obj_conv);
47596 }
47597
47598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47599         LDKInvoiceRequest this_obj_conv;
47600         this_obj_conv.inner = untag_ptr(this_obj);
47601         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47603         InvoiceRequest_free(this_obj_conv);
47604 }
47605
47606 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
47607         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
47608         int64_t ret_ref = 0;
47609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47610         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47611         return ret_ref;
47612 }
47613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47614         LDKInvoiceRequest arg_conv;
47615         arg_conv.inner = untag_ptr(arg);
47616         arg_conv.is_owned = ptr_is_owned(arg);
47617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47618         arg_conv.is_owned = false;
47619         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
47620         return ret_conv;
47621 }
47622
47623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47624         LDKInvoiceRequest orig_conv;
47625         orig_conv.inner = untag_ptr(orig);
47626         orig_conv.is_owned = ptr_is_owned(orig);
47627         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47628         orig_conv.is_owned = false;
47629         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
47630         int64_t ret_ref = 0;
47631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47633         return ret_ref;
47634 }
47635
47636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47637         LDKInvoiceRequest this_arg_conv;
47638         this_arg_conv.inner = untag_ptr(this_arg);
47639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47641         this_arg_conv.is_owned = false;
47642         LDKu8slice ret_var = InvoiceRequest_metadata(&this_arg_conv);
47643         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47644         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47645         return ret_arr;
47646 }
47647
47648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
47649         LDKInvoiceRequest this_arg_conv;
47650         this_arg_conv.inner = untag_ptr(this_arg);
47651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47653         this_arg_conv.is_owned = false;
47654         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, InvoiceRequest_chain(&this_arg_conv).data);
47656         return ret_arr;
47657 }
47658
47659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
47660         LDKInvoiceRequest this_arg_conv;
47661         this_arg_conv.inner = untag_ptr(this_arg);
47662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47664         this_arg_conv.is_owned = false;
47665         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47666         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
47667         int64_t ret_ref = tag_ptr(ret_copy, true);
47668         return ret_ref;
47669 }
47670
47671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47672         LDKInvoiceRequest this_arg_conv;
47673         this_arg_conv.inner = untag_ptr(this_arg);
47674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47676         this_arg_conv.is_owned = false;
47677         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_features(&this_arg_conv);
47678         int64_t ret_ref = 0;
47679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47681         return ret_ref;
47682 }
47683
47684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47685         LDKInvoiceRequest this_arg_conv;
47686         this_arg_conv.inner = untag_ptr(this_arg);
47687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47689         this_arg_conv.is_owned = false;
47690         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47691         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
47692         int64_t ret_ref = tag_ptr(ret_copy, true);
47693         return ret_ref;
47694 }
47695
47696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
47697         LDKInvoiceRequest this_arg_conv;
47698         this_arg_conv.inner = untag_ptr(this_arg);
47699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47701         this_arg_conv.is_owned = false;
47702         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, InvoiceRequest_payer_id(&this_arg_conv).compressed_form);
47704         return ret_arr;
47705 }
47706
47707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
47708         LDKInvoiceRequest this_arg_conv;
47709         this_arg_conv.inner = untag_ptr(this_arg);
47710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47712         this_arg_conv.is_owned = false;
47713         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
47714         int64_t ret_ref = 0;
47715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47717         return ret_ref;
47718 }
47719
47720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1write(JNIEnv *env, jclass clz, int64_t obj) {
47721         LDKInvoiceRequest obj_conv;
47722         obj_conv.inner = untag_ptr(obj);
47723         obj_conv.is_owned = ptr_is_owned(obj);
47724         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47725         obj_conv.is_owned = false;
47726         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
47727         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47728         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47729         CVec_u8Z_free(ret_var);
47730         return ret_arr;
47731 }
47732
47733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Offer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47734         LDKOffer this_obj_conv;
47735         this_obj_conv.inner = untag_ptr(this_obj);
47736         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47738         Offer_free(this_obj_conv);
47739 }
47740
47741 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
47742         LDKOffer ret_var = Offer_clone(arg);
47743         int64_t ret_ref = 0;
47744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47746         return ret_ref;
47747 }
47748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47749         LDKOffer arg_conv;
47750         arg_conv.inner = untag_ptr(arg);
47751         arg_conv.is_owned = ptr_is_owned(arg);
47752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47753         arg_conv.is_owned = false;
47754         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
47755         return ret_conv;
47756 }
47757
47758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47759         LDKOffer orig_conv;
47760         orig_conv.inner = untag_ptr(orig);
47761         orig_conv.is_owned = ptr_is_owned(orig);
47762         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47763         orig_conv.is_owned = false;
47764         LDKOffer ret_var = Offer_clone(&orig_conv);
47765         int64_t ret_ref = 0;
47766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47768         return ret_ref;
47769 }
47770
47771 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Offer_1chains(JNIEnv *env, jclass clz, int64_t this_arg) {
47772         LDKOffer this_arg_conv;
47773         this_arg_conv.inner = untag_ptr(this_arg);
47774         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47776         this_arg_conv.is_owned = false;
47777         LDKCVec_ChainHashZ ret_var = Offer_chains(&this_arg_conv);
47778         jobjectArray ret_arr = NULL;
47779         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
47780         ;
47781         for (size_t i = 0; i < ret_var.datalen; i++) {
47782                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
47783                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
47784                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
47785         }
47786         
47787         FREE(ret_var.data);
47788         return ret_arr;
47789 }
47790
47791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1supports_1chain(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray chain) {
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         LDKThirtyTwoBytes chain_ref;
47798         CHECK((*env)->GetArrayLength(env, chain) == 32);
47799         (*env)->GetByteArrayRegion(env, chain, 0, 32, chain_ref.data);
47800         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
47801         return ret_conv;
47802 }
47803
47804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47805         LDKOffer this_arg_conv;
47806         this_arg_conv.inner = untag_ptr(this_arg);
47807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47809         this_arg_conv.is_owned = false;
47810         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47811         *ret_copy = Offer_metadata(&this_arg_conv);
47812         int64_t ret_ref = tag_ptr(ret_copy, true);
47813         return ret_ref;
47814 }
47815
47816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
47817         LDKOffer this_arg_conv;
47818         this_arg_conv.inner = untag_ptr(this_arg);
47819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47821         this_arg_conv.is_owned = false;
47822         LDKAmount ret_var = Offer_amount(&this_arg_conv);
47823         int64_t ret_ref = 0;
47824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47826         return ret_ref;
47827 }
47828
47829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47830         LDKOffer this_arg_conv;
47831         this_arg_conv.inner = untag_ptr(this_arg);
47832         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47834         this_arg_conv.is_owned = false;
47835         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
47836         int64_t ret_ref = 0;
47837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47839         return ret_ref;
47840 }
47841
47842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47843         LDKOffer this_arg_conv;
47844         this_arg_conv.inner = untag_ptr(this_arg);
47845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47847         this_arg_conv.is_owned = false;
47848         LDKOfferFeatures ret_var = Offer_features(&this_arg_conv);
47849         int64_t ret_ref = 0;
47850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47851         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47852         return ret_ref;
47853 }
47854
47855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47856         LDKOffer this_arg_conv;
47857         this_arg_conv.inner = untag_ptr(this_arg);
47858         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47860         this_arg_conv.is_owned = false;
47861         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
47862         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
47863         int64_t ret_ref = tag_ptr(ret_copy, true);
47864         return ret_ref;
47865 }
47866
47867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47868         LDKOffer this_arg_conv;
47869         this_arg_conv.inner = untag_ptr(this_arg);
47870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47872         this_arg_conv.is_owned = false;
47873         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
47874         return ret_conv;
47875 }
47876
47877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
47878         LDKOffer this_arg_conv;
47879         this_arg_conv.inner = untag_ptr(this_arg);
47880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47882         this_arg_conv.is_owned = false;
47883         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
47884         int64_t ret_ref = 0;
47885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47887         return ret_ref;
47888 }
47889
47890 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
47891         LDKOffer this_arg_conv;
47892         this_arg_conv.inner = untag_ptr(this_arg);
47893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47895         this_arg_conv.is_owned = false;
47896         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
47897         int64_tArray ret_arr = NULL;
47898         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47899         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47900         for (size_t n = 0; n < ret_var.datalen; n++) {
47901                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
47902                 int64_t ret_conv_13_ref = 0;
47903                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
47904                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
47905                 ret_arr_ptr[n] = ret_conv_13_ref;
47906         }
47907         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47908         FREE(ret_var.data);
47909         return ret_arr;
47910 }
47911
47912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1supported_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47913         LDKOffer this_arg_conv;
47914         this_arg_conv.inner = untag_ptr(this_arg);
47915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47917         this_arg_conv.is_owned = false;
47918         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
47919         int64_t ret_ref = 0;
47920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47922         return ret_ref;
47923 }
47924
47925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1valid_1quantity(JNIEnv *env, jclass clz, int64_t this_arg, int64_t quantity) {
47926         LDKOffer this_arg_conv;
47927         this_arg_conv.inner = untag_ptr(this_arg);
47928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47930         this_arg_conv.is_owned = false;
47931         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
47932         return ret_conv;
47933 }
47934
47935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1expects_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47936         LDKOffer this_arg_conv;
47937         this_arg_conv.inner = untag_ptr(this_arg);
47938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47940         this_arg_conv.is_owned = false;
47941         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
47942         return ret_conv;
47943 }
47944
47945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Offer_signing_pubkey(&this_arg_conv).compressed_form);
47953         return ret_arr;
47954 }
47955
47956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47957         LDKOffer obj_conv;
47958         obj_conv.inner = untag_ptr(obj);
47959         obj_conv.is_owned = ptr_is_owned(obj);
47960         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47961         obj_conv.is_owned = false;
47962         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
47963         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47964         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47965         CVec_u8Z_free(ret_var);
47966         return ret_arr;
47967 }
47968
47969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Amount_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47970         LDKAmount this_obj_conv;
47971         this_obj_conv.inner = untag_ptr(this_obj);
47972         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47974         Amount_free(this_obj_conv);
47975 }
47976
47977 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
47978         LDKAmount ret_var = Amount_clone(arg);
47979         int64_t ret_ref = 0;
47980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47982         return ret_ref;
47983 }
47984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47985         LDKAmount arg_conv;
47986         arg_conv.inner = untag_ptr(arg);
47987         arg_conv.is_owned = ptr_is_owned(arg);
47988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47989         arg_conv.is_owned = false;
47990         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
47991         return ret_conv;
47992 }
47993
47994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47995         LDKAmount orig_conv;
47996         orig_conv.inner = untag_ptr(orig);
47997         orig_conv.is_owned = ptr_is_owned(orig);
47998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47999         orig_conv.is_owned = false;
48000         LDKAmount ret_var = Amount_clone(&orig_conv);
48001         int64_t ret_ref = 0;
48002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48004         return ret_ref;
48005 }
48006
48007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Quantity_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48008         LDKQuantity this_obj_conv;
48009         this_obj_conv.inner = untag_ptr(this_obj);
48010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48012         Quantity_free(this_obj_conv);
48013 }
48014
48015 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
48016         LDKQuantity ret_var = Quantity_clone(arg);
48017         int64_t ret_ref = 0;
48018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48020         return ret_ref;
48021 }
48022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48023         LDKQuantity arg_conv;
48024         arg_conv.inner = untag_ptr(arg);
48025         arg_conv.is_owned = ptr_is_owned(arg);
48026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48027         arg_conv.is_owned = false;
48028         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
48029         return ret_conv;
48030 }
48031
48032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48033         LDKQuantity orig_conv;
48034         orig_conv.inner = untag_ptr(orig);
48035         orig_conv.is_owned = ptr_is_owned(orig);
48036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48037         orig_conv.is_owned = false;
48038         LDKQuantity ret_var = Quantity_clone(&orig_conv);
48039         int64_t ret_ref = 0;
48040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48042         return ret_ref;
48043 }
48044
48045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Refund_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48046         LDKRefund this_obj_conv;
48047         this_obj_conv.inner = untag_ptr(this_obj);
48048         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48050         Refund_free(this_obj_conv);
48051 }
48052
48053 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
48054         LDKRefund ret_var = Refund_clone(arg);
48055         int64_t ret_ref = 0;
48056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48057         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48058         return ret_ref;
48059 }
48060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48061         LDKRefund arg_conv;
48062         arg_conv.inner = untag_ptr(arg);
48063         arg_conv.is_owned = ptr_is_owned(arg);
48064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48065         arg_conv.is_owned = false;
48066         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
48067         return ret_conv;
48068 }
48069
48070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48071         LDKRefund orig_conv;
48072         orig_conv.inner = untag_ptr(orig);
48073         orig_conv.is_owned = ptr_is_owned(orig);
48074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48075         orig_conv.is_owned = false;
48076         LDKRefund ret_var = Refund_clone(&orig_conv);
48077         int64_t ret_ref = 0;
48078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48080         return ret_ref;
48081 }
48082
48083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48084         LDKRefund this_arg_conv;
48085         this_arg_conv.inner = untag_ptr(this_arg);
48086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48088         this_arg_conv.is_owned = false;
48089         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
48090         int64_t ret_ref = 0;
48091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48093         return ret_ref;
48094 }
48095
48096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48097         LDKRefund this_arg_conv;
48098         this_arg_conv.inner = untag_ptr(this_arg);
48099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48101         this_arg_conv.is_owned = false;
48102         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
48103         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
48104         int64_t ret_ref = tag_ptr(ret_copy, true);
48105         return ret_ref;
48106 }
48107
48108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Refund_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48109         LDKRefund this_arg_conv;
48110         this_arg_conv.inner = untag_ptr(this_arg);
48111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48113         this_arg_conv.is_owned = false;
48114         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
48115         return ret_conv;
48116 }
48117
48118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
48119         LDKRefund this_arg_conv;
48120         this_arg_conv.inner = untag_ptr(this_arg);
48121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48123         this_arg_conv.is_owned = false;
48124         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
48125         int64_t ret_ref = 0;
48126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48128         return ret_ref;
48129 }
48130
48131 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
48132         LDKRefund this_arg_conv;
48133         this_arg_conv.inner = untag_ptr(this_arg);
48134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48136         this_arg_conv.is_owned = false;
48137         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
48138         int64_tArray ret_arr = NULL;
48139         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48140         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48141         for (size_t n = 0; n < ret_var.datalen; n++) {
48142                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
48143                 int64_t ret_conv_13_ref = 0;
48144                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
48145                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
48146                 ret_arr_ptr[n] = ret_conv_13_ref;
48147         }
48148         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48149         FREE(ret_var.data);
48150         return ret_arr;
48151 }
48152
48153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
48154         LDKRefund this_arg_conv;
48155         this_arg_conv.inner = untag_ptr(this_arg);
48156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48158         this_arg_conv.is_owned = false;
48159         LDKu8slice ret_var = Refund_metadata(&this_arg_conv);
48160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48162         return ret_arr;
48163 }
48164
48165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
48166         LDKRefund this_arg_conv;
48167         this_arg_conv.inner = untag_ptr(this_arg);
48168         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48170         this_arg_conv.is_owned = false;
48171         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48172         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Refund_chain(&this_arg_conv).data);
48173         return ret_arr;
48174 }
48175
48176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
48177         LDKRefund this_arg_conv;
48178         this_arg_conv.inner = untag_ptr(this_arg);
48179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48181         this_arg_conv.is_owned = false;
48182         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
48183         return ret_conv;
48184 }
48185
48186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48187         LDKRefund this_arg_conv;
48188         this_arg_conv.inner = untag_ptr(this_arg);
48189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48191         this_arg_conv.is_owned = false;
48192         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
48193         int64_t ret_ref = 0;
48194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48196         return ret_ref;
48197 }
48198
48199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
48200         LDKRefund this_arg_conv;
48201         this_arg_conv.inner = untag_ptr(this_arg);
48202         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48204         this_arg_conv.is_owned = false;
48205         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48206         *ret_copy = Refund_quantity(&this_arg_conv);
48207         int64_t ret_ref = tag_ptr(ret_copy, true);
48208         return ret_ref;
48209 }
48210
48211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
48212         LDKRefund this_arg_conv;
48213         this_arg_conv.inner = untag_ptr(this_arg);
48214         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48216         this_arg_conv.is_owned = false;
48217         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Refund_payer_id(&this_arg_conv).compressed_form);
48219         return ret_arr;
48220 }
48221
48222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
48223         LDKRefund this_arg_conv;
48224         this_arg_conv.inner = untag_ptr(this_arg);
48225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48227         this_arg_conv.is_owned = false;
48228         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
48229         int64_t ret_ref = 0;
48230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48232         return ret_ref;
48233 }
48234
48235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1write(JNIEnv *env, jclass clz, int64_t obj) {
48236         LDKRefund obj_conv;
48237         obj_conv.inner = untag_ptr(obj);
48238         obj_conv.is_owned = ptr_is_owned(obj);
48239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48240         obj_conv.is_owned = false;
48241         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
48242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48244         CVec_u8Z_free(ret_var);
48245         return ret_arr;
48246 }
48247
48248 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48249         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
48250         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_clone(orig_conv));
48251         return ret_conv;
48252 }
48253
48254 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1chain(JNIEnv *env, jclass clz) {
48255         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_chain());
48256         return ret_conv;
48257 }
48258
48259 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1tx(JNIEnv *env, jclass clz) {
48260         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_tx());
48261         return ret_conv;
48262 }
48263
48264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoResult_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48265         if (!ptr_is_owned(this_ptr)) return;
48266         void* this_ptr_ptr = untag_ptr(this_ptr);
48267         CHECK_ACCESS(this_ptr_ptr);
48268         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
48269         FREE(untag_ptr(this_ptr));
48270         UtxoResult_free(this_ptr_conv);
48271 }
48272
48273 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
48274         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48275         *ret_copy = UtxoResult_clone(arg);
48276         int64_t ret_ref = tag_ptr(ret_copy, true);
48277         return ret_ref;
48278 }
48279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48280         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
48281         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
48282         return ret_conv;
48283 }
48284
48285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48286         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
48287         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48288         *ret_copy = UtxoResult_clone(orig_conv);
48289         int64_t ret_ref = tag_ptr(ret_copy, true);
48290         return ret_ref;
48291 }
48292
48293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1sync(JNIEnv *env, jclass clz, int64_t a) {
48294         void* a_ptr = untag_ptr(a);
48295         CHECK_ACCESS(a_ptr);
48296         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
48297         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
48298         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48299         *ret_copy = UtxoResult_sync(a_conv);
48300         int64_t ret_ref = tag_ptr(ret_copy, true);
48301         return ret_ref;
48302 }
48303
48304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1async(JNIEnv *env, jclass clz, int64_t a) {
48305         LDKUtxoFuture a_conv;
48306         a_conv.inner = untag_ptr(a);
48307         a_conv.is_owned = ptr_is_owned(a);
48308         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48309         a_conv = UtxoFuture_clone(&a_conv);
48310         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48311         *ret_copy = UtxoResult_async(a_conv);
48312         int64_t ret_ref = tag_ptr(ret_copy, true);
48313         return ret_ref;
48314 }
48315
48316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48317         if (!ptr_is_owned(this_ptr)) return;
48318         void* this_ptr_ptr = untag_ptr(this_ptr);
48319         CHECK_ACCESS(this_ptr_ptr);
48320         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
48321         FREE(untag_ptr(this_ptr));
48322         UtxoLookup_free(this_ptr_conv);
48323 }
48324
48325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48326         LDKUtxoFuture this_obj_conv;
48327         this_obj_conv.inner = untag_ptr(this_obj);
48328         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48330         UtxoFuture_free(this_obj_conv);
48331 }
48332
48333 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
48334         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
48335         int64_t ret_ref = 0;
48336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48338         return ret_ref;
48339 }
48340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48341         LDKUtxoFuture arg_conv;
48342         arg_conv.inner = untag_ptr(arg);
48343         arg_conv.is_owned = ptr_is_owned(arg);
48344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48345         arg_conv.is_owned = false;
48346         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
48347         return ret_conv;
48348 }
48349
48350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48351         LDKUtxoFuture orig_conv;
48352         orig_conv.inner = untag_ptr(orig);
48353         orig_conv.is_owned = ptr_is_owned(orig);
48354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48355         orig_conv.is_owned = false;
48356         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
48357         int64_t ret_ref = 0;
48358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48360         return ret_ref;
48361 }
48362
48363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1new(JNIEnv *env, jclass clz) {
48364         LDKUtxoFuture ret_var = UtxoFuture_new();
48365         int64_t ret_ref = 0;
48366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48368         return ret_ref;
48369 }
48370
48371 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) {
48372         LDKUtxoFuture this_arg_conv;
48373         this_arg_conv.inner = untag_ptr(this_arg);
48374         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48376         this_arg_conv.is_owned = false;
48377         LDKNetworkGraph graph_conv;
48378         graph_conv.inner = untag_ptr(graph);
48379         graph_conv.is_owned = ptr_is_owned(graph);
48380         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48381         graph_conv.is_owned = false;
48382         void* result_ptr = untag_ptr(result);
48383         CHECK_ACCESS(result_ptr);
48384         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48385         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
48386 }
48387
48388 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) {
48389         LDKUtxoFuture this_arg_conv;
48390         this_arg_conv.inner = untag_ptr(this_arg);
48391         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48393         this_arg_conv.is_owned = false;
48394         LDKNetworkGraph graph_conv;
48395         graph_conv.inner = untag_ptr(graph);
48396         graph_conv.is_owned = ptr_is_owned(graph);
48397         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48398         graph_conv.is_owned = false;
48399         LDKP2PGossipSync gossip_conv;
48400         gossip_conv.inner = untag_ptr(gossip);
48401         gossip_conv.is_owned = ptr_is_owned(gossip);
48402         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
48403         gossip_conv.is_owned = false;
48404         void* result_ptr = untag_ptr(result);
48405         CHECK_ACCESS(result_ptr);
48406         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48407         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
48408 }
48409
48410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48411         LDKNodeId this_obj_conv;
48412         this_obj_conv.inner = untag_ptr(this_obj);
48413         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48415         NodeId_free(this_obj_conv);
48416 }
48417
48418 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
48419         LDKNodeId ret_var = NodeId_clone(arg);
48420         int64_t ret_ref = 0;
48421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48423         return ret_ref;
48424 }
48425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48426         LDKNodeId arg_conv;
48427         arg_conv.inner = untag_ptr(arg);
48428         arg_conv.is_owned = ptr_is_owned(arg);
48429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48430         arg_conv.is_owned = false;
48431         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
48432         return ret_conv;
48433 }
48434
48435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48436         LDKNodeId orig_conv;
48437         orig_conv.inner = untag_ptr(orig);
48438         orig_conv.is_owned = ptr_is_owned(orig);
48439         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48440         orig_conv.is_owned = false;
48441         LDKNodeId ret_var = NodeId_clone(&orig_conv);
48442         int64_t ret_ref = 0;
48443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48445         return ret_ref;
48446 }
48447
48448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
48449         LDKPublicKey pubkey_ref;
48450         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48451         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48452         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
48453         int64_t ret_ref = 0;
48454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48456         return ret_ref;
48457 }
48458
48459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
48460         LDKNodeId this_arg_conv;
48461         this_arg_conv.inner = untag_ptr(this_arg);
48462         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48464         this_arg_conv.is_owned = false;
48465         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
48466         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48467         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48468         return ret_arr;
48469 }
48470
48471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
48472         LDKNodeId this_arg_conv;
48473         this_arg_conv.inner = untag_ptr(this_arg);
48474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48476         this_arg_conv.is_owned = false;
48477         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
48478         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
48479         return tag_ptr(ret_conv, true);
48480 }
48481
48482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
48483         LDKNodeId o_conv;
48484         o_conv.inner = untag_ptr(o);
48485         o_conv.is_owned = ptr_is_owned(o);
48486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48487         o_conv.is_owned = false;
48488         int64_t ret_conv = NodeId_hash(&o_conv);
48489         return ret_conv;
48490 }
48491
48492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
48493         LDKNodeId obj_conv;
48494         obj_conv.inner = untag_ptr(obj);
48495         obj_conv.is_owned = ptr_is_owned(obj);
48496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48497         obj_conv.is_owned = false;
48498         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
48499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48501         CVec_u8Z_free(ret_var);
48502         return ret_arr;
48503 }
48504
48505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48506         LDKu8slice ser_ref;
48507         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48508         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48509         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
48510         *ret_conv = NodeId_read(ser_ref);
48511         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48512         return tag_ptr(ret_conv, true);
48513 }
48514
48515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48516         LDKNetworkGraph this_obj_conv;
48517         this_obj_conv.inner = untag_ptr(this_obj);
48518         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48520         NetworkGraph_free(this_obj_conv);
48521 }
48522
48523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48524         LDKReadOnlyNetworkGraph this_obj_conv;
48525         this_obj_conv.inner = untag_ptr(this_obj);
48526         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48528         ReadOnlyNetworkGraph_free(this_obj_conv);
48529 }
48530
48531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48532         if (!ptr_is_owned(this_ptr)) return;
48533         void* this_ptr_ptr = untag_ptr(this_ptr);
48534         CHECK_ACCESS(this_ptr_ptr);
48535         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
48536         FREE(untag_ptr(this_ptr));
48537         NetworkUpdate_free(this_ptr_conv);
48538 }
48539
48540 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
48541         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48542         *ret_copy = NetworkUpdate_clone(arg);
48543         int64_t ret_ref = tag_ptr(ret_copy, true);
48544         return ret_ref;
48545 }
48546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48547         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
48548         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
48549         return ret_conv;
48550 }
48551
48552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48553         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
48554         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48555         *ret_copy = NetworkUpdate_clone(orig_conv);
48556         int64_t ret_ref = tag_ptr(ret_copy, true);
48557         return ret_ref;
48558 }
48559
48560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
48561         LDKChannelUpdate msg_conv;
48562         msg_conv.inner = untag_ptr(msg);
48563         msg_conv.is_owned = ptr_is_owned(msg);
48564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48565         msg_conv = ChannelUpdate_clone(&msg_conv);
48566         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48567         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
48568         int64_t ret_ref = tag_ptr(ret_copy, true);
48569         return ret_ref;
48570 }
48571
48572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
48573         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48574         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
48575         int64_t ret_ref = tag_ptr(ret_copy, true);
48576         return ret_ref;
48577 }
48578
48579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
48580         LDKPublicKey node_id_ref;
48581         CHECK((*env)->GetArrayLength(env, node_id) == 33);
48582         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
48583         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48584         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
48585         int64_t ret_ref = tag_ptr(ret_copy, true);
48586         return ret_ref;
48587 }
48588
48589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48590         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
48591         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
48592         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
48593         return ret_conv;
48594 }
48595
48596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
48597         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
48598         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
48599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48601         CVec_u8Z_free(ret_var);
48602         return ret_arr;
48603 }
48604
48605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48606         LDKu8slice ser_ref;
48607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48609         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
48610         *ret_conv = NetworkUpdate_read(ser_ref);
48611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48612         return tag_ptr(ret_conv, true);
48613 }
48614
48615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48616         LDKP2PGossipSync this_obj_conv;
48617         this_obj_conv.inner = untag_ptr(this_obj);
48618         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48620         P2PGossipSync_free(this_obj_conv);
48621 }
48622
48623 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) {
48624         LDKNetworkGraph network_graph_conv;
48625         network_graph_conv.inner = untag_ptr(network_graph);
48626         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48627         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48628         network_graph_conv.is_owned = false;
48629         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48630         CHECK_ACCESS(utxo_lookup_ptr);
48631         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48632         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48633         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48634                 // Manually implement clone for Java trait instances
48635                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48636                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48637                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48638                 }
48639         }
48640         void* logger_ptr = untag_ptr(logger);
48641         CHECK_ACCESS(logger_ptr);
48642         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48643         if (logger_conv.free == LDKLogger_JCalls_free) {
48644                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48645                 LDKLogger_JCalls_cloned(&logger_conv);
48646         }
48647         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
48648         int64_t ret_ref = 0;
48649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48651         return ret_ref;
48652 }
48653
48654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1utxo_1lookup(JNIEnv *env, jclass clz, int64_t this_arg, int64_t utxo_lookup) {
48655         LDKP2PGossipSync this_arg_conv;
48656         this_arg_conv.inner = untag_ptr(this_arg);
48657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48659         this_arg_conv.is_owned = false;
48660         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48661         CHECK_ACCESS(utxo_lookup_ptr);
48662         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48663         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48664         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48665                 // Manually implement clone for Java trait instances
48666                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48667                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48668                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48669                 }
48670         }
48671         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
48672 }
48673
48674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
48675         LDKNetworkGraph 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         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
48681         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
48682 }
48683
48684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48685         LDKP2PGossipSync this_arg_conv;
48686         this_arg_conv.inner = untag_ptr(this_arg);
48687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48689         this_arg_conv.is_owned = false;
48690         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
48691         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
48692         return tag_ptr(ret_ret, true);
48693 }
48694
48695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
48696         LDKP2PGossipSync this_arg_conv;
48697         this_arg_conv.inner = untag_ptr(this_arg);
48698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48700         this_arg_conv.is_owned = false;
48701         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
48702         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
48703         return tag_ptr(ret_ret, true);
48704 }
48705
48706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48707         LDKChannelUpdateInfo this_obj_conv;
48708         this_obj_conv.inner = untag_ptr(this_obj);
48709         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48711         ChannelUpdateInfo_free(this_obj_conv);
48712 }
48713
48714 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
48715         LDKChannelUpdateInfo this_ptr_conv;
48716         this_ptr_conv.inner = untag_ptr(this_ptr);
48717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48719         this_ptr_conv.is_owned = false;
48720         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
48721         return ret_conv;
48722 }
48723
48724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48725         LDKChannelUpdateInfo this_ptr_conv;
48726         this_ptr_conv.inner = untag_ptr(this_ptr);
48727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48729         this_ptr_conv.is_owned = false;
48730         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
48731 }
48732
48733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
48734         LDKChannelUpdateInfo this_ptr_conv;
48735         this_ptr_conv.inner = untag_ptr(this_ptr);
48736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48738         this_ptr_conv.is_owned = false;
48739         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
48740         return ret_conv;
48741 }
48742
48743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
48744         LDKChannelUpdateInfo this_ptr_conv;
48745         this_ptr_conv.inner = untag_ptr(this_ptr);
48746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48748         this_ptr_conv.is_owned = false;
48749         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
48750 }
48751
48752 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48753         LDKChannelUpdateInfo this_ptr_conv;
48754         this_ptr_conv.inner = untag_ptr(this_ptr);
48755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48757         this_ptr_conv.is_owned = false;
48758         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
48759         return ret_conv;
48760 }
48761
48762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
48763         LDKChannelUpdateInfo this_ptr_conv;
48764         this_ptr_conv.inner = untag_ptr(this_ptr);
48765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48767         this_ptr_conv.is_owned = false;
48768         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
48769 }
48770
48771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48772         LDKChannelUpdateInfo this_ptr_conv;
48773         this_ptr_conv.inner = untag_ptr(this_ptr);
48774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48776         this_ptr_conv.is_owned = false;
48777         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
48778         return ret_conv;
48779 }
48780
48781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48782         LDKChannelUpdateInfo this_ptr_conv;
48783         this_ptr_conv.inner = untag_ptr(this_ptr);
48784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48786         this_ptr_conv.is_owned = false;
48787         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
48788 }
48789
48790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48791         LDKChannelUpdateInfo this_ptr_conv;
48792         this_ptr_conv.inner = untag_ptr(this_ptr);
48793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48795         this_ptr_conv.is_owned = false;
48796         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
48797         return ret_conv;
48798 }
48799
48800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48801         LDKChannelUpdateInfo this_ptr_conv;
48802         this_ptr_conv.inner = untag_ptr(this_ptr);
48803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48805         this_ptr_conv.is_owned = false;
48806         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
48807 }
48808
48809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
48810         LDKChannelUpdateInfo this_ptr_conv;
48811         this_ptr_conv.inner = untag_ptr(this_ptr);
48812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48814         this_ptr_conv.is_owned = false;
48815         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
48816         int64_t ret_ref = 0;
48817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48818         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48819         return ret_ref;
48820 }
48821
48822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48823         LDKChannelUpdateInfo this_ptr_conv;
48824         this_ptr_conv.inner = untag_ptr(this_ptr);
48825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48827         this_ptr_conv.is_owned = false;
48828         LDKRoutingFees val_conv;
48829         val_conv.inner = untag_ptr(val);
48830         val_conv.is_owned = ptr_is_owned(val);
48831         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48832         val_conv = RoutingFees_clone(&val_conv);
48833         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
48834 }
48835
48836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
48837         LDKChannelUpdateInfo this_ptr_conv;
48838         this_ptr_conv.inner = untag_ptr(this_ptr);
48839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48841         this_ptr_conv.is_owned = false;
48842         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
48843         int64_t ret_ref = 0;
48844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48846         return ret_ref;
48847 }
48848
48849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48850         LDKChannelUpdateInfo this_ptr_conv;
48851         this_ptr_conv.inner = untag_ptr(this_ptr);
48852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48854         this_ptr_conv.is_owned = false;
48855         LDKChannelUpdate val_conv;
48856         val_conv.inner = untag_ptr(val);
48857         val_conv.is_owned = ptr_is_owned(val);
48858         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48859         val_conv = ChannelUpdate_clone(&val_conv);
48860         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
48861 }
48862
48863 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) {
48864         LDKRoutingFees fees_arg_conv;
48865         fees_arg_conv.inner = untag_ptr(fees_arg);
48866         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
48867         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
48868         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
48869         LDKChannelUpdate last_update_message_arg_conv;
48870         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
48871         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
48872         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
48873         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
48874         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);
48875         int64_t ret_ref = 0;
48876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48878         return ret_ref;
48879 }
48880
48881 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
48882         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
48883         int64_t ret_ref = 0;
48884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48886         return ret_ref;
48887 }
48888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48889         LDKChannelUpdateInfo arg_conv;
48890         arg_conv.inner = untag_ptr(arg);
48891         arg_conv.is_owned = ptr_is_owned(arg);
48892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48893         arg_conv.is_owned = false;
48894         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
48895         return ret_conv;
48896 }
48897
48898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48899         LDKChannelUpdateInfo orig_conv;
48900         orig_conv.inner = untag_ptr(orig);
48901         orig_conv.is_owned = ptr_is_owned(orig);
48902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48903         orig_conv.is_owned = false;
48904         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
48905         int64_t ret_ref = 0;
48906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48908         return ret_ref;
48909 }
48910
48911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48912         LDKChannelUpdateInfo a_conv;
48913         a_conv.inner = untag_ptr(a);
48914         a_conv.is_owned = ptr_is_owned(a);
48915         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48916         a_conv.is_owned = false;
48917         LDKChannelUpdateInfo b_conv;
48918         b_conv.inner = untag_ptr(b);
48919         b_conv.is_owned = ptr_is_owned(b);
48920         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48921         b_conv.is_owned = false;
48922         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
48923         return ret_conv;
48924 }
48925
48926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48927         LDKChannelUpdateInfo obj_conv;
48928         obj_conv.inner = untag_ptr(obj);
48929         obj_conv.is_owned = ptr_is_owned(obj);
48930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48931         obj_conv.is_owned = false;
48932         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
48933         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48934         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48935         CVec_u8Z_free(ret_var);
48936         return ret_arr;
48937 }
48938
48939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48940         LDKu8slice ser_ref;
48941         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48942         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48943         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
48944         *ret_conv = ChannelUpdateInfo_read(ser_ref);
48945         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48946         return tag_ptr(ret_conv, true);
48947 }
48948
48949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48950         LDKChannelInfo this_obj_conv;
48951         this_obj_conv.inner = untag_ptr(this_obj);
48952         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48954         ChannelInfo_free(this_obj_conv);
48955 }
48956
48957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48958         LDKChannelInfo this_ptr_conv;
48959         this_ptr_conv.inner = untag_ptr(this_ptr);
48960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48962         this_ptr_conv.is_owned = false;
48963         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
48964         int64_t ret_ref = 0;
48965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48967         return ret_ref;
48968 }
48969
48970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48971         LDKChannelInfo this_ptr_conv;
48972         this_ptr_conv.inner = untag_ptr(this_ptr);
48973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48975         this_ptr_conv.is_owned = false;
48976         LDKChannelFeatures val_conv;
48977         val_conv.inner = untag_ptr(val);
48978         val_conv.is_owned = ptr_is_owned(val);
48979         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48980         val_conv = ChannelFeatures_clone(&val_conv);
48981         ChannelInfo_set_features(&this_ptr_conv, val_conv);
48982 }
48983
48984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
48985         LDKChannelInfo this_ptr_conv;
48986         this_ptr_conv.inner = untag_ptr(this_ptr);
48987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48989         this_ptr_conv.is_owned = false;
48990         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
48991         int64_t ret_ref = 0;
48992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48993         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48994         return ret_ref;
48995 }
48996
48997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48998         LDKChannelInfo this_ptr_conv;
48999         this_ptr_conv.inner = untag_ptr(this_ptr);
49000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49002         this_ptr_conv.is_owned = false;
49003         LDKNodeId val_conv;
49004         val_conv.inner = untag_ptr(val);
49005         val_conv.is_owned = ptr_is_owned(val);
49006         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49007         val_conv = NodeId_clone(&val_conv);
49008         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
49009 }
49010
49011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49012         LDKChannelInfo this_ptr_conv;
49013         this_ptr_conv.inner = untag_ptr(this_ptr);
49014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49016         this_ptr_conv.is_owned = false;
49017         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
49018         int64_t ret_ref = 0;
49019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49021         return ret_ref;
49022 }
49023
49024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49025         LDKChannelInfo this_ptr_conv;
49026         this_ptr_conv.inner = untag_ptr(this_ptr);
49027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49029         this_ptr_conv.is_owned = false;
49030         LDKChannelUpdateInfo val_conv;
49031         val_conv.inner = untag_ptr(val);
49032         val_conv.is_owned = ptr_is_owned(val);
49033         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49034         val_conv = ChannelUpdateInfo_clone(&val_conv);
49035         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
49036 }
49037
49038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49039         LDKChannelInfo this_ptr_conv;
49040         this_ptr_conv.inner = untag_ptr(this_ptr);
49041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49043         this_ptr_conv.is_owned = false;
49044         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
49045         int64_t ret_ref = 0;
49046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49048         return ret_ref;
49049 }
49050
49051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49052         LDKChannelInfo this_ptr_conv;
49053         this_ptr_conv.inner = untag_ptr(this_ptr);
49054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49056         this_ptr_conv.is_owned = false;
49057         LDKNodeId val_conv;
49058         val_conv.inner = untag_ptr(val);
49059         val_conv.is_owned = ptr_is_owned(val);
49060         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49061         val_conv = NodeId_clone(&val_conv);
49062         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
49063 }
49064
49065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49066         LDKChannelInfo this_ptr_conv;
49067         this_ptr_conv.inner = untag_ptr(this_ptr);
49068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49070         this_ptr_conv.is_owned = false;
49071         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
49072         int64_t ret_ref = 0;
49073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49075         return ret_ref;
49076 }
49077
49078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49079         LDKChannelInfo this_ptr_conv;
49080         this_ptr_conv.inner = untag_ptr(this_ptr);
49081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49083         this_ptr_conv.is_owned = false;
49084         LDKChannelUpdateInfo val_conv;
49085         val_conv.inner = untag_ptr(val);
49086         val_conv.is_owned = ptr_is_owned(val);
49087         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49088         val_conv = ChannelUpdateInfo_clone(&val_conv);
49089         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
49090 }
49091
49092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
49093         LDKChannelInfo this_ptr_conv;
49094         this_ptr_conv.inner = untag_ptr(this_ptr);
49095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49097         this_ptr_conv.is_owned = false;
49098         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49099         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
49100         int64_t ret_ref = tag_ptr(ret_copy, true);
49101         return ret_ref;
49102 }
49103
49104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49105         LDKChannelInfo this_ptr_conv;
49106         this_ptr_conv.inner = untag_ptr(this_ptr);
49107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49109         this_ptr_conv.is_owned = false;
49110         void* val_ptr = untag_ptr(val);
49111         CHECK_ACCESS(val_ptr);
49112         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49113         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49114         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
49115 }
49116
49117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49118         LDKChannelInfo this_ptr_conv;
49119         this_ptr_conv.inner = untag_ptr(this_ptr);
49120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49122         this_ptr_conv.is_owned = false;
49123         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
49124         int64_t ret_ref = 0;
49125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49127         return ret_ref;
49128 }
49129
49130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49131         LDKChannelInfo this_ptr_conv;
49132         this_ptr_conv.inner = untag_ptr(this_ptr);
49133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49135         this_ptr_conv.is_owned = false;
49136         LDKChannelAnnouncement val_conv;
49137         val_conv.inner = untag_ptr(val);
49138         val_conv.is_owned = ptr_is_owned(val);
49139         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49140         val_conv = ChannelAnnouncement_clone(&val_conv);
49141         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
49142 }
49143
49144 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
49145         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
49146         int64_t ret_ref = 0;
49147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49149         return ret_ref;
49150 }
49151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49152         LDKChannelInfo arg_conv;
49153         arg_conv.inner = untag_ptr(arg);
49154         arg_conv.is_owned = ptr_is_owned(arg);
49155         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49156         arg_conv.is_owned = false;
49157         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
49158         return ret_conv;
49159 }
49160
49161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49162         LDKChannelInfo orig_conv;
49163         orig_conv.inner = untag_ptr(orig);
49164         orig_conv.is_owned = ptr_is_owned(orig);
49165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49166         orig_conv.is_owned = false;
49167         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
49168         int64_t ret_ref = 0;
49169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49171         return ret_ref;
49172 }
49173
49174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49175         LDKChannelInfo a_conv;
49176         a_conv.inner = untag_ptr(a);
49177         a_conv.is_owned = ptr_is_owned(a);
49178         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49179         a_conv.is_owned = false;
49180         LDKChannelInfo b_conv;
49181         b_conv.inner = untag_ptr(b);
49182         b_conv.is_owned = ptr_is_owned(b);
49183         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49184         b_conv.is_owned = false;
49185         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
49186         return ret_conv;
49187 }
49188
49189 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) {
49190         LDKChannelInfo this_arg_conv;
49191         this_arg_conv.inner = untag_ptr(this_arg);
49192         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49194         this_arg_conv.is_owned = false;
49195         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
49196         int64_t ret_ref = 0;
49197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49199         return ret_ref;
49200 }
49201
49202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49203         LDKChannelInfo obj_conv;
49204         obj_conv.inner = untag_ptr(obj);
49205         obj_conv.is_owned = ptr_is_owned(obj);
49206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49207         obj_conv.is_owned = false;
49208         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
49209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49211         CVec_u8Z_free(ret_var);
49212         return ret_arr;
49213 }
49214
49215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49216         LDKu8slice ser_ref;
49217         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49218         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49219         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
49220         *ret_conv = ChannelInfo_read(ser_ref);
49221         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49222         return tag_ptr(ret_conv, true);
49223 }
49224
49225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49226         LDKDirectedChannelInfo this_obj_conv;
49227         this_obj_conv.inner = untag_ptr(this_obj);
49228         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49230         DirectedChannelInfo_free(this_obj_conv);
49231 }
49232
49233 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
49234         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
49235         int64_t ret_ref = 0;
49236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49238         return ret_ref;
49239 }
49240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49241         LDKDirectedChannelInfo arg_conv;
49242         arg_conv.inner = untag_ptr(arg);
49243         arg_conv.is_owned = ptr_is_owned(arg);
49244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49245         arg_conv.is_owned = false;
49246         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
49247         return ret_conv;
49248 }
49249
49250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49251         LDKDirectedChannelInfo orig_conv;
49252         orig_conv.inner = untag_ptr(orig);
49253         orig_conv.is_owned = ptr_is_owned(orig);
49254         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49255         orig_conv.is_owned = false;
49256         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
49257         int64_t ret_ref = 0;
49258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49260         return ret_ref;
49261 }
49262
49263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
49264         LDKDirectedChannelInfo this_arg_conv;
49265         this_arg_conv.inner = untag_ptr(this_arg);
49266         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49268         this_arg_conv.is_owned = false;
49269         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
49270         int64_t ret_ref = 0;
49271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49273         return ret_ref;
49274 }
49275
49276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49277         LDKDirectedChannelInfo this_arg_conv;
49278         this_arg_conv.inner = untag_ptr(this_arg);
49279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49281         this_arg_conv.is_owned = false;
49282         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
49283         return ret_conv;
49284 }
49285
49286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
49287         LDKDirectedChannelInfo this_arg_conv;
49288         this_arg_conv.inner = untag_ptr(this_arg);
49289         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49291         this_arg_conv.is_owned = false;
49292         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49293         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
49294         int64_t ret_ref = tag_ptr(ret_copy, true);
49295         return ret_ref;
49296 }
49297
49298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49299         if (!ptr_is_owned(this_ptr)) return;
49300         void* this_ptr_ptr = untag_ptr(this_ptr);
49301         CHECK_ACCESS(this_ptr_ptr);
49302         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
49303         FREE(untag_ptr(this_ptr));
49304         EffectiveCapacity_free(this_ptr_conv);
49305 }
49306
49307 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
49308         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49309         *ret_copy = EffectiveCapacity_clone(arg);
49310         int64_t ret_ref = tag_ptr(ret_copy, true);
49311         return ret_ref;
49312 }
49313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49314         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
49315         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
49316         return ret_conv;
49317 }
49318
49319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49320         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
49321         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49322         *ret_copy = EffectiveCapacity_clone(orig_conv);
49323         int64_t ret_ref = tag_ptr(ret_copy, true);
49324         return ret_ref;
49325 }
49326
49327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
49328         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49329         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
49330         int64_t ret_ref = tag_ptr(ret_copy, true);
49331         return ret_ref;
49332 }
49333
49334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
49335         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49336         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
49337         int64_t ret_ref = tag_ptr(ret_copy, true);
49338         return ret_ref;
49339 }
49340
49341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
49342         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49343         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
49344         int64_t ret_ref = tag_ptr(ret_copy, true);
49345         return ret_ref;
49346 }
49347
49348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
49349         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49350         *ret_copy = EffectiveCapacity_infinite();
49351         int64_t ret_ref = tag_ptr(ret_copy, true);
49352         return ret_ref;
49353 }
49354
49355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
49356         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49357         *ret_copy = EffectiveCapacity_unknown();
49358         int64_t ret_ref = tag_ptr(ret_copy, true);
49359         return ret_ref;
49360 }
49361
49362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49363         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
49364         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
49365         return ret_conv;
49366 }
49367
49368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49369         LDKRoutingFees this_obj_conv;
49370         this_obj_conv.inner = untag_ptr(this_obj);
49371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49373         RoutingFees_free(this_obj_conv);
49374 }
49375
49376 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49377         LDKRoutingFees this_ptr_conv;
49378         this_ptr_conv.inner = untag_ptr(this_ptr);
49379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49381         this_ptr_conv.is_owned = false;
49382         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
49383         return ret_conv;
49384 }
49385
49386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49387         LDKRoutingFees this_ptr_conv;
49388         this_ptr_conv.inner = untag_ptr(this_ptr);
49389         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49391         this_ptr_conv.is_owned = false;
49392         RoutingFees_set_base_msat(&this_ptr_conv, val);
49393 }
49394
49395 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
49396         LDKRoutingFees this_ptr_conv;
49397         this_ptr_conv.inner = untag_ptr(this_ptr);
49398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49400         this_ptr_conv.is_owned = false;
49401         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
49402         return ret_conv;
49403 }
49404
49405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49406         LDKRoutingFees this_ptr_conv;
49407         this_ptr_conv.inner = untag_ptr(this_ptr);
49408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49410         this_ptr_conv.is_owned = false;
49411         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
49412 }
49413
49414 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) {
49415         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
49416         int64_t ret_ref = 0;
49417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49419         return ret_ref;
49420 }
49421
49422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49423         LDKRoutingFees a_conv;
49424         a_conv.inner = untag_ptr(a);
49425         a_conv.is_owned = ptr_is_owned(a);
49426         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49427         a_conv.is_owned = false;
49428         LDKRoutingFees b_conv;
49429         b_conv.inner = untag_ptr(b);
49430         b_conv.is_owned = ptr_is_owned(b);
49431         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49432         b_conv.is_owned = false;
49433         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
49434         return ret_conv;
49435 }
49436
49437 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
49438         LDKRoutingFees ret_var = RoutingFees_clone(arg);
49439         int64_t ret_ref = 0;
49440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49442         return ret_ref;
49443 }
49444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49445         LDKRoutingFees arg_conv;
49446         arg_conv.inner = untag_ptr(arg);
49447         arg_conv.is_owned = ptr_is_owned(arg);
49448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49449         arg_conv.is_owned = false;
49450         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
49451         return ret_conv;
49452 }
49453
49454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49455         LDKRoutingFees orig_conv;
49456         orig_conv.inner = untag_ptr(orig);
49457         orig_conv.is_owned = ptr_is_owned(orig);
49458         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49459         orig_conv.is_owned = false;
49460         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
49461         int64_t ret_ref = 0;
49462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49464         return ret_ref;
49465 }
49466
49467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
49468         LDKRoutingFees o_conv;
49469         o_conv.inner = untag_ptr(o);
49470         o_conv.is_owned = ptr_is_owned(o);
49471         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49472         o_conv.is_owned = false;
49473         int64_t ret_conv = RoutingFees_hash(&o_conv);
49474         return ret_conv;
49475 }
49476
49477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
49478         LDKRoutingFees obj_conv;
49479         obj_conv.inner = untag_ptr(obj);
49480         obj_conv.is_owned = ptr_is_owned(obj);
49481         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49482         obj_conv.is_owned = false;
49483         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
49484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49486         CVec_u8Z_free(ret_var);
49487         return ret_arr;
49488 }
49489
49490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49491         LDKu8slice ser_ref;
49492         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49493         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49494         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
49495         *ret_conv = RoutingFees_read(ser_ref);
49496         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49497         return tag_ptr(ret_conv, true);
49498 }
49499
49500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49501         LDKNodeAnnouncementInfo this_obj_conv;
49502         this_obj_conv.inner = untag_ptr(this_obj);
49503         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49505         NodeAnnouncementInfo_free(this_obj_conv);
49506 }
49507
49508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49509         LDKNodeAnnouncementInfo this_ptr_conv;
49510         this_ptr_conv.inner = untag_ptr(this_ptr);
49511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49513         this_ptr_conv.is_owned = false;
49514         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
49515         int64_t ret_ref = 0;
49516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49517         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49518         return ret_ref;
49519 }
49520
49521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49522         LDKNodeAnnouncementInfo this_ptr_conv;
49523         this_ptr_conv.inner = untag_ptr(this_ptr);
49524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49526         this_ptr_conv.is_owned = false;
49527         LDKNodeFeatures val_conv;
49528         val_conv.inner = untag_ptr(val);
49529         val_conv.is_owned = ptr_is_owned(val);
49530         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49531         val_conv = NodeFeatures_clone(&val_conv);
49532         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
49533 }
49534
49535 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
49536         LDKNodeAnnouncementInfo this_ptr_conv;
49537         this_ptr_conv.inner = untag_ptr(this_ptr);
49538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49540         this_ptr_conv.is_owned = false;
49541         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
49542         return ret_conv;
49543 }
49544
49545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49546         LDKNodeAnnouncementInfo this_ptr_conv;
49547         this_ptr_conv.inner = untag_ptr(this_ptr);
49548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49550         this_ptr_conv.is_owned = false;
49551         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
49552 }
49553
49554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
49555         LDKNodeAnnouncementInfo this_ptr_conv;
49556         this_ptr_conv.inner = untag_ptr(this_ptr);
49557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49559         this_ptr_conv.is_owned = false;
49560         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
49561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
49562         return ret_arr;
49563 }
49564
49565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThreeBytes val_ref;
49572         CHECK((*env)->GetArrayLength(env, val) == 3);
49573         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
49574         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
49575 }
49576
49577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
49578         LDKNodeAnnouncementInfo this_ptr_conv;
49579         this_ptr_conv.inner = untag_ptr(this_ptr);
49580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49582         this_ptr_conv.is_owned = false;
49583         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
49584         int64_t ret_ref = 0;
49585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49587         return ret_ref;
49588 }
49589
49590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49591         LDKNodeAnnouncementInfo this_ptr_conv;
49592         this_ptr_conv.inner = untag_ptr(this_ptr);
49593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49595         this_ptr_conv.is_owned = false;
49596         LDKNodeAlias val_conv;
49597         val_conv.inner = untag_ptr(val);
49598         val_conv.is_owned = ptr_is_owned(val);
49599         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49600         val_conv = NodeAlias_clone(&val_conv);
49601         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
49602 }
49603
49604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49605         LDKNodeAnnouncementInfo this_ptr_conv;
49606         this_ptr_conv.inner = untag_ptr(this_ptr);
49607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49609         this_ptr_conv.is_owned = false;
49610         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
49611         int64_t ret_ref = 0;
49612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49614         return ret_ref;
49615 }
49616
49617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49618         LDKNodeAnnouncementInfo this_ptr_conv;
49619         this_ptr_conv.inner = untag_ptr(this_ptr);
49620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49622         this_ptr_conv.is_owned = false;
49623         LDKNodeAnnouncement val_conv;
49624         val_conv.inner = untag_ptr(val);
49625         val_conv.is_owned = ptr_is_owned(val);
49626         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49627         val_conv = NodeAnnouncement_clone(&val_conv);
49628         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
49629 }
49630
49631 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) {
49632         LDKNodeFeatures features_arg_conv;
49633         features_arg_conv.inner = untag_ptr(features_arg);
49634         features_arg_conv.is_owned = ptr_is_owned(features_arg);
49635         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
49636         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
49637         LDKThreeBytes rgb_arg_ref;
49638         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
49639         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
49640         LDKNodeAlias alias_arg_conv;
49641         alias_arg_conv.inner = untag_ptr(alias_arg);
49642         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
49643         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
49644         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
49645         LDKNodeAnnouncement announcement_message_arg_conv;
49646         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
49647         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
49648         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
49649         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
49650         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
49651         int64_t ret_ref = 0;
49652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49654         return ret_ref;
49655 }
49656
49657 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
49658         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
49659         int64_t ret_ref = 0;
49660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49662         return ret_ref;
49663 }
49664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49665         LDKNodeAnnouncementInfo arg_conv;
49666         arg_conv.inner = untag_ptr(arg);
49667         arg_conv.is_owned = ptr_is_owned(arg);
49668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49669         arg_conv.is_owned = false;
49670         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
49671         return ret_conv;
49672 }
49673
49674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49675         LDKNodeAnnouncementInfo orig_conv;
49676         orig_conv.inner = untag_ptr(orig);
49677         orig_conv.is_owned = ptr_is_owned(orig);
49678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49679         orig_conv.is_owned = false;
49680         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
49681         int64_t ret_ref = 0;
49682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49684         return ret_ref;
49685 }
49686
49687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49688         LDKNodeAnnouncementInfo a_conv;
49689         a_conv.inner = untag_ptr(a);
49690         a_conv.is_owned = ptr_is_owned(a);
49691         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49692         a_conv.is_owned = false;
49693         LDKNodeAnnouncementInfo b_conv;
49694         b_conv.inner = untag_ptr(b);
49695         b_conv.is_owned = ptr_is_owned(b);
49696         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49697         b_conv.is_owned = false;
49698         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
49699         return ret_conv;
49700 }
49701
49702 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
49703         LDKNodeAnnouncementInfo this_arg_conv;
49704         this_arg_conv.inner = untag_ptr(this_arg);
49705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49707         this_arg_conv.is_owned = false;
49708         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
49709         int64_tArray ret_arr = NULL;
49710         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49711         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49712         for (size_t m = 0; m < ret_var.datalen; m++) {
49713                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
49714                 *ret_conv_12_copy = ret_var.data[m];
49715                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
49716                 ret_arr_ptr[m] = ret_conv_12_ref;
49717         }
49718         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49719         FREE(ret_var.data);
49720         return ret_arr;
49721 }
49722
49723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49724         LDKNodeAnnouncementInfo obj_conv;
49725         obj_conv.inner = untag_ptr(obj);
49726         obj_conv.is_owned = ptr_is_owned(obj);
49727         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49728         obj_conv.is_owned = false;
49729         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
49730         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49731         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49732         CVec_u8Z_free(ret_var);
49733         return ret_arr;
49734 }
49735
49736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49737         LDKu8slice ser_ref;
49738         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49739         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49740         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
49741         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
49742         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49743         return tag_ptr(ret_conv, true);
49744 }
49745
49746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49747         LDKNodeAlias this_obj_conv;
49748         this_obj_conv.inner = untag_ptr(this_obj);
49749         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49751         NodeAlias_free(this_obj_conv);
49752 }
49753
49754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49755         LDKNodeAlias this_ptr_conv;
49756         this_ptr_conv.inner = untag_ptr(this_ptr);
49757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49759         this_ptr_conv.is_owned = false;
49760         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49761         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
49762         return ret_arr;
49763 }
49764
49765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49766         LDKNodeAlias this_ptr_conv;
49767         this_ptr_conv.inner = untag_ptr(this_ptr);
49768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49770         this_ptr_conv.is_owned = false;
49771         LDKThirtyTwoBytes val_ref;
49772         CHECK((*env)->GetArrayLength(env, val) == 32);
49773         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
49774         NodeAlias_set_a(&this_ptr_conv, val_ref);
49775 }
49776
49777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
49778         LDKThirtyTwoBytes a_arg_ref;
49779         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
49780         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
49781         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
49782         int64_t ret_ref = 0;
49783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49785         return ret_ref;
49786 }
49787
49788 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
49789         LDKNodeAlias ret_var = NodeAlias_clone(arg);
49790         int64_t ret_ref = 0;
49791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49793         return ret_ref;
49794 }
49795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49796         LDKNodeAlias arg_conv;
49797         arg_conv.inner = untag_ptr(arg);
49798         arg_conv.is_owned = ptr_is_owned(arg);
49799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49800         arg_conv.is_owned = false;
49801         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
49802         return ret_conv;
49803 }
49804
49805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49806         LDKNodeAlias orig_conv;
49807         orig_conv.inner = untag_ptr(orig);
49808         orig_conv.is_owned = ptr_is_owned(orig);
49809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49810         orig_conv.is_owned = false;
49811         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
49812         int64_t ret_ref = 0;
49813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49815         return ret_ref;
49816 }
49817
49818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49819         LDKNodeAlias a_conv;
49820         a_conv.inner = untag_ptr(a);
49821         a_conv.is_owned = ptr_is_owned(a);
49822         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49823         a_conv.is_owned = false;
49824         LDKNodeAlias b_conv;
49825         b_conv.inner = untag_ptr(b);
49826         b_conv.is_owned = ptr_is_owned(b);
49827         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49828         b_conv.is_owned = false;
49829         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
49830         return ret_conv;
49831 }
49832
49833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
49834         LDKNodeAlias obj_conv;
49835         obj_conv.inner = untag_ptr(obj);
49836         obj_conv.is_owned = ptr_is_owned(obj);
49837         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49838         obj_conv.is_owned = false;
49839         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
49840         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49841         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49842         CVec_u8Z_free(ret_var);
49843         return ret_arr;
49844 }
49845
49846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49847         LDKu8slice ser_ref;
49848         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49849         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49850         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
49851         *ret_conv = NodeAlias_read(ser_ref);
49852         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49853         return tag_ptr(ret_conv, true);
49854 }
49855
49856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49857         LDKNodeInfo this_obj_conv;
49858         this_obj_conv.inner = untag_ptr(this_obj);
49859         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49861         NodeInfo_free(this_obj_conv);
49862 }
49863
49864 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
49865         LDKNodeInfo this_ptr_conv;
49866         this_ptr_conv.inner = untag_ptr(this_ptr);
49867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49869         this_ptr_conv.is_owned = false;
49870         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
49871         int64_tArray ret_arr = NULL;
49872         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49873         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49874         for (size_t g = 0; g < ret_var.datalen; g++) {
49875                 int64_t ret_conv_6_conv = ret_var.data[g];
49876                 ret_arr_ptr[g] = ret_conv_6_conv;
49877         }
49878         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49879         FREE(ret_var.data);
49880         return ret_arr;
49881 }
49882
49883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49884         LDKNodeInfo this_ptr_conv;
49885         this_ptr_conv.inner = untag_ptr(this_ptr);
49886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49888         this_ptr_conv.is_owned = false;
49889         LDKCVec_u64Z val_constr;
49890         val_constr.datalen = (*env)->GetArrayLength(env, val);
49891         if (val_constr.datalen > 0)
49892                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49893         else
49894                 val_constr.data = NULL;
49895         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49896         for (size_t g = 0; g < val_constr.datalen; g++) {
49897                 int64_t val_conv_6 = val_vals[g];
49898                 val_constr.data[g] = val_conv_6;
49899         }
49900         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49901         NodeInfo_set_channels(&this_ptr_conv, val_constr);
49902 }
49903
49904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
49905         LDKNodeInfo this_ptr_conv;
49906         this_ptr_conv.inner = untag_ptr(this_ptr);
49907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49909         this_ptr_conv.is_owned = false;
49910         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
49911         int64_t ret_ref = 0;
49912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49914         return ret_ref;
49915 }
49916
49917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49918         LDKNodeInfo this_ptr_conv;
49919         this_ptr_conv.inner = untag_ptr(this_ptr);
49920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49922         this_ptr_conv.is_owned = false;
49923         LDKNodeAnnouncementInfo val_conv;
49924         val_conv.inner = untag_ptr(val);
49925         val_conv.is_owned = ptr_is_owned(val);
49926         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49927         val_conv = NodeAnnouncementInfo_clone(&val_conv);
49928         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
49929 }
49930
49931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t announcement_info_arg) {
49932         LDKCVec_u64Z channels_arg_constr;
49933         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
49934         if (channels_arg_constr.datalen > 0)
49935                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49936         else
49937                 channels_arg_constr.data = NULL;
49938         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
49939         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
49940                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
49941                 channels_arg_constr.data[g] = channels_arg_conv_6;
49942         }
49943         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
49944         LDKNodeAnnouncementInfo announcement_info_arg_conv;
49945         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
49946         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
49947         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
49948         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
49949         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
49950         int64_t ret_ref = 0;
49951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49953         return ret_ref;
49954 }
49955
49956 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
49957         LDKNodeInfo ret_var = NodeInfo_clone(arg);
49958         int64_t ret_ref = 0;
49959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49961         return ret_ref;
49962 }
49963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49964         LDKNodeInfo arg_conv;
49965         arg_conv.inner = untag_ptr(arg);
49966         arg_conv.is_owned = ptr_is_owned(arg);
49967         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49968         arg_conv.is_owned = false;
49969         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
49970         return ret_conv;
49971 }
49972
49973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49974         LDKNodeInfo orig_conv;
49975         orig_conv.inner = untag_ptr(orig);
49976         orig_conv.is_owned = ptr_is_owned(orig);
49977         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49978         orig_conv.is_owned = false;
49979         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
49980         int64_t ret_ref = 0;
49981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49983         return ret_ref;
49984 }
49985
49986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49987         LDKNodeInfo a_conv;
49988         a_conv.inner = untag_ptr(a);
49989         a_conv.is_owned = ptr_is_owned(a);
49990         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49991         a_conv.is_owned = false;
49992         LDKNodeInfo b_conv;
49993         b_conv.inner = untag_ptr(b);
49994         b_conv.is_owned = ptr_is_owned(b);
49995         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49996         b_conv.is_owned = false;
49997         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
49998         return ret_conv;
49999 }
50000
50001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
50002         LDKNodeInfo obj_conv;
50003         obj_conv.inner = untag_ptr(obj);
50004         obj_conv.is_owned = ptr_is_owned(obj);
50005         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50006         obj_conv.is_owned = false;
50007         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
50008         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50009         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50010         CVec_u8Z_free(ret_var);
50011         return ret_arr;
50012 }
50013
50014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50015         LDKu8slice ser_ref;
50016         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50017         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50018         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
50019         *ret_conv = NodeInfo_read(ser_ref);
50020         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50021         return tag_ptr(ret_conv, true);
50022 }
50023
50024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
50025         LDKNetworkGraph obj_conv;
50026         obj_conv.inner = untag_ptr(obj);
50027         obj_conv.is_owned = ptr_is_owned(obj);
50028         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50029         obj_conv.is_owned = false;
50030         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
50031         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50032         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50033         CVec_u8Z_free(ret_var);
50034         return ret_arr;
50035 }
50036
50037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
50038         LDKu8slice ser_ref;
50039         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50040         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50041         void* arg_ptr = untag_ptr(arg);
50042         CHECK_ACCESS(arg_ptr);
50043         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
50044         if (arg_conv.free == LDKLogger_JCalls_free) {
50045                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50046                 LDKLogger_JCalls_cloned(&arg_conv);
50047         }
50048         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
50049         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
50050         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50051         return tag_ptr(ret_conv, true);
50052 }
50053
50054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, jclass network, int64_t logger) {
50055         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
50056         void* logger_ptr = untag_ptr(logger);
50057         CHECK_ACCESS(logger_ptr);
50058         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50059         if (logger_conv.free == LDKLogger_JCalls_free) {
50060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50061                 LDKLogger_JCalls_cloned(&logger_conv);
50062         }
50063         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
50064         int64_t ret_ref = 0;
50065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50067         return ret_ref;
50068 }
50069
50070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
50071         LDKNetworkGraph this_arg_conv;
50072         this_arg_conv.inner = untag_ptr(this_arg);
50073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50075         this_arg_conv.is_owned = false;
50076         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
50077         int64_t ret_ref = 0;
50078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50080         return ret_ref;
50081 }
50082
50083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50084         LDKNetworkGraph this_arg_conv;
50085         this_arg_conv.inner = untag_ptr(this_arg);
50086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50088         this_arg_conv.is_owned = false;
50089         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
50090         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
50091         int64_t ret_ref = tag_ptr(ret_copy, true);
50092         return ret_ref;
50093 }
50094
50095 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) {
50096         LDKNetworkGraph this_arg_conv;
50097         this_arg_conv.inner = untag_ptr(this_arg);
50098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50100         this_arg_conv.is_owned = false;
50101         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
50102 }
50103
50104 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) {
50105         LDKNetworkGraph this_arg_conv;
50106         this_arg_conv.inner = untag_ptr(this_arg);
50107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50109         this_arg_conv.is_owned = false;
50110         LDKNodeAnnouncement msg_conv;
50111         msg_conv.inner = untag_ptr(msg);
50112         msg_conv.is_owned = ptr_is_owned(msg);
50113         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50114         msg_conv.is_owned = false;
50115         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50116         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
50117         return tag_ptr(ret_conv, true);
50118 }
50119
50120 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) {
50121         LDKNetworkGraph this_arg_conv;
50122         this_arg_conv.inner = untag_ptr(this_arg);
50123         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50125         this_arg_conv.is_owned = false;
50126         LDKUnsignedNodeAnnouncement msg_conv;
50127         msg_conv.inner = untag_ptr(msg);
50128         msg_conv.is_owned = ptr_is_owned(msg);
50129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50130         msg_conv.is_owned = false;
50131         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50132         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
50133         return tag_ptr(ret_conv, true);
50134 }
50135
50136 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) {
50137         LDKNetworkGraph this_arg_conv;
50138         this_arg_conv.inner = untag_ptr(this_arg);
50139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50141         this_arg_conv.is_owned = false;
50142         LDKChannelAnnouncement msg_conv;
50143         msg_conv.inner = untag_ptr(msg);
50144         msg_conv.is_owned = ptr_is_owned(msg);
50145         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50146         msg_conv.is_owned = false;
50147         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50148         CHECK_ACCESS(utxo_lookup_ptr);
50149         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50150         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50151         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50152                 // Manually implement clone for Java trait instances
50153                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50154                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50155                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50156                 }
50157         }
50158         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50159         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50160         return tag_ptr(ret_conv, true);
50161 }
50162
50163 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) {
50164         LDKNetworkGraph this_arg_conv;
50165         this_arg_conv.inner = untag_ptr(this_arg);
50166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50168         this_arg_conv.is_owned = false;
50169         LDKUnsignedChannelAnnouncement msg_conv;
50170         msg_conv.inner = untag_ptr(msg);
50171         msg_conv.is_owned = ptr_is_owned(msg);
50172         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50173         msg_conv.is_owned = false;
50174         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50175         CHECK_ACCESS(utxo_lookup_ptr);
50176         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50177         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50178         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50179                 // Manually implement clone for Java trait instances
50180                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50181                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50182                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50183                 }
50184         }
50185         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50186         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50187         return tag_ptr(ret_conv, true);
50188 }
50189
50190 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) {
50191         LDKNetworkGraph this_arg_conv;
50192         this_arg_conv.inner = untag_ptr(this_arg);
50193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50195         this_arg_conv.is_owned = false;
50196         LDKChannelFeatures features_conv;
50197         features_conv.inner = untag_ptr(features);
50198         features_conv.is_owned = ptr_is_owned(features);
50199         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
50200         features_conv = ChannelFeatures_clone(&features_conv);
50201         LDKPublicKey node_id_1_ref;
50202         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
50203         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
50204         LDKPublicKey node_id_2_ref;
50205         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
50206         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
50207         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50208         *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);
50209         return tag_ptr(ret_conv, true);
50210 }
50211
50212 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) {
50213         LDKNetworkGraph this_arg_conv;
50214         this_arg_conv.inner = untag_ptr(this_arg);
50215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50217         this_arg_conv.is_owned = false;
50218         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
50219 }
50220
50221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
50222         LDKNetworkGraph this_arg_conv;
50223         this_arg_conv.inner = untag_ptr(this_arg);
50224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50226         this_arg_conv.is_owned = false;
50227         LDKPublicKey node_id_ref;
50228         CHECK((*env)->GetArrayLength(env, node_id) == 33);
50229         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
50230         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
50231 }
50232
50233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
50234         LDKNetworkGraph this_arg_conv;
50235         this_arg_conv.inner = untag_ptr(this_arg);
50236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50238         this_arg_conv.is_owned = false;
50239         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
50240 }
50241
50242 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) {
50243         LDKNetworkGraph this_arg_conv;
50244         this_arg_conv.inner = untag_ptr(this_arg);
50245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50247         this_arg_conv.is_owned = false;
50248         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
50249 }
50250
50251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50252         LDKNetworkGraph this_arg_conv;
50253         this_arg_conv.inner = untag_ptr(this_arg);
50254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50256         this_arg_conv.is_owned = false;
50257         LDKChannelUpdate msg_conv;
50258         msg_conv.inner = untag_ptr(msg);
50259         msg_conv.is_owned = ptr_is_owned(msg);
50260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50261         msg_conv.is_owned = false;
50262         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50263         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
50264         return tag_ptr(ret_conv, true);
50265 }
50266
50267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50268         LDKNetworkGraph this_arg_conv;
50269         this_arg_conv.inner = untag_ptr(this_arg);
50270         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50272         this_arg_conv.is_owned = false;
50273         LDKUnsignedChannelUpdate msg_conv;
50274         msg_conv.inner = untag_ptr(msg);
50275         msg_conv.is_owned = ptr_is_owned(msg);
50276         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50277         msg_conv.is_owned = false;
50278         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50279         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
50280         return tag_ptr(ret_conv, true);
50281 }
50282
50283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50284         LDKReadOnlyNetworkGraph this_arg_conv;
50285         this_arg_conv.inner = untag_ptr(this_arg);
50286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50288         this_arg_conv.is_owned = false;
50289         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
50290         int64_t ret_ref = 0;
50291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50293         return ret_ref;
50294 }
50295
50296 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
50297         LDKReadOnlyNetworkGraph this_arg_conv;
50298         this_arg_conv.inner = untag_ptr(this_arg);
50299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50301         this_arg_conv.is_owned = false;
50302         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
50303         int64_tArray ret_arr = NULL;
50304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50306         for (size_t g = 0; g < ret_var.datalen; g++) {
50307                 int64_t ret_conv_6_conv = ret_var.data[g];
50308                 ret_arr_ptr[g] = ret_conv_6_conv;
50309         }
50310         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50311         FREE(ret_var.data);
50312         return ret_arr;
50313 }
50314
50315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50316         LDKReadOnlyNetworkGraph this_arg_conv;
50317         this_arg_conv.inner = untag_ptr(this_arg);
50318         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50320         this_arg_conv.is_owned = false;
50321         LDKNodeId node_id_conv;
50322         node_id_conv.inner = untag_ptr(node_id);
50323         node_id_conv.is_owned = ptr_is_owned(node_id);
50324         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50325         node_id_conv.is_owned = false;
50326         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
50327         int64_t ret_ref = 0;
50328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50329         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50330         return ret_ref;
50331 }
50332
50333 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
50334         LDKReadOnlyNetworkGraph this_arg_conv;
50335         this_arg_conv.inner = untag_ptr(this_arg);
50336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50338         this_arg_conv.is_owned = false;
50339         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
50340         int64_tArray ret_arr = NULL;
50341         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50342         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50343         for (size_t i = 0; i < ret_var.datalen; i++) {
50344                 LDKNodeId ret_conv_8_var = ret_var.data[i];
50345                 int64_t ret_conv_8_ref = 0;
50346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
50347                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
50348                 ret_arr_ptr[i] = ret_conv_8_ref;
50349         }
50350         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50351         FREE(ret_var.data);
50352         return ret_arr;
50353 }
50354
50355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
50356         LDKReadOnlyNetworkGraph this_arg_conv;
50357         this_arg_conv.inner = untag_ptr(this_arg);
50358         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50360         this_arg_conv.is_owned = false;
50361         LDKPublicKey pubkey_ref;
50362         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
50363         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
50364         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
50365         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
50366         int64_t ret_ref = tag_ptr(ret_copy, true);
50367         return ret_ref;
50368 }
50369
50370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50371         LDKDefaultRouter this_obj_conv;
50372         this_obj_conv.inner = untag_ptr(this_obj);
50373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50375         DefaultRouter_free(this_obj_conv);
50376 }
50377
50378 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) {
50379         LDKNetworkGraph network_graph_conv;
50380         network_graph_conv.inner = untag_ptr(network_graph);
50381         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50382         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50383         network_graph_conv.is_owned = false;
50384         void* logger_ptr = untag_ptr(logger);
50385         CHECK_ACCESS(logger_ptr);
50386         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50387         if (logger_conv.free == LDKLogger_JCalls_free) {
50388                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50389                 LDKLogger_JCalls_cloned(&logger_conv);
50390         }
50391         LDKThirtyTwoBytes random_seed_bytes_ref;
50392         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50393         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
50394         void* scorer_ptr = untag_ptr(scorer);
50395         CHECK_ACCESS(scorer_ptr);
50396         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
50397         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
50398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50399                 LDKLockableScore_JCalls_cloned(&scorer_conv);
50400         }
50401         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
50402         int64_t ret_ref = 0;
50403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50405         return ret_ref;
50406 }
50407
50408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
50409         LDKDefaultRouter this_arg_conv;
50410         this_arg_conv.inner = untag_ptr(this_arg);
50411         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50413         this_arg_conv.is_owned = false;
50414         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
50415         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
50416         return tag_ptr(ret_ret, true);
50417 }
50418
50419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50420         if (!ptr_is_owned(this_ptr)) return;
50421         void* this_ptr_ptr = untag_ptr(this_ptr);
50422         CHECK_ACCESS(this_ptr_ptr);
50423         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
50424         FREE(untag_ptr(this_ptr));
50425         Router_free(this_ptr_conv);
50426 }
50427
50428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50429         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
50430         this_obj_conv.inner = untag_ptr(this_obj);
50431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50433         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
50434 }
50435
50436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
50437         void* scorer_ptr = untag_ptr(scorer);
50438         CHECK_ACCESS(scorer_ptr);
50439         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
50440         if (scorer_conv.free == LDKScore_JCalls_free) {
50441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50442                 LDKScore_JCalls_cloned(&scorer_conv);
50443         }
50444         LDKInFlightHtlcs inflight_htlcs_conv;
50445         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
50446         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
50447         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
50448         inflight_htlcs_conv.is_owned = false;
50449         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
50450         int64_t ret_ref = 0;
50451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50453         return ret_ref;
50454 }
50455
50456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50457         LDKScorerAccountingForInFlightHtlcs obj_conv;
50458         obj_conv.inner = untag_ptr(obj);
50459         obj_conv.is_owned = ptr_is_owned(obj);
50460         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50461         obj_conv.is_owned = false;
50462         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
50463         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50464         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50465         CVec_u8Z_free(ret_var);
50466         return ret_arr;
50467 }
50468
50469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50470         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
50471         this_arg_conv.inner = untag_ptr(this_arg);
50472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50474         this_arg_conv.is_owned = false;
50475         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50476         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
50477         return tag_ptr(ret_ret, true);
50478 }
50479
50480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50481         LDKInFlightHtlcs this_obj_conv;
50482         this_obj_conv.inner = untag_ptr(this_obj);
50483         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50485         InFlightHtlcs_free(this_obj_conv);
50486 }
50487
50488 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
50489         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
50490         int64_t ret_ref = 0;
50491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50493         return ret_ref;
50494 }
50495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50496         LDKInFlightHtlcs arg_conv;
50497         arg_conv.inner = untag_ptr(arg);
50498         arg_conv.is_owned = ptr_is_owned(arg);
50499         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50500         arg_conv.is_owned = false;
50501         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
50502         return ret_conv;
50503 }
50504
50505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50506         LDKInFlightHtlcs orig_conv;
50507         orig_conv.inner = untag_ptr(orig);
50508         orig_conv.is_owned = ptr_is_owned(orig);
50509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50510         orig_conv.is_owned = false;
50511         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
50512         int64_t ret_ref = 0;
50513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50515         return ret_ref;
50516 }
50517
50518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
50519         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
50520         int64_t ret_ref = 0;
50521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50523         return ret_ref;
50524 }
50525
50526 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) {
50527         LDKInFlightHtlcs this_arg_conv;
50528         this_arg_conv.inner = untag_ptr(this_arg);
50529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50531         this_arg_conv.is_owned = false;
50532         LDKPath path_conv;
50533         path_conv.inner = untag_ptr(path);
50534         path_conv.is_owned = ptr_is_owned(path);
50535         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
50536         path_conv.is_owned = false;
50537         LDKPublicKey payer_node_id_ref;
50538         CHECK((*env)->GetArrayLength(env, payer_node_id) == 33);
50539         (*env)->GetByteArrayRegion(env, payer_node_id, 0, 33, payer_node_id_ref.compressed_form);
50540         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
50541 }
50542
50543 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) {
50544         LDKInFlightHtlcs this_arg_conv;
50545         this_arg_conv.inner = untag_ptr(this_arg);
50546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50548         this_arg_conv.is_owned = false;
50549         LDKNodeId source_conv;
50550         source_conv.inner = untag_ptr(source);
50551         source_conv.is_owned = ptr_is_owned(source);
50552         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
50553         source_conv.is_owned = false;
50554         LDKNodeId target_conv;
50555         target_conv.inner = untag_ptr(target);
50556         target_conv.is_owned = ptr_is_owned(target);
50557         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50558         target_conv.is_owned = false;
50559         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50560         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
50561         int64_t ret_ref = tag_ptr(ret_copy, true);
50562         return ret_ref;
50563 }
50564
50565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50566         LDKInFlightHtlcs obj_conv;
50567         obj_conv.inner = untag_ptr(obj);
50568         obj_conv.is_owned = ptr_is_owned(obj);
50569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50570         obj_conv.is_owned = false;
50571         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
50572         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50573         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50574         CVec_u8Z_free(ret_var);
50575         return ret_arr;
50576 }
50577
50578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50579         LDKu8slice ser_ref;
50580         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50581         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50582         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
50583         *ret_conv = InFlightHtlcs_read(ser_ref);
50584         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50585         return tag_ptr(ret_conv, true);
50586 }
50587
50588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50589         LDKRouteHop this_obj_conv;
50590         this_obj_conv.inner = untag_ptr(this_obj);
50591         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50593         RouteHop_free(this_obj_conv);
50594 }
50595
50596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
50597         LDKRouteHop this_ptr_conv;
50598         this_ptr_conv.inner = untag_ptr(this_ptr);
50599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50601         this_ptr_conv.is_owned = false;
50602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
50604         return ret_arr;
50605 }
50606
50607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50608         LDKRouteHop this_ptr_conv;
50609         this_ptr_conv.inner = untag_ptr(this_ptr);
50610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50612         this_ptr_conv.is_owned = false;
50613         LDKPublicKey val_ref;
50614         CHECK((*env)->GetArrayLength(env, val) == 33);
50615         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50616         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
50617 }
50618
50619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50620         LDKRouteHop this_ptr_conv;
50621         this_ptr_conv.inner = untag_ptr(this_ptr);
50622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50624         this_ptr_conv.is_owned = false;
50625         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
50626         int64_t ret_ref = 0;
50627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50629         return ret_ref;
50630 }
50631
50632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50633         LDKRouteHop this_ptr_conv;
50634         this_ptr_conv.inner = untag_ptr(this_ptr);
50635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50637         this_ptr_conv.is_owned = false;
50638         LDKNodeFeatures val_conv;
50639         val_conv.inner = untag_ptr(val);
50640         val_conv.is_owned = ptr_is_owned(val);
50641         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50642         val_conv = NodeFeatures_clone(&val_conv);
50643         RouteHop_set_node_features(&this_ptr_conv, val_conv);
50644 }
50645
50646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50647         LDKRouteHop this_ptr_conv;
50648         this_ptr_conv.inner = untag_ptr(this_ptr);
50649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50651         this_ptr_conv.is_owned = false;
50652         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
50653         return ret_conv;
50654 }
50655
50656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50657         LDKRouteHop this_ptr_conv;
50658         this_ptr_conv.inner = untag_ptr(this_ptr);
50659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50661         this_ptr_conv.is_owned = false;
50662         RouteHop_set_short_channel_id(&this_ptr_conv, val);
50663 }
50664
50665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50666         LDKRouteHop this_ptr_conv;
50667         this_ptr_conv.inner = untag_ptr(this_ptr);
50668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50670         this_ptr_conv.is_owned = false;
50671         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
50672         int64_t ret_ref = 0;
50673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50675         return ret_ref;
50676 }
50677
50678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50679         LDKRouteHop this_ptr_conv;
50680         this_ptr_conv.inner = untag_ptr(this_ptr);
50681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50683         this_ptr_conv.is_owned = false;
50684         LDKChannelFeatures val_conv;
50685         val_conv.inner = untag_ptr(val);
50686         val_conv.is_owned = ptr_is_owned(val);
50687         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50688         val_conv = ChannelFeatures_clone(&val_conv);
50689         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
50690 }
50691
50692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50693         LDKRouteHop this_ptr_conv;
50694         this_ptr_conv.inner = untag_ptr(this_ptr);
50695         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50697         this_ptr_conv.is_owned = false;
50698         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
50699         return ret_conv;
50700 }
50701
50702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50703         LDKRouteHop this_ptr_conv;
50704         this_ptr_conv.inner = untag_ptr(this_ptr);
50705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50707         this_ptr_conv.is_owned = false;
50708         RouteHop_set_fee_msat(&this_ptr_conv, val);
50709 }
50710
50711 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50712         LDKRouteHop this_ptr_conv;
50713         this_ptr_conv.inner = untag_ptr(this_ptr);
50714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50716         this_ptr_conv.is_owned = false;
50717         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
50718         return ret_conv;
50719 }
50720
50721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50722         LDKRouteHop this_ptr_conv;
50723         this_ptr_conv.inner = untag_ptr(this_ptr);
50724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50726         this_ptr_conv.is_owned = false;
50727         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
50728 }
50729
50730 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) {
50731         LDKPublicKey pubkey_arg_ref;
50732         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
50733         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
50734         LDKNodeFeatures node_features_arg_conv;
50735         node_features_arg_conv.inner = untag_ptr(node_features_arg);
50736         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
50737         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
50738         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
50739         LDKChannelFeatures channel_features_arg_conv;
50740         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
50741         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
50742         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
50743         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
50744         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);
50745         int64_t ret_ref = 0;
50746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50748         return ret_ref;
50749 }
50750
50751 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
50752         LDKRouteHop ret_var = RouteHop_clone(arg);
50753         int64_t ret_ref = 0;
50754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50756         return ret_ref;
50757 }
50758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50759         LDKRouteHop arg_conv;
50760         arg_conv.inner = untag_ptr(arg);
50761         arg_conv.is_owned = ptr_is_owned(arg);
50762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50763         arg_conv.is_owned = false;
50764         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
50765         return ret_conv;
50766 }
50767
50768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50769         LDKRouteHop orig_conv;
50770         orig_conv.inner = untag_ptr(orig);
50771         orig_conv.is_owned = ptr_is_owned(orig);
50772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50773         orig_conv.is_owned = false;
50774         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
50775         int64_t ret_ref = 0;
50776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50778         return ret_ref;
50779 }
50780
50781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
50782         LDKRouteHop o_conv;
50783         o_conv.inner = untag_ptr(o);
50784         o_conv.is_owned = ptr_is_owned(o);
50785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50786         o_conv.is_owned = false;
50787         int64_t ret_conv = RouteHop_hash(&o_conv);
50788         return ret_conv;
50789 }
50790
50791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50792         LDKRouteHop a_conv;
50793         a_conv.inner = untag_ptr(a);
50794         a_conv.is_owned = ptr_is_owned(a);
50795         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50796         a_conv.is_owned = false;
50797         LDKRouteHop b_conv;
50798         b_conv.inner = untag_ptr(b);
50799         b_conv.is_owned = ptr_is_owned(b);
50800         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50801         b_conv.is_owned = false;
50802         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
50803         return ret_conv;
50804 }
50805
50806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50807         LDKRouteHop obj_conv;
50808         obj_conv.inner = untag_ptr(obj);
50809         obj_conv.is_owned = ptr_is_owned(obj);
50810         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50811         obj_conv.is_owned = false;
50812         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
50813         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50814         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50815         CVec_u8Z_free(ret_var);
50816         return ret_arr;
50817 }
50818
50819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50820         LDKu8slice ser_ref;
50821         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50822         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50823         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
50824         *ret_conv = RouteHop_read(ser_ref);
50825         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50826         return tag_ptr(ret_conv, true);
50827 }
50828
50829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50830         LDKBlindedTail this_obj_conv;
50831         this_obj_conv.inner = untag_ptr(this_obj);
50832         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50834         BlindedTail_free(this_obj_conv);
50835 }
50836
50837 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
50838         LDKBlindedTail this_ptr_conv;
50839         this_ptr_conv.inner = untag_ptr(this_ptr);
50840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50842         this_ptr_conv.is_owned = false;
50843         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
50844         int64_tArray ret_arr = NULL;
50845         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50846         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50847         for (size_t m = 0; m < ret_var.datalen; m++) {
50848                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
50849                 int64_t ret_conv_12_ref = 0;
50850                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
50851                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
50852                 ret_arr_ptr[m] = ret_conv_12_ref;
50853         }
50854         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50855         FREE(ret_var.data);
50856         return ret_arr;
50857 }
50858
50859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50860         LDKBlindedTail this_ptr_conv;
50861         this_ptr_conv.inner = untag_ptr(this_ptr);
50862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50864         this_ptr_conv.is_owned = false;
50865         LDKCVec_BlindedHopZ val_constr;
50866         val_constr.datalen = (*env)->GetArrayLength(env, val);
50867         if (val_constr.datalen > 0)
50868                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50869         else
50870                 val_constr.data = NULL;
50871         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50872         for (size_t m = 0; m < val_constr.datalen; m++) {
50873                 int64_t val_conv_12 = val_vals[m];
50874                 LDKBlindedHop val_conv_12_conv;
50875                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
50876                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
50877                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
50878                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
50879                 val_constr.data[m] = val_conv_12_conv;
50880         }
50881         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50882         BlindedTail_set_hops(&this_ptr_conv, val_constr);
50883 }
50884
50885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
50886         LDKBlindedTail this_ptr_conv;
50887         this_ptr_conv.inner = untag_ptr(this_ptr);
50888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50890         this_ptr_conv.is_owned = false;
50891         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form);
50893         return ret_arr;
50894 }
50895
50896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50897         LDKBlindedTail this_ptr_conv;
50898         this_ptr_conv.inner = untag_ptr(this_ptr);
50899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50901         this_ptr_conv.is_owned = false;
50902         LDKPublicKey val_ref;
50903         CHECK((*env)->GetArrayLength(env, val) == 33);
50904         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50905         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
50906 }
50907
50908 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50909         LDKBlindedTail this_ptr_conv;
50910         this_ptr_conv.inner = untag_ptr(this_ptr);
50911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50913         this_ptr_conv.is_owned = false;
50914         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
50915         return ret_conv;
50916 }
50917
50918 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) {
50919         LDKBlindedTail this_ptr_conv;
50920         this_ptr_conv.inner = untag_ptr(this_ptr);
50921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50923         this_ptr_conv.is_owned = false;
50924         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
50925 }
50926
50927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50928         LDKBlindedTail this_ptr_conv;
50929         this_ptr_conv.inner = untag_ptr(this_ptr);
50930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50932         this_ptr_conv.is_owned = false;
50933         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
50934         return ret_conv;
50935 }
50936
50937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50938         LDKBlindedTail this_ptr_conv;
50939         this_ptr_conv.inner = untag_ptr(this_ptr);
50940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50942         this_ptr_conv.is_owned = false;
50943         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
50944 }
50945
50946 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) {
50947         LDKCVec_BlindedHopZ hops_arg_constr;
50948         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
50949         if (hops_arg_constr.datalen > 0)
50950                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50951         else
50952                 hops_arg_constr.data = NULL;
50953         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
50954         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
50955                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
50956                 LDKBlindedHop hops_arg_conv_12_conv;
50957                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
50958                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
50959                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
50960                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
50961                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
50962         }
50963         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
50964         LDKPublicKey blinding_point_arg_ref;
50965         CHECK((*env)->GetArrayLength(env, blinding_point_arg) == 33);
50966         (*env)->GetByteArrayRegion(env, blinding_point_arg, 0, 33, blinding_point_arg_ref.compressed_form);
50967         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
50968         int64_t ret_ref = 0;
50969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50971         return ret_ref;
50972 }
50973
50974 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
50975         LDKBlindedTail ret_var = BlindedTail_clone(arg);
50976         int64_t ret_ref = 0;
50977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50979         return ret_ref;
50980 }
50981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50982         LDKBlindedTail arg_conv;
50983         arg_conv.inner = untag_ptr(arg);
50984         arg_conv.is_owned = ptr_is_owned(arg);
50985         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50986         arg_conv.is_owned = false;
50987         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
50988         return ret_conv;
50989 }
50990
50991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50992         LDKBlindedTail orig_conv;
50993         orig_conv.inner = untag_ptr(orig);
50994         orig_conv.is_owned = ptr_is_owned(orig);
50995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50996         orig_conv.is_owned = false;
50997         LDKBlindedTail ret_var = BlindedTail_clone(&orig_conv);
50998         int64_t ret_ref = 0;
50999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51001         return ret_ref;
51002 }
51003
51004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1hash(JNIEnv *env, jclass clz, int64_t o) {
51005         LDKBlindedTail o_conv;
51006         o_conv.inner = untag_ptr(o);
51007         o_conv.is_owned = ptr_is_owned(o);
51008         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51009         o_conv.is_owned = false;
51010         int64_t ret_conv = BlindedTail_hash(&o_conv);
51011         return ret_conv;
51012 }
51013
51014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedTail_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51015         LDKBlindedTail a_conv;
51016         a_conv.inner = untag_ptr(a);
51017         a_conv.is_owned = ptr_is_owned(a);
51018         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51019         a_conv.is_owned = false;
51020         LDKBlindedTail b_conv;
51021         b_conv.inner = untag_ptr(b);
51022         b_conv.is_owned = ptr_is_owned(b);
51023         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51024         b_conv.is_owned = false;
51025         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
51026         return ret_conv;
51027 }
51028
51029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1write(JNIEnv *env, jclass clz, int64_t obj) {
51030         LDKBlindedTail obj_conv;
51031         obj_conv.inner = untag_ptr(obj);
51032         obj_conv.is_owned = ptr_is_owned(obj);
51033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51034         obj_conv.is_owned = false;
51035         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
51036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51038         CVec_u8Z_free(ret_var);
51039         return ret_arr;
51040 }
51041
51042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51043         LDKu8slice ser_ref;
51044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51046         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
51047         *ret_conv = BlindedTail_read(ser_ref);
51048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51049         return tag_ptr(ret_conv, true);
51050 }
51051
51052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51053         LDKPath this_obj_conv;
51054         this_obj_conv.inner = untag_ptr(this_obj);
51055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51057         Path_free(this_obj_conv);
51058 }
51059
51060 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Path_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
51061         LDKPath this_ptr_conv;
51062         this_ptr_conv.inner = untag_ptr(this_ptr);
51063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51065         this_ptr_conv.is_owned = false;
51066         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
51067         int64_tArray ret_arr = NULL;
51068         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51069         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51070         for (size_t k = 0; k < ret_var.datalen; k++) {
51071                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
51072                 int64_t ret_conv_10_ref = 0;
51073                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
51074                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
51075                 ret_arr_ptr[k] = ret_conv_10_ref;
51076         }
51077         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51078         FREE(ret_var.data);
51079         return ret_arr;
51080 }
51081
51082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51083         LDKPath this_ptr_conv;
51084         this_ptr_conv.inner = untag_ptr(this_ptr);
51085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51087         this_ptr_conv.is_owned = false;
51088         LDKCVec_RouteHopZ val_constr;
51089         val_constr.datalen = (*env)->GetArrayLength(env, val);
51090         if (val_constr.datalen > 0)
51091                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51092         else
51093                 val_constr.data = NULL;
51094         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51095         for (size_t k = 0; k < val_constr.datalen; k++) {
51096                 int64_t val_conv_10 = val_vals[k];
51097                 LDKRouteHop val_conv_10_conv;
51098                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
51099                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
51100                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
51101                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
51102                 val_constr.data[k] = val_conv_10_conv;
51103         }
51104         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51105         Path_set_hops(&this_ptr_conv, val_constr);
51106 }
51107
51108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1get_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr) {
51109         LDKPath this_ptr_conv;
51110         this_ptr_conv.inner = untag_ptr(this_ptr);
51111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51113         this_ptr_conv.is_owned = false;
51114         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
51115         int64_t ret_ref = 0;
51116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51118         return ret_ref;
51119 }
51120
51121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51122         LDKPath this_ptr_conv;
51123         this_ptr_conv.inner = untag_ptr(this_ptr);
51124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51126         this_ptr_conv.is_owned = false;
51127         LDKBlindedTail val_conv;
51128         val_conv.inner = untag_ptr(val);
51129         val_conv.is_owned = ptr_is_owned(val);
51130         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51131         val_conv = BlindedTail_clone(&val_conv);
51132         Path_set_blinded_tail(&this_ptr_conv, val_conv);
51133 }
51134
51135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int64_t blinded_tail_arg) {
51136         LDKCVec_RouteHopZ hops_arg_constr;
51137         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
51138         if (hops_arg_constr.datalen > 0)
51139                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51140         else
51141                 hops_arg_constr.data = NULL;
51142         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
51143         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
51144                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
51145                 LDKRouteHop hops_arg_conv_10_conv;
51146                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
51147                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
51148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
51149                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
51150                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
51151         }
51152         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
51153         LDKBlindedTail blinded_tail_arg_conv;
51154         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
51155         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
51156         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
51157         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
51158         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
51159         int64_t ret_ref = 0;
51160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51162         return ret_ref;
51163 }
51164
51165 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
51166         LDKPath ret_var = Path_clone(arg);
51167         int64_t ret_ref = 0;
51168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51170         return ret_ref;
51171 }
51172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51173         LDKPath arg_conv;
51174         arg_conv.inner = untag_ptr(arg);
51175         arg_conv.is_owned = ptr_is_owned(arg);
51176         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51177         arg_conv.is_owned = false;
51178         int64_t ret_conv = Path_clone_ptr(&arg_conv);
51179         return ret_conv;
51180 }
51181
51182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51183         LDKPath orig_conv;
51184         orig_conv.inner = untag_ptr(orig);
51185         orig_conv.is_owned = ptr_is_owned(orig);
51186         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51187         orig_conv.is_owned = false;
51188         LDKPath ret_var = Path_clone(&orig_conv);
51189         int64_t ret_ref = 0;
51190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51192         return ret_ref;
51193 }
51194
51195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1hash(JNIEnv *env, jclass clz, int64_t o) {
51196         LDKPath o_conv;
51197         o_conv.inner = untag_ptr(o);
51198         o_conv.is_owned = ptr_is_owned(o);
51199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51200         o_conv.is_owned = false;
51201         int64_t ret_conv = Path_hash(&o_conv);
51202         return ret_conv;
51203 }
51204
51205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Path_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51206         LDKPath a_conv;
51207         a_conv.inner = untag_ptr(a);
51208         a_conv.is_owned = ptr_is_owned(a);
51209         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51210         a_conv.is_owned = false;
51211         LDKPath b_conv;
51212         b_conv.inner = untag_ptr(b);
51213         b_conv.is_owned = ptr_is_owned(b);
51214         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51215         b_conv.is_owned = false;
51216         jboolean ret_conv = Path_eq(&a_conv, &b_conv);
51217         return ret_conv;
51218 }
51219
51220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51221         LDKPath this_arg_conv;
51222         this_arg_conv.inner = untag_ptr(this_arg);
51223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51225         this_arg_conv.is_owned = false;
51226         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
51227         return ret_conv;
51228 }
51229
51230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51231         LDKPath this_arg_conv;
51232         this_arg_conv.inner = untag_ptr(this_arg);
51233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51235         this_arg_conv.is_owned = false;
51236         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
51237         return ret_conv;
51238 }
51239
51240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1cltv_1expiry_1delta(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         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
51247         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
51248         int64_t ret_ref = tag_ptr(ret_copy, true);
51249         return ret_ref;
51250 }
51251
51252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51253         LDKRoute this_obj_conv;
51254         this_obj_conv.inner = untag_ptr(this_obj);
51255         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51257         Route_free(this_obj_conv);
51258 }
51259
51260 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
51261         LDKRoute this_ptr_conv;
51262         this_ptr_conv.inner = untag_ptr(this_ptr);
51263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51265         this_ptr_conv.is_owned = false;
51266         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
51267         int64_tArray ret_arr = NULL;
51268         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51269         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51270         for (size_t g = 0; g < ret_var.datalen; g++) {
51271                 LDKPath ret_conv_6_var = ret_var.data[g];
51272                 int64_t ret_conv_6_ref = 0;
51273                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
51274                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
51275                 ret_arr_ptr[g] = ret_conv_6_ref;
51276         }
51277         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51278         FREE(ret_var.data);
51279         return ret_arr;
51280 }
51281
51282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51283         LDKRoute this_ptr_conv;
51284         this_ptr_conv.inner = untag_ptr(this_ptr);
51285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51287         this_ptr_conv.is_owned = false;
51288         LDKCVec_PathZ val_constr;
51289         val_constr.datalen = (*env)->GetArrayLength(env, val);
51290         if (val_constr.datalen > 0)
51291                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51292         else
51293                 val_constr.data = NULL;
51294         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51295         for (size_t g = 0; g < val_constr.datalen; g++) {
51296                 int64_t val_conv_6 = val_vals[g];
51297                 LDKPath val_conv_6_conv;
51298                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
51299                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
51300                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
51301                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
51302                 val_constr.data[g] = val_conv_6_conv;
51303         }
51304         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51305         Route_set_paths(&this_ptr_conv, val_constr);
51306 }
51307
51308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51309         LDKRoute this_ptr_conv;
51310         this_ptr_conv.inner = untag_ptr(this_ptr);
51311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51313         this_ptr_conv.is_owned = false;
51314         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
51315         int64_t ret_ref = 0;
51316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51318         return ret_ref;
51319 }
51320
51321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51322         LDKRoute this_ptr_conv;
51323         this_ptr_conv.inner = untag_ptr(this_ptr);
51324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51326         this_ptr_conv.is_owned = false;
51327         LDKPaymentParameters val_conv;
51328         val_conv.inner = untag_ptr(val);
51329         val_conv.is_owned = ptr_is_owned(val);
51330         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51331         val_conv = PaymentParameters_clone(&val_conv);
51332         Route_set_payment_params(&this_ptr_conv, val_conv);
51333 }
51334
51335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, int64_tArray paths_arg, int64_t payment_params_arg) {
51336         LDKCVec_PathZ paths_arg_constr;
51337         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
51338         if (paths_arg_constr.datalen > 0)
51339                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51340         else
51341                 paths_arg_constr.data = NULL;
51342         int64_t* paths_arg_vals = (*env)->GetLongArrayElements (env, paths_arg, NULL);
51343         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
51344                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
51345                 LDKPath paths_arg_conv_6_conv;
51346                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
51347                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
51348                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
51349                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
51350                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
51351         }
51352         (*env)->ReleaseLongArrayElements(env, paths_arg, paths_arg_vals, 0);
51353         LDKPaymentParameters payment_params_arg_conv;
51354         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51355         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51356         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51357         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51358         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
51359         int64_t ret_ref = 0;
51360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51362         return ret_ref;
51363 }
51364
51365 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
51366         LDKRoute ret_var = Route_clone(arg);
51367         int64_t ret_ref = 0;
51368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51370         return ret_ref;
51371 }
51372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51373         LDKRoute arg_conv;
51374         arg_conv.inner = untag_ptr(arg);
51375         arg_conv.is_owned = ptr_is_owned(arg);
51376         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51377         arg_conv.is_owned = false;
51378         int64_t ret_conv = Route_clone_ptr(&arg_conv);
51379         return ret_conv;
51380 }
51381
51382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51383         LDKRoute orig_conv;
51384         orig_conv.inner = untag_ptr(orig);
51385         orig_conv.is_owned = ptr_is_owned(orig);
51386         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51387         orig_conv.is_owned = false;
51388         LDKRoute ret_var = Route_clone(&orig_conv);
51389         int64_t ret_ref = 0;
51390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51392         return ret_ref;
51393 }
51394
51395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
51396         LDKRoute o_conv;
51397         o_conv.inner = untag_ptr(o);
51398         o_conv.is_owned = ptr_is_owned(o);
51399         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51400         o_conv.is_owned = false;
51401         int64_t ret_conv = Route_hash(&o_conv);
51402         return ret_conv;
51403 }
51404
51405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51406         LDKRoute a_conv;
51407         a_conv.inner = untag_ptr(a);
51408         a_conv.is_owned = ptr_is_owned(a);
51409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51410         a_conv.is_owned = false;
51411         LDKRoute b_conv;
51412         b_conv.inner = untag_ptr(b);
51413         b_conv.is_owned = ptr_is_owned(b);
51414         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51415         b_conv.is_owned = false;
51416         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
51417         return ret_conv;
51418 }
51419
51420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
51421         LDKRoute this_arg_conv;
51422         this_arg_conv.inner = untag_ptr(this_arg);
51423         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51425         this_arg_conv.is_owned = false;
51426         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
51427         return ret_conv;
51428 }
51429
51430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
51431         LDKRoute this_arg_conv;
51432         this_arg_conv.inner = untag_ptr(this_arg);
51433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51435         this_arg_conv.is_owned = false;
51436         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
51437         return ret_conv;
51438 }
51439
51440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
51441         LDKRoute obj_conv;
51442         obj_conv.inner = untag_ptr(obj);
51443         obj_conv.is_owned = ptr_is_owned(obj);
51444         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51445         obj_conv.is_owned = false;
51446         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
51447         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51448         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51449         CVec_u8Z_free(ret_var);
51450         return ret_arr;
51451 }
51452
51453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51454         LDKu8slice ser_ref;
51455         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51456         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51457         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
51458         *ret_conv = Route_read(ser_ref);
51459         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51460         return tag_ptr(ret_conv, true);
51461 }
51462
51463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51464         LDKRouteParameters this_obj_conv;
51465         this_obj_conv.inner = untag_ptr(this_obj);
51466         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51468         RouteParameters_free(this_obj_conv);
51469 }
51470
51471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51472         LDKRouteParameters this_ptr_conv;
51473         this_ptr_conv.inner = untag_ptr(this_ptr);
51474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51476         this_ptr_conv.is_owned = false;
51477         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
51478         int64_t ret_ref = 0;
51479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51481         return ret_ref;
51482 }
51483
51484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51485         LDKRouteParameters this_ptr_conv;
51486         this_ptr_conv.inner = untag_ptr(this_ptr);
51487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51489         this_ptr_conv.is_owned = false;
51490         LDKPaymentParameters val_conv;
51491         val_conv.inner = untag_ptr(val);
51492         val_conv.is_owned = ptr_is_owned(val);
51493         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51494         val_conv = PaymentParameters_clone(&val_conv);
51495         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
51496 }
51497
51498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51499         LDKRouteParameters this_ptr_conv;
51500         this_ptr_conv.inner = untag_ptr(this_ptr);
51501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51503         this_ptr_conv.is_owned = false;
51504         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
51505         return ret_conv;
51506 }
51507
51508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51509         LDKRouteParameters this_ptr_conv;
51510         this_ptr_conv.inner = untag_ptr(this_ptr);
51511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51513         this_ptr_conv.is_owned = false;
51514         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
51515 }
51516
51517 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) {
51518         LDKPaymentParameters payment_params_arg_conv;
51519         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51520         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51521         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51522         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51523         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg);
51524         int64_t ret_ref = 0;
51525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51527         return ret_ref;
51528 }
51529
51530 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
51531         LDKRouteParameters ret_var = RouteParameters_clone(arg);
51532         int64_t ret_ref = 0;
51533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51535         return ret_ref;
51536 }
51537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51538         LDKRouteParameters arg_conv;
51539         arg_conv.inner = untag_ptr(arg);
51540         arg_conv.is_owned = ptr_is_owned(arg);
51541         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51542         arg_conv.is_owned = false;
51543         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
51544         return ret_conv;
51545 }
51546
51547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51548         LDKRouteParameters orig_conv;
51549         orig_conv.inner = untag_ptr(orig);
51550         orig_conv.is_owned = ptr_is_owned(orig);
51551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51552         orig_conv.is_owned = false;
51553         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
51554         int64_t ret_ref = 0;
51555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51557         return ret_ref;
51558 }
51559
51560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51561         LDKRouteParameters a_conv;
51562         a_conv.inner = untag_ptr(a);
51563         a_conv.is_owned = ptr_is_owned(a);
51564         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51565         a_conv.is_owned = false;
51566         LDKRouteParameters b_conv;
51567         b_conv.inner = untag_ptr(b);
51568         b_conv.is_owned = ptr_is_owned(b);
51569         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51570         b_conv.is_owned = false;
51571         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
51572         return ret_conv;
51573 }
51574
51575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51576         LDKRouteParameters obj_conv;
51577         obj_conv.inner = untag_ptr(obj);
51578         obj_conv.is_owned = ptr_is_owned(obj);
51579         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51580         obj_conv.is_owned = false;
51581         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
51582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51584         CVec_u8Z_free(ret_var);
51585         return ret_arr;
51586 }
51587
51588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51589         LDKu8slice ser_ref;
51590         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51591         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51592         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
51593         *ret_conv = RouteParameters_read(ser_ref);
51594         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51595         return tag_ptr(ret_conv, true);
51596 }
51597
51598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51599         LDKPaymentParameters this_obj_conv;
51600         this_obj_conv.inner = untag_ptr(this_obj);
51601         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51603         PaymentParameters_free(this_obj_conv);
51604 }
51605
51606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
51607         LDKPaymentParameters this_ptr_conv;
51608         this_ptr_conv.inner = untag_ptr(this_ptr);
51609         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51611         this_ptr_conv.is_owned = false;
51612         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
51614         return ret_arr;
51615 }
51616
51617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51618         LDKPaymentParameters this_ptr_conv;
51619         this_ptr_conv.inner = untag_ptr(this_ptr);
51620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51622         this_ptr_conv.is_owned = false;
51623         LDKPublicKey val_ref;
51624         CHECK((*env)->GetArrayLength(env, val) == 33);
51625         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51626         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
51627 }
51628
51629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
51630         LDKPaymentParameters this_ptr_conv;
51631         this_ptr_conv.inner = untag_ptr(this_ptr);
51632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51634         this_ptr_conv.is_owned = false;
51635         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
51636         int64_t ret_ref = 0;
51637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51638         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51639         return ret_ref;
51640 }
51641
51642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51643         LDKPaymentParameters this_ptr_conv;
51644         this_ptr_conv.inner = untag_ptr(this_ptr);
51645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51647         this_ptr_conv.is_owned = false;
51648         LDKInvoiceFeatures val_conv;
51649         val_conv.inner = untag_ptr(val);
51650         val_conv.is_owned = ptr_is_owned(val);
51651         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51652         val_conv = InvoiceFeatures_clone(&val_conv);
51653         PaymentParameters_set_features(&this_ptr_conv, val_conv);
51654 }
51655
51656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
51657         LDKPaymentParameters this_ptr_conv;
51658         this_ptr_conv.inner = untag_ptr(this_ptr);
51659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51661         this_ptr_conv.is_owned = false;
51662         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51663         *ret_copy = PaymentParameters_get_route_hints(&this_ptr_conv);
51664         int64_t ret_ref = tag_ptr(ret_copy, true);
51665         return ret_ref;
51666 }
51667
51668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51669         LDKPaymentParameters this_ptr_conv;
51670         this_ptr_conv.inner = untag_ptr(this_ptr);
51671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51673         this_ptr_conv.is_owned = false;
51674         void* val_ptr = untag_ptr(val);
51675         CHECK_ACCESS(val_ptr);
51676         LDKHints val_conv = *(LDKHints*)(val_ptr);
51677         val_conv = Hints_clone((LDKHints*)untag_ptr(val));
51678         PaymentParameters_set_route_hints(&this_ptr_conv, val_conv);
51679 }
51680
51681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
51682         LDKPaymentParameters this_ptr_conv;
51683         this_ptr_conv.inner = untag_ptr(this_ptr);
51684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51686         this_ptr_conv.is_owned = false;
51687         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51688         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
51689         int64_t ret_ref = tag_ptr(ret_copy, true);
51690         return ret_ref;
51691 }
51692
51693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51694         LDKPaymentParameters this_ptr_conv;
51695         this_ptr_conv.inner = untag_ptr(this_ptr);
51696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51698         this_ptr_conv.is_owned = false;
51699         void* val_ptr = untag_ptr(val);
51700         CHECK_ACCESS(val_ptr);
51701         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
51702         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
51703         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
51704 }
51705
51706 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51707         LDKPaymentParameters this_ptr_conv;
51708         this_ptr_conv.inner = untag_ptr(this_ptr);
51709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51711         this_ptr_conv.is_owned = false;
51712         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
51713         return ret_conv;
51714 }
51715
51716 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) {
51717         LDKPaymentParameters this_ptr_conv;
51718         this_ptr_conv.inner = untag_ptr(this_ptr);
51719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51721         this_ptr_conv.is_owned = false;
51722         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
51723 }
51724
51725 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
51726         LDKPaymentParameters this_ptr_conv;
51727         this_ptr_conv.inner = untag_ptr(this_ptr);
51728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51730         this_ptr_conv.is_owned = false;
51731         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
51732         return ret_conv;
51733 }
51734
51735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
51736         LDKPaymentParameters this_ptr_conv;
51737         this_ptr_conv.inner = untag_ptr(this_ptr);
51738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51740         this_ptr_conv.is_owned = false;
51741         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
51742 }
51743
51744 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) {
51745         LDKPaymentParameters this_ptr_conv;
51746         this_ptr_conv.inner = untag_ptr(this_ptr);
51747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51749         this_ptr_conv.is_owned = false;
51750         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
51751         return ret_conv;
51752 }
51753
51754 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) {
51755         LDKPaymentParameters this_ptr_conv;
51756         this_ptr_conv.inner = untag_ptr(this_ptr);
51757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51759         this_ptr_conv.is_owned = false;
51760         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
51761 }
51762
51763 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
51764         LDKPaymentParameters this_ptr_conv;
51765         this_ptr_conv.inner = untag_ptr(this_ptr);
51766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51768         this_ptr_conv.is_owned = false;
51769         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
51770         int64_tArray ret_arr = NULL;
51771         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51772         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51773         for (size_t g = 0; g < ret_var.datalen; g++) {
51774                 int64_t ret_conv_6_conv = ret_var.data[g];
51775                 ret_arr_ptr[g] = ret_conv_6_conv;
51776         }
51777         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51778         FREE(ret_var.data);
51779         return ret_arr;
51780 }
51781
51782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51783         LDKPaymentParameters this_ptr_conv;
51784         this_ptr_conv.inner = untag_ptr(this_ptr);
51785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51787         this_ptr_conv.is_owned = false;
51788         LDKCVec_u64Z val_constr;
51789         val_constr.datalen = (*env)->GetArrayLength(env, val);
51790         if (val_constr.datalen > 0)
51791                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51792         else
51793                 val_constr.data = NULL;
51794         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51795         for (size_t g = 0; g < val_constr.datalen; g++) {
51796                 int64_t val_conv_6 = val_vals[g];
51797                 val_constr.data[g] = val_conv_6;
51798         }
51799         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51800         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
51801 }
51802
51803 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51804         LDKPaymentParameters this_ptr_conv;
51805         this_ptr_conv.inner = untag_ptr(this_ptr);
51806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51808         this_ptr_conv.is_owned = false;
51809         int32_t ret_conv = PaymentParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
51810         return ret_conv;
51811 }
51812
51813 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) {
51814         LDKPaymentParameters this_ptr_conv;
51815         this_ptr_conv.inner = untag_ptr(this_ptr);
51816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51818         this_ptr_conv.is_owned = false;
51819         PaymentParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
51820 }
51821
51822 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) {
51823         LDKPublicKey payee_pubkey_arg_ref;
51824         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
51825         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
51826         LDKInvoiceFeatures features_arg_conv;
51827         features_arg_conv.inner = untag_ptr(features_arg);
51828         features_arg_conv.is_owned = ptr_is_owned(features_arg);
51829         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
51830         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
51831         void* route_hints_arg_ptr = untag_ptr(route_hints_arg);
51832         CHECK_ACCESS(route_hints_arg_ptr);
51833         LDKHints route_hints_arg_conv = *(LDKHints*)(route_hints_arg_ptr);
51834         route_hints_arg_conv = Hints_clone((LDKHints*)untag_ptr(route_hints_arg));
51835         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
51836         CHECK_ACCESS(expiry_time_arg_ptr);
51837         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
51838         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
51839         LDKCVec_u64Z previously_failed_channels_arg_constr;
51840         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
51841         if (previously_failed_channels_arg_constr.datalen > 0)
51842                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51843         else
51844                 previously_failed_channels_arg_constr.data = NULL;
51845         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
51846         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
51847                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
51848                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
51849         }
51850         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
51851         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);
51852         int64_t ret_ref = 0;
51853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51855         return ret_ref;
51856 }
51857
51858 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
51859         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
51860         int64_t ret_ref = 0;
51861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51863         return ret_ref;
51864 }
51865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51866         LDKPaymentParameters arg_conv;
51867         arg_conv.inner = untag_ptr(arg);
51868         arg_conv.is_owned = ptr_is_owned(arg);
51869         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51870         arg_conv.is_owned = false;
51871         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
51872         return ret_conv;
51873 }
51874
51875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51876         LDKPaymentParameters orig_conv;
51877         orig_conv.inner = untag_ptr(orig);
51878         orig_conv.is_owned = ptr_is_owned(orig);
51879         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51880         orig_conv.is_owned = false;
51881         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
51882         int64_t ret_ref = 0;
51883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51885         return ret_ref;
51886 }
51887
51888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
51889         LDKPaymentParameters o_conv;
51890         o_conv.inner = untag_ptr(o);
51891         o_conv.is_owned = ptr_is_owned(o);
51892         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51893         o_conv.is_owned = false;
51894         int64_t ret_conv = PaymentParameters_hash(&o_conv);
51895         return ret_conv;
51896 }
51897
51898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51899         LDKPaymentParameters a_conv;
51900         a_conv.inner = untag_ptr(a);
51901         a_conv.is_owned = ptr_is_owned(a);
51902         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51903         a_conv.is_owned = false;
51904         LDKPaymentParameters b_conv;
51905         b_conv.inner = untag_ptr(b);
51906         b_conv.is_owned = ptr_is_owned(b);
51907         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51908         b_conv.is_owned = false;
51909         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
51910         return ret_conv;
51911 }
51912
51913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51914         LDKPaymentParameters obj_conv;
51915         obj_conv.inner = untag_ptr(obj);
51916         obj_conv.is_owned = ptr_is_owned(obj);
51917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51918         obj_conv.is_owned = false;
51919         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
51920         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51921         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51922         CVec_u8Z_free(ret_var);
51923         return ret_arr;
51924 }
51925
51926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser, int32_t arg) {
51927         LDKu8slice ser_ref;
51928         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51929         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51930         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
51931         *ret_conv = PaymentParameters_read(ser_ref, arg);
51932         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51933         return tag_ptr(ret_conv, true);
51934 }
51935
51936 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) {
51937         LDKPublicKey payee_pubkey_ref;
51938         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51939         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51940         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
51941         int64_t ret_ref = 0;
51942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51944         return ret_ref;
51945 }
51946
51947 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) {
51948         LDKPublicKey payee_pubkey_ref;
51949         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51950         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51951         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta);
51952         int64_t ret_ref = 0;
51953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51955         return ret_ref;
51956 }
51957
51958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hints_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51959         if (!ptr_is_owned(this_ptr)) return;
51960         void* this_ptr_ptr = untag_ptr(this_ptr);
51961         CHECK_ACCESS(this_ptr_ptr);
51962         LDKHints this_ptr_conv = *(LDKHints*)(this_ptr_ptr);
51963         FREE(untag_ptr(this_ptr));
51964         Hints_free(this_ptr_conv);
51965 }
51966
51967 static inline uint64_t Hints_clone_ptr(LDKHints *NONNULL_PTR arg) {
51968         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51969         *ret_copy = Hints_clone(arg);
51970         int64_t ret_ref = tag_ptr(ret_copy, true);
51971         return ret_ref;
51972 }
51973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51974         LDKHints* arg_conv = (LDKHints*)untag_ptr(arg);
51975         int64_t ret_conv = Hints_clone_ptr(arg_conv);
51976         return ret_conv;
51977 }
51978
51979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51980         LDKHints* orig_conv = (LDKHints*)untag_ptr(orig);
51981         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51982         *ret_copy = Hints_clone(orig_conv);
51983         int64_t ret_ref = tag_ptr(ret_copy, true);
51984         return ret_ref;
51985 }
51986
51987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1blinded(JNIEnv *env, jclass clz, int64_tArray a) {
51988         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a_constr;
51989         a_constr.datalen = (*env)->GetArrayLength(env, a);
51990         if (a_constr.datalen > 0)
51991                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
51992         else
51993                 a_constr.data = NULL;
51994         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
51995         for (size_t l = 0; l < a_constr.datalen; l++) {
51996                 int64_t a_conv_37 = a_vals[l];
51997                 void* a_conv_37_ptr = untag_ptr(a_conv_37);
51998                 CHECK_ACCESS(a_conv_37_ptr);
51999                 LDKC2Tuple_BlindedPayInfoBlindedPathZ a_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(a_conv_37_ptr);
52000                 a_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(a_conv_37));
52001                 a_constr.data[l] = a_conv_37_conv;
52002         }
52003         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52004         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52005         *ret_copy = Hints_blinded(a_constr);
52006         int64_t ret_ref = tag_ptr(ret_copy, true);
52007         return ret_ref;
52008 }
52009
52010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clear(JNIEnv *env, jclass clz, int64_tArray a) {
52011         LDKCVec_RouteHintZ a_constr;
52012         a_constr.datalen = (*env)->GetArrayLength(env, a);
52013         if (a_constr.datalen > 0)
52014                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
52015         else
52016                 a_constr.data = NULL;
52017         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52018         for (size_t l = 0; l < a_constr.datalen; l++) {
52019                 int64_t a_conv_11 = a_vals[l];
52020                 LDKRouteHint a_conv_11_conv;
52021                 a_conv_11_conv.inner = untag_ptr(a_conv_11);
52022                 a_conv_11_conv.is_owned = ptr_is_owned(a_conv_11);
52023                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv_11_conv);
52024                 a_conv_11_conv = RouteHint_clone(&a_conv_11_conv);
52025                 a_constr.data[l] = a_conv_11_conv;
52026         }
52027         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52028         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52029         *ret_copy = Hints_clear(a_constr);
52030         int64_t ret_ref = tag_ptr(ret_copy, true);
52031         return ret_ref;
52032 }
52033
52034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1hash(JNIEnv *env, jclass clz, int64_t o) {
52035         LDKHints* o_conv = (LDKHints*)untag_ptr(o);
52036         int64_t ret_conv = Hints_hash(o_conv);
52037         return ret_conv;
52038 }
52039
52040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hints_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52041         LDKHints* a_conv = (LDKHints*)untag_ptr(a);
52042         LDKHints* b_conv = (LDKHints*)untag_ptr(b);
52043         jboolean ret_conv = Hints_eq(a_conv, b_conv);
52044         return ret_conv;
52045 }
52046
52047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52048         LDKRouteHint this_obj_conv;
52049         this_obj_conv.inner = untag_ptr(this_obj);
52050         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52052         RouteHint_free(this_obj_conv);
52053 }
52054
52055 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
52056         LDKRouteHint this_ptr_conv;
52057         this_ptr_conv.inner = untag_ptr(this_ptr);
52058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52060         this_ptr_conv.is_owned = false;
52061         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
52062         int64_tArray ret_arr = NULL;
52063         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52064         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52065         for (size_t o = 0; o < ret_var.datalen; o++) {
52066                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
52067                 int64_t ret_conv_14_ref = 0;
52068                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52069                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52070                 ret_arr_ptr[o] = ret_conv_14_ref;
52071         }
52072         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52073         FREE(ret_var.data);
52074         return ret_arr;
52075 }
52076
52077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
52078         LDKRouteHint this_ptr_conv;
52079         this_ptr_conv.inner = untag_ptr(this_ptr);
52080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52082         this_ptr_conv.is_owned = false;
52083         LDKCVec_RouteHintHopZ val_constr;
52084         val_constr.datalen = (*env)->GetArrayLength(env, val);
52085         if (val_constr.datalen > 0)
52086                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52087         else
52088                 val_constr.data = NULL;
52089         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
52090         for (size_t o = 0; o < val_constr.datalen; o++) {
52091                 int64_t val_conv_14 = val_vals[o];
52092                 LDKRouteHintHop val_conv_14_conv;
52093                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
52094                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
52095                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
52096                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
52097                 val_constr.data[o] = val_conv_14_conv;
52098         }
52099         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
52100         RouteHint_set_a(&this_ptr_conv, val_constr);
52101 }
52102
52103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
52104         LDKCVec_RouteHintHopZ a_arg_constr;
52105         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
52106         if (a_arg_constr.datalen > 0)
52107                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52108         else
52109                 a_arg_constr.data = NULL;
52110         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
52111         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
52112                 int64_t a_arg_conv_14 = a_arg_vals[o];
52113                 LDKRouteHintHop a_arg_conv_14_conv;
52114                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
52115                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
52116                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
52117                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
52118                 a_arg_constr.data[o] = a_arg_conv_14_conv;
52119         }
52120         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
52121         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
52122         int64_t ret_ref = 0;
52123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52125         return ret_ref;
52126 }
52127
52128 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
52129         LDKRouteHint ret_var = RouteHint_clone(arg);
52130         int64_t ret_ref = 0;
52131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52133         return ret_ref;
52134 }
52135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52136         LDKRouteHint arg_conv;
52137         arg_conv.inner = untag_ptr(arg);
52138         arg_conv.is_owned = ptr_is_owned(arg);
52139         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52140         arg_conv.is_owned = false;
52141         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
52142         return ret_conv;
52143 }
52144
52145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52146         LDKRouteHint orig_conv;
52147         orig_conv.inner = untag_ptr(orig);
52148         orig_conv.is_owned = ptr_is_owned(orig);
52149         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52150         orig_conv.is_owned = false;
52151         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
52152         int64_t ret_ref = 0;
52153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52155         return ret_ref;
52156 }
52157
52158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
52159         LDKRouteHint o_conv;
52160         o_conv.inner = untag_ptr(o);
52161         o_conv.is_owned = ptr_is_owned(o);
52162         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52163         o_conv.is_owned = false;
52164         int64_t ret_conv = RouteHint_hash(&o_conv);
52165         return ret_conv;
52166 }
52167
52168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52169         LDKRouteHint a_conv;
52170         a_conv.inner = untag_ptr(a);
52171         a_conv.is_owned = ptr_is_owned(a);
52172         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52173         a_conv.is_owned = false;
52174         LDKRouteHint b_conv;
52175         b_conv.inner = untag_ptr(b);
52176         b_conv.is_owned = ptr_is_owned(b);
52177         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52178         b_conv.is_owned = false;
52179         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
52180         return ret_conv;
52181 }
52182
52183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
52184         LDKRouteHint obj_conv;
52185         obj_conv.inner = untag_ptr(obj);
52186         obj_conv.is_owned = ptr_is_owned(obj);
52187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52188         obj_conv.is_owned = false;
52189         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
52190         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52191         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52192         CVec_u8Z_free(ret_var);
52193         return ret_arr;
52194 }
52195
52196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52197         LDKu8slice ser_ref;
52198         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52199         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52200         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
52201         *ret_conv = RouteHint_read(ser_ref);
52202         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52203         return tag_ptr(ret_conv, true);
52204 }
52205
52206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52207         LDKRouteHintHop this_obj_conv;
52208         this_obj_conv.inner = untag_ptr(this_obj);
52209         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52211         RouteHintHop_free(this_obj_conv);
52212 }
52213
52214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52215         LDKRouteHintHop this_ptr_conv;
52216         this_ptr_conv.inner = untag_ptr(this_ptr);
52217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52219         this_ptr_conv.is_owned = false;
52220         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
52222         return ret_arr;
52223 }
52224
52225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
52226         LDKRouteHintHop this_ptr_conv;
52227         this_ptr_conv.inner = untag_ptr(this_ptr);
52228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52230         this_ptr_conv.is_owned = false;
52231         LDKPublicKey val_ref;
52232         CHECK((*env)->GetArrayLength(env, val) == 33);
52233         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
52234         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
52235 }
52236
52237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52238         LDKRouteHintHop this_ptr_conv;
52239         this_ptr_conv.inner = untag_ptr(this_ptr);
52240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52242         this_ptr_conv.is_owned = false;
52243         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
52244         return ret_conv;
52245 }
52246
52247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52248         LDKRouteHintHop this_ptr_conv;
52249         this_ptr_conv.inner = untag_ptr(this_ptr);
52250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52252         this_ptr_conv.is_owned = false;
52253         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
52254 }
52255
52256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
52257         LDKRouteHintHop this_ptr_conv;
52258         this_ptr_conv.inner = untag_ptr(this_ptr);
52259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52261         this_ptr_conv.is_owned = false;
52262         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
52263         int64_t ret_ref = 0;
52264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52266         return ret_ref;
52267 }
52268
52269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52270         LDKRouteHintHop this_ptr_conv;
52271         this_ptr_conv.inner = untag_ptr(this_ptr);
52272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52274         this_ptr_conv.is_owned = false;
52275         LDKRoutingFees val_conv;
52276         val_conv.inner = untag_ptr(val);
52277         val_conv.is_owned = ptr_is_owned(val);
52278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52279         val_conv = RoutingFees_clone(&val_conv);
52280         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
52281 }
52282
52283 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
52284         LDKRouteHintHop this_ptr_conv;
52285         this_ptr_conv.inner = untag_ptr(this_ptr);
52286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52288         this_ptr_conv.is_owned = false;
52289         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
52290         return ret_conv;
52291 }
52292
52293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
52294         LDKRouteHintHop this_ptr_conv;
52295         this_ptr_conv.inner = untag_ptr(this_ptr);
52296         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52298         this_ptr_conv.is_owned = false;
52299         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
52300 }
52301
52302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52303         LDKRouteHintHop this_ptr_conv;
52304         this_ptr_conv.inner = untag_ptr(this_ptr);
52305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52307         this_ptr_conv.is_owned = false;
52308         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52309         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
52310         int64_t ret_ref = tag_ptr(ret_copy, true);
52311         return ret_ref;
52312 }
52313
52314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52315         LDKRouteHintHop this_ptr_conv;
52316         this_ptr_conv.inner = untag_ptr(this_ptr);
52317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52319         this_ptr_conv.is_owned = false;
52320         void* val_ptr = untag_ptr(val);
52321         CHECK_ACCESS(val_ptr);
52322         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52323         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52324         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
52325 }
52326
52327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52328         LDKRouteHintHop this_ptr_conv;
52329         this_ptr_conv.inner = untag_ptr(this_ptr);
52330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52332         this_ptr_conv.is_owned = false;
52333         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52334         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
52335         int64_t ret_ref = tag_ptr(ret_copy, true);
52336         return ret_ref;
52337 }
52338
52339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52340         LDKRouteHintHop this_ptr_conv;
52341         this_ptr_conv.inner = untag_ptr(this_ptr);
52342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52344         this_ptr_conv.is_owned = false;
52345         void* val_ptr = untag_ptr(val);
52346         CHECK_ACCESS(val_ptr);
52347         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52348         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52349         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
52350 }
52351
52352 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) {
52353         LDKPublicKey src_node_id_arg_ref;
52354         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
52355         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
52356         LDKRoutingFees fees_arg_conv;
52357         fees_arg_conv.inner = untag_ptr(fees_arg);
52358         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
52359         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
52360         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
52361         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
52362         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
52363         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
52364         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
52365         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
52366         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
52367         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
52368         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
52369         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);
52370         int64_t ret_ref = 0;
52371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52373         return ret_ref;
52374 }
52375
52376 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
52377         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
52378         int64_t ret_ref = 0;
52379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52380         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52381         return ret_ref;
52382 }
52383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52384         LDKRouteHintHop arg_conv;
52385         arg_conv.inner = untag_ptr(arg);
52386         arg_conv.is_owned = ptr_is_owned(arg);
52387         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52388         arg_conv.is_owned = false;
52389         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
52390         return ret_conv;
52391 }
52392
52393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52394         LDKRouteHintHop orig_conv;
52395         orig_conv.inner = untag_ptr(orig);
52396         orig_conv.is_owned = ptr_is_owned(orig);
52397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52398         orig_conv.is_owned = false;
52399         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
52400         int64_t ret_ref = 0;
52401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52403         return ret_ref;
52404 }
52405
52406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
52407         LDKRouteHintHop o_conv;
52408         o_conv.inner = untag_ptr(o);
52409         o_conv.is_owned = ptr_is_owned(o);
52410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52411         o_conv.is_owned = false;
52412         int64_t ret_conv = RouteHintHop_hash(&o_conv);
52413         return ret_conv;
52414 }
52415
52416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52417         LDKRouteHintHop a_conv;
52418         a_conv.inner = untag_ptr(a);
52419         a_conv.is_owned = ptr_is_owned(a);
52420         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52421         a_conv.is_owned = false;
52422         LDKRouteHintHop b_conv;
52423         b_conv.inner = untag_ptr(b);
52424         b_conv.is_owned = ptr_is_owned(b);
52425         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52426         b_conv.is_owned = false;
52427         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
52428         return ret_conv;
52429 }
52430
52431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
52432         LDKRouteHintHop obj_conv;
52433         obj_conv.inner = untag_ptr(obj);
52434         obj_conv.is_owned = ptr_is_owned(obj);
52435         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52436         obj_conv.is_owned = false;
52437         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
52438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52440         CVec_u8Z_free(ret_var);
52441         return ret_arr;
52442 }
52443
52444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52445         LDKu8slice ser_ref;
52446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52448         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
52449         *ret_conv = RouteHintHop_read(ser_ref);
52450         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52451         return tag_ptr(ret_conv, true);
52452 }
52453
52454 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) {
52455         LDKPublicKey our_node_pubkey_ref;
52456         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52457         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52458         LDKRouteParameters route_params_conv;
52459         route_params_conv.inner = untag_ptr(route_params);
52460         route_params_conv.is_owned = ptr_is_owned(route_params);
52461         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52462         route_params_conv.is_owned = false;
52463         LDKNetworkGraph network_graph_conv;
52464         network_graph_conv.inner = untag_ptr(network_graph);
52465         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52466         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52467         network_graph_conv.is_owned = false;
52468         LDKCVec_ChannelDetailsZ first_hops_constr;
52469         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
52470         if (first_hops != NULL) {
52471                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
52472                 if (first_hops_constr.datalen > 0)
52473                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
52474                 else
52475                         first_hops_constr.data = NULL;
52476                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
52477                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
52478                         int64_t first_hops_conv_16 = first_hops_vals[q];
52479                         LDKChannelDetails first_hops_conv_16_conv;
52480                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
52481                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
52482                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
52483                         first_hops_conv_16_conv.is_owned = false;
52484                         first_hops_constr.data[q] = first_hops_conv_16_conv;
52485                 }
52486                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
52487                 first_hops_ptr = &first_hops_constr;
52488         }
52489         void* logger_ptr = untag_ptr(logger);
52490         CHECK_ACCESS(logger_ptr);
52491         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52492         if (logger_conv.free == LDKLogger_JCalls_free) {
52493                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52494                 LDKLogger_JCalls_cloned(&logger_conv);
52495         }
52496         void* scorer_ptr = untag_ptr(scorer);
52497         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
52498         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
52499         uint8_t random_seed_bytes_arr[32];
52500         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52501         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52502         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52503         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52504         *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);
52505         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
52506         return tag_ptr(ret_conv, true);
52507 }
52508
52509 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) {
52510         LDKPublicKey our_node_pubkey_ref;
52511         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52512         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52513         LDKCVec_PublicKeyZ hops_constr;
52514         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
52515         if (hops_constr.datalen > 0)
52516                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
52517         else
52518                 hops_constr.data = NULL;
52519         for (size_t i = 0; i < hops_constr.datalen; i++) {
52520                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
52521                 LDKPublicKey hops_conv_8_ref;
52522                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
52523                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
52524                 hops_constr.data[i] = hops_conv_8_ref;
52525         }
52526         LDKRouteParameters route_params_conv;
52527         route_params_conv.inner = untag_ptr(route_params);
52528         route_params_conv.is_owned = ptr_is_owned(route_params);
52529         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52530         route_params_conv.is_owned = false;
52531         LDKNetworkGraph network_graph_conv;
52532         network_graph_conv.inner = untag_ptr(network_graph);
52533         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52534         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52535         network_graph_conv.is_owned = false;
52536         void* logger_ptr = untag_ptr(logger);
52537         CHECK_ACCESS(logger_ptr);
52538         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52539         if (logger_conv.free == LDKLogger_JCalls_free) {
52540                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52541                 LDKLogger_JCalls_cloned(&logger_conv);
52542         }
52543         uint8_t random_seed_bytes_arr[32];
52544         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52545         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52546         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52547         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52548         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
52549         return tag_ptr(ret_conv, true);
52550 }
52551
52552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52553         if (!ptr_is_owned(this_ptr)) return;
52554         void* this_ptr_ptr = untag_ptr(this_ptr);
52555         CHECK_ACCESS(this_ptr_ptr);
52556         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
52557         FREE(untag_ptr(this_ptr));
52558         Score_free(this_ptr_conv);
52559 }
52560
52561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52562         if (!ptr_is_owned(this_ptr)) return;
52563         void* this_ptr_ptr = untag_ptr(this_ptr);
52564         CHECK_ACCESS(this_ptr_ptr);
52565         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
52566         FREE(untag_ptr(this_ptr));
52567         LockableScore_free(this_ptr_conv);
52568 }
52569
52570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52571         if (!ptr_is_owned(this_ptr)) return;
52572         void* this_ptr_ptr = untag_ptr(this_ptr);
52573         CHECK_ACCESS(this_ptr_ptr);
52574         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
52575         FREE(untag_ptr(this_ptr));
52576         WriteableScore_free(this_ptr_conv);
52577 }
52578
52579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52580         LDKMultiThreadedLockableScore this_obj_conv;
52581         this_obj_conv.inner = untag_ptr(this_obj);
52582         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52584         MultiThreadedLockableScore_free(this_obj_conv);
52585 }
52586
52587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52588         LDKMultiThreadedScoreLock this_obj_conv;
52589         this_obj_conv.inner = untag_ptr(this_obj);
52590         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52592         MultiThreadedScoreLock_free(this_obj_conv);
52593 }
52594
52595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52596         LDKMultiThreadedScoreLock this_arg_conv;
52597         this_arg_conv.inner = untag_ptr(this_arg);
52598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52600         this_arg_conv.is_owned = false;
52601         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52602         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
52603         return tag_ptr(ret_ret, true);
52604 }
52605
52606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
52607         LDKMultiThreadedScoreLock obj_conv;
52608         obj_conv.inner = untag_ptr(obj);
52609         obj_conv.is_owned = ptr_is_owned(obj);
52610         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52611         obj_conv.is_owned = false;
52612         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
52613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52615         CVec_u8Z_free(ret_var);
52616         return ret_arr;
52617 }
52618
52619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52620         LDKMultiThreadedLockableScore this_arg_conv;
52621         this_arg_conv.inner = untag_ptr(this_arg);
52622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52624         this_arg_conv.is_owned = false;
52625         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
52626         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
52627         return tag_ptr(ret_ret, true);
52628 }
52629
52630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
52631         LDKMultiThreadedLockableScore obj_conv;
52632         obj_conv.inner = untag_ptr(obj);
52633         obj_conv.is_owned = ptr_is_owned(obj);
52634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52635         obj_conv.is_owned = false;
52636         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
52637         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52638         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52639         CVec_u8Z_free(ret_var);
52640         return ret_arr;
52641 }
52642
52643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52644         LDKMultiThreadedLockableScore this_arg_conv;
52645         this_arg_conv.inner = untag_ptr(this_arg);
52646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52648         this_arg_conv.is_owned = false;
52649         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
52650         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
52651         return tag_ptr(ret_ret, true);
52652 }
52653
52654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
52655         void* score_ptr = untag_ptr(score);
52656         CHECK_ACCESS(score_ptr);
52657         LDKScore score_conv = *(LDKScore*)(score_ptr);
52658         if (score_conv.free == LDKScore_JCalls_free) {
52659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52660                 LDKScore_JCalls_cloned(&score_conv);
52661         }
52662         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
52663         int64_t ret_ref = 0;
52664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52666         return ret_ref;
52667 }
52668
52669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52670         LDKChannelUsage this_obj_conv;
52671         this_obj_conv.inner = untag_ptr(this_obj);
52672         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52674         ChannelUsage_free(this_obj_conv);
52675 }
52676
52677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52678         LDKChannelUsage this_ptr_conv;
52679         this_ptr_conv.inner = untag_ptr(this_ptr);
52680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52682         this_ptr_conv.is_owned = false;
52683         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
52684         return ret_conv;
52685 }
52686
52687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52688         LDKChannelUsage this_ptr_conv;
52689         this_ptr_conv.inner = untag_ptr(this_ptr);
52690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52692         this_ptr_conv.is_owned = false;
52693         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
52694 }
52695
52696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52697         LDKChannelUsage this_ptr_conv;
52698         this_ptr_conv.inner = untag_ptr(this_ptr);
52699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52701         this_ptr_conv.is_owned = false;
52702         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
52703         return ret_conv;
52704 }
52705
52706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52707         LDKChannelUsage this_ptr_conv;
52708         this_ptr_conv.inner = untag_ptr(this_ptr);
52709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52711         this_ptr_conv.is_owned = false;
52712         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
52713 }
52714
52715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
52716         LDKChannelUsage this_ptr_conv;
52717         this_ptr_conv.inner = untag_ptr(this_ptr);
52718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52720         this_ptr_conv.is_owned = false;
52721         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
52722         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
52723         int64_t ret_ref = tag_ptr(ret_copy, true);
52724         return ret_ref;
52725 }
52726
52727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52728         LDKChannelUsage this_ptr_conv;
52729         this_ptr_conv.inner = untag_ptr(this_ptr);
52730         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52732         this_ptr_conv.is_owned = false;
52733         void* val_ptr = untag_ptr(val);
52734         CHECK_ACCESS(val_ptr);
52735         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
52736         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
52737         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
52738 }
52739
52740 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) {
52741         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
52742         CHECK_ACCESS(effective_capacity_arg_ptr);
52743         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
52744         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
52745         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
52746         int64_t ret_ref = 0;
52747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52749         return ret_ref;
52750 }
52751
52752 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
52753         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
52754         int64_t ret_ref = 0;
52755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52757         return ret_ref;
52758 }
52759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52760         LDKChannelUsage arg_conv;
52761         arg_conv.inner = untag_ptr(arg);
52762         arg_conv.is_owned = ptr_is_owned(arg);
52763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52764         arg_conv.is_owned = false;
52765         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
52766         return ret_conv;
52767 }
52768
52769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52770         LDKChannelUsage orig_conv;
52771         orig_conv.inner = untag_ptr(orig);
52772         orig_conv.is_owned = ptr_is_owned(orig);
52773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52774         orig_conv.is_owned = false;
52775         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
52776         int64_t ret_ref = 0;
52777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52779         return ret_ref;
52780 }
52781
52782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52783         LDKFixedPenaltyScorer this_obj_conv;
52784         this_obj_conv.inner = untag_ptr(this_obj);
52785         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52787         FixedPenaltyScorer_free(this_obj_conv);
52788 }
52789
52790 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
52791         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
52792         int64_t ret_ref = 0;
52793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52795         return ret_ref;
52796 }
52797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52798         LDKFixedPenaltyScorer arg_conv;
52799         arg_conv.inner = untag_ptr(arg);
52800         arg_conv.is_owned = ptr_is_owned(arg);
52801         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52802         arg_conv.is_owned = false;
52803         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
52804         return ret_conv;
52805 }
52806
52807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52808         LDKFixedPenaltyScorer orig_conv;
52809         orig_conv.inner = untag_ptr(orig);
52810         orig_conv.is_owned = ptr_is_owned(orig);
52811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52812         orig_conv.is_owned = false;
52813         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
52814         int64_t ret_ref = 0;
52815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52817         return ret_ref;
52818 }
52819
52820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
52821         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
52822         int64_t ret_ref = 0;
52823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52825         return ret_ref;
52826 }
52827
52828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52829         LDKFixedPenaltyScorer this_arg_conv;
52830         this_arg_conv.inner = untag_ptr(this_arg);
52831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52833         this_arg_conv.is_owned = false;
52834         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52835         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
52836         return tag_ptr(ret_ret, true);
52837 }
52838
52839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
52840         LDKFixedPenaltyScorer obj_conv;
52841         obj_conv.inner = untag_ptr(obj);
52842         obj_conv.is_owned = ptr_is_owned(obj);
52843         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52844         obj_conv.is_owned = false;
52845         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
52846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52848         CVec_u8Z_free(ret_var);
52849         return ret_arr;
52850 }
52851
52852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
52853         LDKu8slice ser_ref;
52854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52856         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
52857         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
52858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52859         return tag_ptr(ret_conv, true);
52860 }
52861
52862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52863         LDKProbabilisticScorer this_obj_conv;
52864         this_obj_conv.inner = untag_ptr(this_obj);
52865         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52867         ProbabilisticScorer_free(this_obj_conv);
52868 }
52869
52870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52871         LDKProbabilisticScoringParameters this_obj_conv;
52872         this_obj_conv.inner = untag_ptr(this_obj);
52873         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52875         ProbabilisticScoringParameters_free(this_obj_conv);
52876 }
52877
52878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52879         LDKProbabilisticScoringParameters this_ptr_conv;
52880         this_ptr_conv.inner = untag_ptr(this_ptr);
52881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52883         this_ptr_conv.is_owned = false;
52884         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
52885         return ret_conv;
52886 }
52887
52888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52889         LDKProbabilisticScoringParameters this_ptr_conv;
52890         this_ptr_conv.inner = untag_ptr(this_ptr);
52891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52893         this_ptr_conv.is_owned = false;
52894         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
52895 }
52896
52897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52898         LDKProbabilisticScoringParameters this_ptr_conv;
52899         this_ptr_conv.inner = untag_ptr(this_ptr);
52900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52902         this_ptr_conv.is_owned = false;
52903         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
52904         return ret_conv;
52905 }
52906
52907 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) {
52908         LDKProbabilisticScoringParameters this_ptr_conv;
52909         this_ptr_conv.inner = untag_ptr(this_ptr);
52910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52912         this_ptr_conv.is_owned = false;
52913         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52914 }
52915
52916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52917         LDKProbabilisticScoringParameters this_ptr_conv;
52918         this_ptr_conv.inner = untag_ptr(this_ptr);
52919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52921         this_ptr_conv.is_owned = false;
52922         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52923         return ret_conv;
52924 }
52925
52926 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) {
52927         LDKProbabilisticScoringParameters this_ptr_conv;
52928         this_ptr_conv.inner = untag_ptr(this_ptr);
52929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52931         this_ptr_conv.is_owned = false;
52932         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52933 }
52934
52935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
52936         LDKProbabilisticScoringParameters this_ptr_conv;
52937         this_ptr_conv.inner = untag_ptr(this_ptr);
52938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52940         this_ptr_conv.is_owned = false;
52941         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
52942         return ret_conv;
52943 }
52944
52945 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) {
52946         LDKProbabilisticScoringParameters this_ptr_conv;
52947         this_ptr_conv.inner = untag_ptr(this_ptr);
52948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52950         this_ptr_conv.is_owned = false;
52951         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
52952 }
52953
52954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52955         LDKProbabilisticScoringParameters this_ptr_conv;
52956         this_ptr_conv.inner = untag_ptr(this_ptr);
52957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52959         this_ptr_conv.is_owned = false;
52960         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52961         return ret_conv;
52962 }
52963
52964 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) {
52965         LDKProbabilisticScoringParameters this_ptr_conv;
52966         this_ptr_conv.inner = untag_ptr(this_ptr);
52967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52969         this_ptr_conv.is_owned = false;
52970         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52971 }
52972
52973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52974         LDKProbabilisticScoringParameters this_ptr_conv;
52975         this_ptr_conv.inner = untag_ptr(this_ptr);
52976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52978         this_ptr_conv.is_owned = false;
52979         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52980         return ret_conv;
52981 }
52982
52983 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) {
52984         LDKProbabilisticScoringParameters this_ptr_conv;
52985         this_ptr_conv.inner = untag_ptr(this_ptr);
52986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52988         this_ptr_conv.is_owned = false;
52989         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52990 }
52991
52992 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) {
52993         LDKProbabilisticScoringParameters this_ptr_conv;
52994         this_ptr_conv.inner = untag_ptr(this_ptr);
52995         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52997         this_ptr_conv.is_owned = false;
52998         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52999         return ret_conv;
53000 }
53001
53002 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) {
53003         LDKProbabilisticScoringParameters this_ptr_conv;
53004         this_ptr_conv.inner = untag_ptr(this_ptr);
53005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53007         this_ptr_conv.is_owned = false;
53008         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
53009 }
53010
53011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
53012         LDKProbabilisticScoringParameters this_ptr_conv;
53013         this_ptr_conv.inner = untag_ptr(this_ptr);
53014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53016         this_ptr_conv.is_owned = false;
53017         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
53018         return ret_conv;
53019 }
53020
53021 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) {
53022         LDKProbabilisticScoringParameters this_ptr_conv;
53023         this_ptr_conv.inner = untag_ptr(this_ptr);
53024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53026         this_ptr_conv.is_owned = false;
53027         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
53028 }
53029
53030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53031         LDKProbabilisticScoringParameters this_ptr_conv;
53032         this_ptr_conv.inner = untag_ptr(this_ptr);
53033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53035         this_ptr_conv.is_owned = false;
53036         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
53037         return ret_conv;
53038 }
53039
53040 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) {
53041         LDKProbabilisticScoringParameters this_ptr_conv;
53042         this_ptr_conv.inner = untag_ptr(this_ptr);
53043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53045         this_ptr_conv.is_owned = false;
53046         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
53047 }
53048
53049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53050         LDKProbabilisticScoringParameters this_ptr_conv;
53051         this_ptr_conv.inner = untag_ptr(this_ptr);
53052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53054         this_ptr_conv.is_owned = false;
53055         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
53056         return ret_conv;
53057 }
53058
53059 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) {
53060         LDKProbabilisticScoringParameters this_ptr_conv;
53061         this_ptr_conv.inner = untag_ptr(this_ptr);
53062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53064         this_ptr_conv.is_owned = false;
53065         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
53066 }
53067
53068 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
53069         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
53070         int64_t ret_ref = 0;
53071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53073         return ret_ref;
53074 }
53075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53076         LDKProbabilisticScoringParameters arg_conv;
53077         arg_conv.inner = untag_ptr(arg);
53078         arg_conv.is_owned = ptr_is_owned(arg);
53079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53080         arg_conv.is_owned = false;
53081         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
53082         return ret_conv;
53083 }
53084
53085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53086         LDKProbabilisticScoringParameters orig_conv;
53087         orig_conv.inner = untag_ptr(orig);
53088         orig_conv.is_owned = ptr_is_owned(orig);
53089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53090         orig_conv.is_owned = false;
53091         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
53092         int64_t ret_ref = 0;
53093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53095         return ret_ref;
53096 }
53097
53098 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) {
53099         LDKProbabilisticScoringParameters params_conv;
53100         params_conv.inner = untag_ptr(params);
53101         params_conv.is_owned = ptr_is_owned(params);
53102         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
53103         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
53104         LDKNetworkGraph network_graph_conv;
53105         network_graph_conv.inner = untag_ptr(network_graph);
53106         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53107         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53108         network_graph_conv.is_owned = false;
53109         void* logger_ptr = untag_ptr(logger);
53110         CHECK_ACCESS(logger_ptr);
53111         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53112         if (logger_conv.free == LDKLogger_JCalls_free) {
53113                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53114                 LDKLogger_JCalls_cloned(&logger_conv);
53115         }
53116         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
53117         int64_t ret_ref = 0;
53118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53120         return ret_ref;
53121 }
53122
53123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
53124         LDKProbabilisticScorer this_arg_conv;
53125         this_arg_conv.inner = untag_ptr(this_arg);
53126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53128         this_arg_conv.is_owned = false;
53129         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
53130 }
53131
53132 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) {
53133         LDKProbabilisticScorer this_arg_conv;
53134         this_arg_conv.inner = untag_ptr(this_arg);
53135         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53137         this_arg_conv.is_owned = false;
53138         LDKNodeId target_conv;
53139         target_conv.inner = untag_ptr(target);
53140         target_conv.is_owned = ptr_is_owned(target);
53141         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53142         target_conv.is_owned = false;
53143         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
53144         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
53145         int64_t ret_ref = tag_ptr(ret_copy, true);
53146         return ret_ref;
53147 }
53148
53149 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) {
53150         LDKProbabilisticScorer this_arg_conv;
53151         this_arg_conv.inner = untag_ptr(this_arg);
53152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53154         this_arg_conv.is_owned = false;
53155         LDKNodeId target_conv;
53156         target_conv.inner = untag_ptr(target);
53157         target_conv.is_owned = ptr_is_owned(target);
53158         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53159         target_conv.is_owned = false;
53160         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
53161         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
53162         int64_t ret_ref = tag_ptr(ret_copy, true);
53163         return ret_ref;
53164 }
53165
53166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53167         LDKProbabilisticScorer this_arg_conv;
53168         this_arg_conv.inner = untag_ptr(this_arg);
53169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53171         this_arg_conv.is_owned = false;
53172         LDKNodeId node_id_conv;
53173         node_id_conv.inner = untag_ptr(node_id);
53174         node_id_conv.is_owned = ptr_is_owned(node_id);
53175         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53176         node_id_conv.is_owned = false;
53177         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
53178 }
53179
53180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53181         LDKProbabilisticScorer this_arg_conv;
53182         this_arg_conv.inner = untag_ptr(this_arg);
53183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53185         this_arg_conv.is_owned = false;
53186         LDKNodeId node_id_conv;
53187         node_id_conv.inner = untag_ptr(node_id);
53188         node_id_conv.is_owned = ptr_is_owned(node_id);
53189         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53190         node_id_conv.is_owned = false;
53191         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
53192 }
53193
53194 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) {
53195         LDKProbabilisticScorer this_arg_conv;
53196         this_arg_conv.inner = untag_ptr(this_arg);
53197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53199         this_arg_conv.is_owned = false;
53200         LDKNodeId node_id_conv;
53201         node_id_conv.inner = untag_ptr(node_id);
53202         node_id_conv.is_owned = ptr_is_owned(node_id);
53203         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53204         node_id_conv.is_owned = false;
53205         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
53206 }
53207
53208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53209         LDKProbabilisticScorer this_arg_conv;
53210         this_arg_conv.inner = untag_ptr(this_arg);
53211         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53213         this_arg_conv.is_owned = false;
53214         LDKNodeId node_id_conv;
53215         node_id_conv.inner = untag_ptr(node_id);
53216         node_id_conv.is_owned = ptr_is_owned(node_id);
53217         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53218         node_id_conv.is_owned = false;
53219         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
53220 }
53221
53222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
53223         LDKProbabilisticScorer this_arg_conv;
53224         this_arg_conv.inner = untag_ptr(this_arg);
53225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53227         this_arg_conv.is_owned = false;
53228         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
53229 }
53230
53231 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) {
53232         LDKProbabilisticScoringParameters this_arg_conv;
53233         this_arg_conv.inner = untag_ptr(this_arg);
53234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53236         this_arg_conv.is_owned = false;
53237         LDKCVec_NodeIdZ node_ids_constr;
53238         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
53239         if (node_ids_constr.datalen > 0)
53240                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
53241         else
53242                 node_ids_constr.data = NULL;
53243         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
53244         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
53245                 int64_t node_ids_conv_8 = node_ids_vals[i];
53246                 LDKNodeId node_ids_conv_8_conv;
53247                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
53248                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
53249                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
53250                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
53251                 node_ids_constr.data[i] = node_ids_conv_8_conv;
53252         }
53253         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
53254         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
53255 }
53256
53257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
53258         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
53259         int64_t ret_ref = 0;
53260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53262         return ret_ref;
53263 }
53264
53265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
53266         LDKProbabilisticScorer this_arg_conv;
53267         this_arg_conv.inner = untag_ptr(this_arg);
53268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53270         this_arg_conv.is_owned = false;
53271         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
53272         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
53273         return tag_ptr(ret_ret, true);
53274 }
53275
53276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
53277         LDKProbabilisticScorer obj_conv;
53278         obj_conv.inner = untag_ptr(obj);
53279         obj_conv.is_owned = ptr_is_owned(obj);
53280         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53281         obj_conv.is_owned = false;
53282         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
53283         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53284         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53285         CVec_u8Z_free(ret_var);
53286         return ret_arr;
53287 }
53288
53289 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) {
53290         LDKu8slice ser_ref;
53291         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53292         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53293         LDKProbabilisticScoringParameters arg_a_conv;
53294         arg_a_conv.inner = untag_ptr(arg_a);
53295         arg_a_conv.is_owned = ptr_is_owned(arg_a);
53296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
53297         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
53298         LDKNetworkGraph arg_b_conv;
53299         arg_b_conv.inner = untag_ptr(arg_b);
53300         arg_b_conv.is_owned = ptr_is_owned(arg_b);
53301         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
53302         arg_b_conv.is_owned = false;
53303         void* arg_c_ptr = untag_ptr(arg_c);
53304         CHECK_ACCESS(arg_c_ptr);
53305         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
53306         if (arg_c_conv.free == LDKLogger_JCalls_free) {
53307                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53308                 LDKLogger_JCalls_cloned(&arg_c_conv);
53309         }
53310         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
53311         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
53312         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53313         return tag_ptr(ret_conv, true);
53314 }
53315
53316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53317         LDKOnionMessenger this_obj_conv;
53318         this_obj_conv.inner = untag_ptr(this_obj);
53319         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53321         OnionMessenger_free(this_obj_conv);
53322 }
53323
53324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53325         if (!ptr_is_owned(this_ptr)) return;
53326         void* this_ptr_ptr = untag_ptr(this_ptr);
53327         CHECK_ACCESS(this_ptr_ptr);
53328         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
53329         FREE(untag_ptr(this_ptr));
53330         Destination_free(this_ptr_conv);
53331 }
53332
53333 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
53334         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53335         *ret_copy = Destination_clone(arg);
53336         int64_t ret_ref = tag_ptr(ret_copy, true);
53337         return ret_ref;
53338 }
53339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53340         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
53341         int64_t ret_conv = Destination_clone_ptr(arg_conv);
53342         return ret_conv;
53343 }
53344
53345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53346         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
53347         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53348         *ret_copy = Destination_clone(orig_conv);
53349         int64_t ret_ref = tag_ptr(ret_copy, true);
53350         return ret_ref;
53351 }
53352
53353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
53354         LDKPublicKey a_ref;
53355         CHECK((*env)->GetArrayLength(env, a) == 33);
53356         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
53357         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53358         *ret_copy = Destination_node(a_ref);
53359         int64_t ret_ref = tag_ptr(ret_copy, true);
53360         return ret_ref;
53361 }
53362
53363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
53364         LDKBlindedPath a_conv;
53365         a_conv.inner = untag_ptr(a);
53366         a_conv.is_owned = ptr_is_owned(a);
53367         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53368         a_conv = BlindedPath_clone(&a_conv);
53369         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53370         *ret_copy = Destination_blinded_path(a_conv);
53371         int64_t ret_ref = tag_ptr(ret_copy, true);
53372         return ret_ref;
53373 }
53374
53375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53376         if (!ptr_is_owned(this_ptr)) return;
53377         void* this_ptr_ptr = untag_ptr(this_ptr);
53378         CHECK_ACCESS(this_ptr_ptr);
53379         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
53380         FREE(untag_ptr(this_ptr));
53381         SendError_free(this_ptr_conv);
53382 }
53383
53384 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
53385         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53386         *ret_copy = SendError_clone(arg);
53387         int64_t ret_ref = tag_ptr(ret_copy, true);
53388         return ret_ref;
53389 }
53390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53391         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
53392         int64_t ret_conv = SendError_clone_ptr(arg_conv);
53393         return ret_conv;
53394 }
53395
53396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53397         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
53398         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53399         *ret_copy = SendError_clone(orig_conv);
53400         int64_t ret_ref = tag_ptr(ret_copy, true);
53401         return ret_ref;
53402 }
53403
53404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
53405         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
53406         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53407         *ret_copy = SendError_secp256k1(a_conv);
53408         int64_t ret_ref = tag_ptr(ret_copy, true);
53409         return ret_ref;
53410 }
53411
53412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
53413         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53414         *ret_copy = SendError_too_big_packet();
53415         int64_t ret_ref = tag_ptr(ret_copy, true);
53416         return ret_ref;
53417 }
53418
53419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
53420         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53421         *ret_copy = SendError_too_few_blinded_hops();
53422         int64_t ret_ref = tag_ptr(ret_copy, true);
53423         return ret_ref;
53424 }
53425
53426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
53427         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53428         *ret_copy = SendError_invalid_first_hop();
53429         int64_t ret_ref = tag_ptr(ret_copy, true);
53430         return ret_ref;
53431 }
53432
53433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
53434         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53435         *ret_copy = SendError_invalid_message();
53436         int64_t ret_ref = tag_ptr(ret_copy, true);
53437         return ret_ref;
53438 }
53439
53440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
53441         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53442         *ret_copy = SendError_buffer_full();
53443         int64_t ret_ref = tag_ptr(ret_copy, true);
53444         return ret_ref;
53445 }
53446
53447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
53448         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53449         *ret_copy = SendError_get_node_id_failed();
53450         int64_t ret_ref = tag_ptr(ret_copy, true);
53451         return ret_ref;
53452 }
53453
53454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
53455         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53456         *ret_copy = SendError_blinded_path_advance_failed();
53457         int64_t ret_ref = tag_ptr(ret_copy, true);
53458         return ret_ref;
53459 }
53460
53461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53462         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
53463         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
53464         jboolean ret_conv = SendError_eq(a_conv, b_conv);
53465         return ret_conv;
53466 }
53467
53468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53469         if (!ptr_is_owned(this_ptr)) return;
53470         void* this_ptr_ptr = untag_ptr(this_ptr);
53471         CHECK_ACCESS(this_ptr_ptr);
53472         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
53473         FREE(untag_ptr(this_ptr));
53474         CustomOnionMessageHandler_free(this_ptr_conv);
53475 }
53476
53477 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) {
53478         void* entropy_source_ptr = untag_ptr(entropy_source);
53479         CHECK_ACCESS(entropy_source_ptr);
53480         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
53481         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
53482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53483                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
53484         }
53485         void* node_signer_ptr = untag_ptr(node_signer);
53486         CHECK_ACCESS(node_signer_ptr);
53487         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
53488         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
53489                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53490                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
53491         }
53492         void* logger_ptr = untag_ptr(logger);
53493         CHECK_ACCESS(logger_ptr);
53494         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53495         if (logger_conv.free == LDKLogger_JCalls_free) {
53496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53497                 LDKLogger_JCalls_cloned(&logger_conv);
53498         }
53499         void* custom_handler_ptr = untag_ptr(custom_handler);
53500         CHECK_ACCESS(custom_handler_ptr);
53501         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
53502         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
53503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53504                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
53505         }
53506         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, custom_handler_conv);
53507         int64_t ret_ref = 0;
53508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53510         return ret_ref;
53511 }
53512
53513 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) {
53514         LDKOnionMessenger this_arg_conv;
53515         this_arg_conv.inner = untag_ptr(this_arg);
53516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53518         this_arg_conv.is_owned = false;
53519         LDKCVec_PublicKeyZ intermediate_nodes_constr;
53520         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
53521         if (intermediate_nodes_constr.datalen > 0)
53522                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53523         else
53524                 intermediate_nodes_constr.data = NULL;
53525         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
53526                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
53527                 LDKPublicKey intermediate_nodes_conv_8_ref;
53528                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
53529                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
53530                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
53531         }
53532         void* destination_ptr = untag_ptr(destination);
53533         CHECK_ACCESS(destination_ptr);
53534         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
53535         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
53536         void* message_ptr = untag_ptr(message);
53537         CHECK_ACCESS(message_ptr);
53538         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
53539         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
53540         LDKBlindedPath reply_path_conv;
53541         reply_path_conv.inner = untag_ptr(reply_path);
53542         reply_path_conv.is_owned = ptr_is_owned(reply_path);
53543         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
53544         reply_path_conv = BlindedPath_clone(&reply_path_conv);
53545         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
53546         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
53547         return tag_ptr(ret_conv, true);
53548 }
53549
53550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53551         LDKOnionMessenger this_arg_conv;
53552         this_arg_conv.inner = untag_ptr(this_arg);
53553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53555         this_arg_conv.is_owned = false;
53556         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
53557         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
53558         return tag_ptr(ret_ret, true);
53559 }
53560
53561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
53562         LDKOnionMessenger this_arg_conv;
53563         this_arg_conv.inner = untag_ptr(this_arg);
53564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53566         this_arg_conv.is_owned = false;
53567         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
53568         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
53569         return tag_ptr(ret_ret, true);
53570 }
53571
53572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53573         if (!ptr_is_owned(this_ptr)) return;
53574         void* this_ptr_ptr = untag_ptr(this_ptr);
53575         CHECK_ACCESS(this_ptr_ptr);
53576         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
53577         FREE(untag_ptr(this_ptr));
53578         OnionMessageContents_free(this_ptr_conv);
53579 }
53580
53581 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
53582         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53583         *ret_copy = OnionMessageContents_clone(arg);
53584         int64_t ret_ref = tag_ptr(ret_copy, true);
53585         return ret_ref;
53586 }
53587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53588         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
53589         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
53590         return ret_conv;
53591 }
53592
53593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53594         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
53595         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53596         *ret_copy = OnionMessageContents_clone(orig_conv);
53597         int64_t ret_ref = tag_ptr(ret_copy, true);
53598         return ret_ref;
53599 }
53600
53601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
53602         void* a_ptr = untag_ptr(a);
53603         CHECK_ACCESS(a_ptr);
53604         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
53605         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
53606                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53607                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
53608         }
53609         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53610         *ret_copy = OnionMessageContents_custom(a_conv);
53611         int64_t ret_ref = tag_ptr(ret_copy, true);
53612         return ret_ref;
53613 }
53614
53615 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
53616         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53617         *ret_ret = CustomOnionMessageContents_clone(arg);
53618         return tag_ptr(ret_ret, true);
53619 }
53620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53621         void* arg_ptr = untag_ptr(arg);
53622         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53623         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
53624         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
53625         return ret_conv;
53626 }
53627
53628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53629         void* orig_ptr = untag_ptr(orig);
53630         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53631         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
53632         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53633         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
53634         return tag_ptr(ret_ret, true);
53635 }
53636
53637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53638         if (!ptr_is_owned(this_ptr)) return;
53639         void* this_ptr_ptr = untag_ptr(this_ptr);
53640         CHECK_ACCESS(this_ptr_ptr);
53641         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
53642         FREE(untag_ptr(this_ptr));
53643         CustomOnionMessageContents_free(this_ptr_conv);
53644 }
53645
53646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53647         LDKBlindedPath this_obj_conv;
53648         this_obj_conv.inner = untag_ptr(this_obj);
53649         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53651         BlindedPath_free(this_obj_conv);
53652 }
53653
53654 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
53655         LDKBlindedPath ret_var = BlindedPath_clone(arg);
53656         int64_t ret_ref = 0;
53657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53659         return ret_ref;
53660 }
53661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53662         LDKBlindedPath arg_conv;
53663         arg_conv.inner = untag_ptr(arg);
53664         arg_conv.is_owned = ptr_is_owned(arg);
53665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53666         arg_conv.is_owned = false;
53667         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
53668         return ret_conv;
53669 }
53670
53671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53672         LDKBlindedPath orig_conv;
53673         orig_conv.inner = untag_ptr(orig);
53674         orig_conv.is_owned = ptr_is_owned(orig);
53675         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53676         orig_conv.is_owned = false;
53677         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
53678         int64_t ret_ref = 0;
53679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53681         return ret_ref;
53682 }
53683
53684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1hash(JNIEnv *env, jclass clz, int64_t o) {
53685         LDKBlindedPath o_conv;
53686         o_conv.inner = untag_ptr(o);
53687         o_conv.is_owned = ptr_is_owned(o);
53688         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53689         o_conv.is_owned = false;
53690         int64_t ret_conv = BlindedPath_hash(&o_conv);
53691         return ret_conv;
53692 }
53693
53694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPath_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53695         LDKBlindedPath a_conv;
53696         a_conv.inner = untag_ptr(a);
53697         a_conv.is_owned = ptr_is_owned(a);
53698         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53699         a_conv.is_owned = false;
53700         LDKBlindedPath b_conv;
53701         b_conv.inner = untag_ptr(b);
53702         b_conv.is_owned = ptr_is_owned(b);
53703         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53704         b_conv.is_owned = false;
53705         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
53706         return ret_conv;
53707 }
53708
53709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53710         LDKBlindedHop this_obj_conv;
53711         this_obj_conv.inner = untag_ptr(this_obj);
53712         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53714         BlindedHop_free(this_obj_conv);
53715 }
53716
53717 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
53718         LDKBlindedHop ret_var = BlindedHop_clone(arg);
53719         int64_t ret_ref = 0;
53720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53722         return ret_ref;
53723 }
53724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53725         LDKBlindedHop arg_conv;
53726         arg_conv.inner = untag_ptr(arg);
53727         arg_conv.is_owned = ptr_is_owned(arg);
53728         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53729         arg_conv.is_owned = false;
53730         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
53731         return ret_conv;
53732 }
53733
53734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53735         LDKBlindedHop orig_conv;
53736         orig_conv.inner = untag_ptr(orig);
53737         orig_conv.is_owned = ptr_is_owned(orig);
53738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53739         orig_conv.is_owned = false;
53740         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
53741         int64_t ret_ref = 0;
53742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53744         return ret_ref;
53745 }
53746
53747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
53748         LDKBlindedHop o_conv;
53749         o_conv.inner = untag_ptr(o);
53750         o_conv.is_owned = ptr_is_owned(o);
53751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53752         o_conv.is_owned = false;
53753         int64_t ret_conv = BlindedHop_hash(&o_conv);
53754         return ret_conv;
53755 }
53756
53757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53758         LDKBlindedHop a_conv;
53759         a_conv.inner = untag_ptr(a);
53760         a_conv.is_owned = ptr_is_owned(a);
53761         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53762         a_conv.is_owned = false;
53763         LDKBlindedHop b_conv;
53764         b_conv.inner = untag_ptr(b);
53765         b_conv.is_owned = ptr_is_owned(b);
53766         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53767         b_conv.is_owned = false;
53768         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
53769         return ret_conv;
53770 }
53771
53772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new_1for_1message(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t entropy_source) {
53773         LDKCVec_PublicKeyZ node_pks_constr;
53774         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
53775         if (node_pks_constr.datalen > 0)
53776                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53777         else
53778                 node_pks_constr.data = NULL;
53779         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
53780                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
53781                 LDKPublicKey node_pks_conv_8_ref;
53782                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
53783                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
53784                 node_pks_constr.data[i] = node_pks_conv_8_ref;
53785         }
53786         void* entropy_source_ptr = untag_ptr(entropy_source);
53787         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
53788         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
53789         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
53790         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
53791         return tag_ptr(ret_conv, true);
53792 }
53793
53794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
53795         LDKBlindedPath obj_conv;
53796         obj_conv.inner = untag_ptr(obj);
53797         obj_conv.is_owned = ptr_is_owned(obj);
53798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53799         obj_conv.is_owned = false;
53800         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
53801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53803         CVec_u8Z_free(ret_var);
53804         return ret_arr;
53805 }
53806
53807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53808         LDKu8slice ser_ref;
53809         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53810         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53811         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
53812         *ret_conv = BlindedPath_read(ser_ref);
53813         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53814         return tag_ptr(ret_conv, true);
53815 }
53816
53817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
53818         LDKBlindedHop obj_conv;
53819         obj_conv.inner = untag_ptr(obj);
53820         obj_conv.is_owned = ptr_is_owned(obj);
53821         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53822         obj_conv.is_owned = false;
53823         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
53824         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53825         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53826         CVec_u8Z_free(ret_var);
53827         return ret_arr;
53828 }
53829
53830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53831         LDKu8slice ser_ref;
53832         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53833         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53834         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
53835         *ret_conv = BlindedHop_read(ser_ref);
53836         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53837         return tag_ptr(ret_conv, true);
53838 }
53839
53840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53841         if (!ptr_is_owned(this_ptr)) return;
53842         void* this_ptr_ptr = untag_ptr(this_ptr);
53843         CHECK_ACCESS(this_ptr_ptr);
53844         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
53845         FREE(untag_ptr(this_ptr));
53846         PaymentPurpose_free(this_ptr_conv);
53847 }
53848
53849 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
53850         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53851         *ret_copy = PaymentPurpose_clone(arg);
53852         int64_t ret_ref = tag_ptr(ret_copy, true);
53853         return ret_ref;
53854 }
53855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53856         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
53857         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
53858         return ret_conv;
53859 }
53860
53861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53862         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
53863         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53864         *ret_copy = PaymentPurpose_clone(orig_conv);
53865         int64_t ret_ref = tag_ptr(ret_copy, true);
53866         return ret_ref;
53867 }
53868
53869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
53870         LDKThirtyTwoBytes payment_preimage_ref;
53871         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53872         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53873         LDKThirtyTwoBytes payment_secret_ref;
53874         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
53875         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
53876         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53877         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
53878         int64_t ret_ref = tag_ptr(ret_copy, true);
53879         return ret_ref;
53880 }
53881
53882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
53883         LDKThirtyTwoBytes a_ref;
53884         CHECK((*env)->GetArrayLength(env, a) == 32);
53885         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
53886         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53887         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
53888         int64_t ret_ref = tag_ptr(ret_copy, true);
53889         return ret_ref;
53890 }
53891
53892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53893         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
53894         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
53895         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
53896         return ret_conv;
53897 }
53898
53899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
53900         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
53901         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
53902         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53903         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53904         CVec_u8Z_free(ret_var);
53905         return ret_arr;
53906 }
53907
53908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53909         LDKu8slice ser_ref;
53910         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53911         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53912         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
53913         *ret_conv = PaymentPurpose_read(ser_ref);
53914         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53915         return tag_ptr(ret_conv, true);
53916 }
53917
53918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PathFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53919         if (!ptr_is_owned(this_ptr)) return;
53920         void* this_ptr_ptr = untag_ptr(this_ptr);
53921         CHECK_ACCESS(this_ptr_ptr);
53922         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
53923         FREE(untag_ptr(this_ptr));
53924         PathFailure_free(this_ptr_conv);
53925 }
53926
53927 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
53928         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53929         *ret_copy = PathFailure_clone(arg);
53930         int64_t ret_ref = tag_ptr(ret_copy, true);
53931         return ret_ref;
53932 }
53933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53934         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
53935         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
53936         return ret_conv;
53937 }
53938
53939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53940         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
53941         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53942         *ret_copy = PathFailure_clone(orig_conv);
53943         int64_t ret_ref = tag_ptr(ret_copy, true);
53944         return ret_ref;
53945 }
53946
53947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1initial_1send(JNIEnv *env, jclass clz, int64_t err) {
53948         void* err_ptr = untag_ptr(err);
53949         CHECK_ACCESS(err_ptr);
53950         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
53951         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
53952         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53953         *ret_copy = PathFailure_initial_send(err_conv);
53954         int64_t ret_ref = tag_ptr(ret_copy, true);
53955         return ret_ref;
53956 }
53957
53958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1on_1path(JNIEnv *env, jclass clz, int64_t network_update) {
53959         void* network_update_ptr = untag_ptr(network_update);
53960         CHECK_ACCESS(network_update_ptr);
53961         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
53962         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
53963         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53964         *ret_copy = PathFailure_on_path(network_update_conv);
53965         int64_t ret_ref = tag_ptr(ret_copy, true);
53966         return ret_ref;
53967 }
53968
53969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PathFailure_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53970         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
53971         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
53972         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
53973         return ret_conv;
53974 }
53975
53976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PathFailure_1write(JNIEnv *env, jclass clz, int64_t obj) {
53977         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
53978         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
53979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53981         CVec_u8Z_free(ret_var);
53982         return ret_arr;
53983 }
53984
53985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53986         LDKu8slice ser_ref;
53987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53989         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
53990         *ret_conv = PathFailure_read(ser_ref);
53991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53992         return tag_ptr(ret_conv, true);
53993 }
53994
53995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53996         if (!ptr_is_owned(this_ptr)) return;
53997         void* this_ptr_ptr = untag_ptr(this_ptr);
53998         CHECK_ACCESS(this_ptr_ptr);
53999         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
54000         FREE(untag_ptr(this_ptr));
54001         ClosureReason_free(this_ptr_conv);
54002 }
54003
54004 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
54005         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54006         *ret_copy = ClosureReason_clone(arg);
54007         int64_t ret_ref = tag_ptr(ret_copy, true);
54008         return ret_ref;
54009 }
54010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54011         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
54012         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
54013         return ret_conv;
54014 }
54015
54016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54017         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
54018         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54019         *ret_copy = ClosureReason_clone(orig_conv);
54020         int64_t ret_ref = tag_ptr(ret_copy, true);
54021         return ret_ref;
54022 }
54023
54024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, int64_t peer_msg) {
54025         LDKUntrustedString peer_msg_conv;
54026         peer_msg_conv.inner = untag_ptr(peer_msg);
54027         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
54028         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
54029         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
54030         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54031         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
54032         int64_t ret_ref = tag_ptr(ret_copy, true);
54033         return ret_ref;
54034 }
54035
54036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
54037         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54038         *ret_copy = ClosureReason_holder_force_closed();
54039         int64_t ret_ref = tag_ptr(ret_copy, true);
54040         return ret_ref;
54041 }
54042
54043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
54044         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54045         *ret_copy = ClosureReason_cooperative_closure();
54046         int64_t ret_ref = tag_ptr(ret_copy, true);
54047         return ret_ref;
54048 }
54049
54050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
54051         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54052         *ret_copy = ClosureReason_commitment_tx_confirmed();
54053         int64_t ret_ref = tag_ptr(ret_copy, true);
54054         return ret_ref;
54055 }
54056
54057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
54058         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54059         *ret_copy = ClosureReason_funding_timed_out();
54060         int64_t ret_ref = tag_ptr(ret_copy, true);
54061         return ret_ref;
54062 }
54063
54064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
54065         LDKStr err_conv = java_to_owned_str(env, err);
54066         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54067         *ret_copy = ClosureReason_processing_error(err_conv);
54068         int64_t ret_ref = tag_ptr(ret_copy, true);
54069         return ret_ref;
54070 }
54071
54072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
54073         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54074         *ret_copy = ClosureReason_disconnected_peer();
54075         int64_t ret_ref = tag_ptr(ret_copy, true);
54076         return ret_ref;
54077 }
54078
54079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
54080         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54081         *ret_copy = ClosureReason_outdated_channel_manager();
54082         int64_t ret_ref = tag_ptr(ret_copy, true);
54083         return ret_ref;
54084 }
54085
54086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54087         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
54088         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
54089         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
54090         return ret_conv;
54091 }
54092
54093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54094         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
54095         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
54096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54098         CVec_u8Z_free(ret_var);
54099         return ret_arr;
54100 }
54101
54102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54103         LDKu8slice ser_ref;
54104         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54105         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54106         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
54107         *ret_conv = ClosureReason_read(ser_ref);
54108         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54109         return tag_ptr(ret_conv, true);
54110 }
54111
54112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54113         if (!ptr_is_owned(this_ptr)) return;
54114         void* this_ptr_ptr = untag_ptr(this_ptr);
54115         CHECK_ACCESS(this_ptr_ptr);
54116         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
54117         FREE(untag_ptr(this_ptr));
54118         HTLCDestination_free(this_ptr_conv);
54119 }
54120
54121 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
54122         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54123         *ret_copy = HTLCDestination_clone(arg);
54124         int64_t ret_ref = tag_ptr(ret_copy, true);
54125         return ret_ref;
54126 }
54127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54128         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
54129         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
54130         return ret_conv;
54131 }
54132
54133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54134         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
54135         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54136         *ret_copy = HTLCDestination_clone(orig_conv);
54137         int64_t ret_ref = tag_ptr(ret_copy, true);
54138         return ret_ref;
54139 }
54140
54141 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) {
54142         LDKPublicKey node_id_ref;
54143         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54144         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54145         LDKThirtyTwoBytes channel_id_ref;
54146         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54147         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54148         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54149         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
54150         int64_t ret_ref = tag_ptr(ret_copy, true);
54151         return ret_ref;
54152 }
54153
54154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54155         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54156         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
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_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54162         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54163         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
54164         int64_t ret_ref = tag_ptr(ret_copy, true);
54165         return ret_ref;
54166 }
54167
54168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
54169         LDKThirtyTwoBytes payment_hash_ref;
54170         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54171         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54172         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54173         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
54174         int64_t ret_ref = tag_ptr(ret_copy, true);
54175         return ret_ref;
54176 }
54177
54178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54179         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
54180         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
54181         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
54182         return ret_conv;
54183 }
54184
54185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
54186         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
54187         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
54188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54190         CVec_u8Z_free(ret_var);
54191         return ret_arr;
54192 }
54193
54194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54195         LDKu8slice ser_ref;
54196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54198         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
54199         *ret_conv = HTLCDestination_read(ser_ref);
54200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54201         return tag_ptr(ret_conv, true);
54202 }
54203
54204 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54205         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
54206         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_clone(orig_conv));
54207         return ret_conv;
54208 }
54209
54210 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1recipient_1rejected(JNIEnv *env, jclass clz) {
54211         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_recipient_rejected());
54212         return ret_conv;
54213 }
54214
54215 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1user_1abandoned(JNIEnv *env, jclass clz) {
54216         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_user_abandoned());
54217         return ret_conv;
54218 }
54219
54220 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1retries_1exhausted(JNIEnv *env, jclass clz) {
54221         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_retries_exhausted());
54222         return ret_conv;
54223 }
54224
54225 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1payment_1expired(JNIEnv *env, jclass clz) {
54226         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_payment_expired());
54227         return ret_conv;
54228 }
54229
54230 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1route_1not_1found(JNIEnv *env, jclass clz) {
54231         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_route_not_found());
54232         return ret_conv;
54233 }
54234
54235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1unexpected_1error(JNIEnv *env, jclass clz) {
54236         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_unexpected_error());
54237         return ret_conv;
54238 }
54239
54240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54241         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
54242         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
54243         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
54244         return ret_conv;
54245 }
54246
54247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54248         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
54249         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
54250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54252         CVec_u8Z_free(ret_var);
54253         return ret_arr;
54254 }
54255
54256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54257         LDKu8slice ser_ref;
54258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54260         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
54261         *ret_conv = PaymentFailureReason_read(ser_ref);
54262         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54263         return tag_ptr(ret_conv, true);
54264 }
54265
54266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54267         if (!ptr_is_owned(this_ptr)) return;
54268         void* this_ptr_ptr = untag_ptr(this_ptr);
54269         CHECK_ACCESS(this_ptr_ptr);
54270         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
54271         FREE(untag_ptr(this_ptr));
54272         Event_free(this_ptr_conv);
54273 }
54274
54275 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
54276         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54277         *ret_copy = Event_clone(arg);
54278         int64_t ret_ref = tag_ptr(ret_copy, true);
54279         return ret_ref;
54280 }
54281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54282         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
54283         int64_t ret_conv = Event_clone_ptr(arg_conv);
54284         return ret_conv;
54285 }
54286
54287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54288         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
54289         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54290         *ret_copy = Event_clone(orig_conv);
54291         int64_t ret_ref = tag_ptr(ret_copy, true);
54292         return ret_ref;
54293 }
54294
54295 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) {
54296         LDKThirtyTwoBytes temporary_channel_id_ref;
54297         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54298         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54299         LDKPublicKey counterparty_node_id_ref;
54300         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54301         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54302         LDKCVec_u8Z output_script_ref;
54303         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
54304         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
54305         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
54306         LDKU128 user_channel_id_ref;
54307         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54308         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54309         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54310         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
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_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) {
54316         LDKPublicKey receiver_node_id_ref;
54317         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54318         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54319         LDKThirtyTwoBytes payment_hash_ref;
54320         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54321         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54322         LDKRecipientOnionFields onion_fields_conv;
54323         onion_fields_conv.inner = untag_ptr(onion_fields);
54324         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
54325         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
54326         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
54327         void* purpose_ptr = untag_ptr(purpose);
54328         CHECK_ACCESS(purpose_ptr);
54329         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54330         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54331         LDKThirtyTwoBytes via_channel_id_ref;
54332         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
54333         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
54334         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
54335         CHECK_ACCESS(via_user_channel_id_ptr);
54336         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
54337         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
54338         void* claim_deadline_ptr = untag_ptr(claim_deadline);
54339         CHECK_ACCESS(claim_deadline_ptr);
54340         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
54341         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
54342         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54343         *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);
54344         int64_t ret_ref = tag_ptr(ret_copy, true);
54345         return ret_ref;
54346 }
54347
54348 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) {
54349         LDKPublicKey receiver_node_id_ref;
54350         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54351         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54352         LDKThirtyTwoBytes payment_hash_ref;
54353         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54354         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54355         void* purpose_ptr = untag_ptr(purpose);
54356         CHECK_ACCESS(purpose_ptr);
54357         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54358         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54359         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54360         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
54361         int64_t ret_ref = tag_ptr(ret_copy, true);
54362         return ret_ref;
54363 }
54364
54365 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) {
54366         LDKThirtyTwoBytes payment_id_ref;
54367         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54368         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54369         LDKThirtyTwoBytes payment_preimage_ref;
54370         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
54371         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
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* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
54376         CHECK_ACCESS(fee_paid_msat_ptr);
54377         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
54378         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
54379         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54380         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_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_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
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_hash_ref;
54390         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54391         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54392         void* reason_ptr = untag_ptr(reason);
54393         CHECK_ACCESS(reason_ptr);
54394         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
54395         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
54396         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54397         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
54398         int64_t ret_ref = tag_ptr(ret_copy, true);
54399         return ret_ref;
54400 }
54401
54402 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) {
54403         LDKThirtyTwoBytes payment_id_ref;
54404         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54405         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54406         LDKThirtyTwoBytes payment_hash_ref;
54407         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54408         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54409         LDKPath path_conv;
54410         path_conv.inner = untag_ptr(path);
54411         path_conv.is_owned = ptr_is_owned(path);
54412         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54413         path_conv = Path_clone(&path_conv);
54414         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54415         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_conv);
54416         int64_t ret_ref = tag_ptr(ret_copy, true);
54417         return ret_ref;
54418 }
54419
54420 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) {
54421         LDKThirtyTwoBytes payment_id_ref;
54422         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54423         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54424         LDKThirtyTwoBytes payment_hash_ref;
54425         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54426         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54427         void* failure_ptr = untag_ptr(failure);
54428         CHECK_ACCESS(failure_ptr);
54429         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
54430         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
54431         LDKPath path_conv;
54432         path_conv.inner = untag_ptr(path);
54433         path_conv.is_owned = ptr_is_owned(path);
54434         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54435         path_conv = Path_clone(&path_conv);
54436         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54437         CHECK_ACCESS(short_channel_id_ptr);
54438         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54439         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54440         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54441         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
54442         int64_t ret_ref = tag_ptr(ret_copy, true);
54443         return ret_ref;
54444 }
54445
54446 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) {
54447         LDKThirtyTwoBytes payment_id_ref;
54448         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54449         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54450         LDKThirtyTwoBytes payment_hash_ref;
54451         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54452         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54453         LDKPath path_conv;
54454         path_conv.inner = untag_ptr(path);
54455         path_conv.is_owned = ptr_is_owned(path);
54456         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54457         path_conv = Path_clone(&path_conv);
54458         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54459         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
54460         int64_t ret_ref = tag_ptr(ret_copy, true);
54461         return ret_ref;
54462 }
54463
54464 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) {
54465         LDKThirtyTwoBytes payment_id_ref;
54466         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54467         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54468         LDKThirtyTwoBytes payment_hash_ref;
54469         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54470         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54471         LDKPath path_conv;
54472         path_conv.inner = untag_ptr(path);
54473         path_conv.is_owned = ptr_is_owned(path);
54474         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54475         path_conv = Path_clone(&path_conv);
54476         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54477         CHECK_ACCESS(short_channel_id_ptr);
54478         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54479         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54480         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54481         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
54482         int64_t ret_ref = tag_ptr(ret_copy, true);
54483         return ret_ref;
54484 }
54485
54486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
54487         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54488         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
54489         int64_t ret_ref = tag_ptr(ret_copy, true);
54490         return ret_ref;
54491 }
54492
54493 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) {
54494         LDKThirtyTwoBytes intercept_id_ref;
54495         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
54496         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
54497         LDKThirtyTwoBytes payment_hash_ref;
54498         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54499         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54500         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54501         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
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_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
54507         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
54508         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
54509         if (outputs_constr.datalen > 0)
54510                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
54511         else
54512                 outputs_constr.data = NULL;
54513         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
54514         for (size_t b = 0; b < outputs_constr.datalen; b++) {
54515                 int64_t outputs_conv_27 = outputs_vals[b];
54516                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
54517                 CHECK_ACCESS(outputs_conv_27_ptr);
54518                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
54519                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
54520                 outputs_constr.data[b] = outputs_conv_27_conv;
54521         }
54522         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
54523         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54524         *ret_copy = Event_spendable_outputs(outputs_constr);
54525         int64_t ret_ref = tag_ptr(ret_copy, true);
54526         return ret_ref;
54527 }
54528
54529 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) {
54530         LDKThirtyTwoBytes prev_channel_id_ref;
54531         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54532         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54533         LDKThirtyTwoBytes next_channel_id_ref;
54534         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
54535         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
54536         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
54537         CHECK_ACCESS(fee_earned_msat_ptr);
54538         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
54539         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
54540         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
54541         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
54542         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
54543         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
54544         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54545         *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);
54546         int64_t ret_ref = tag_ptr(ret_copy, true);
54547         return ret_ref;
54548 }
54549
54550 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) {
54551         LDKThirtyTwoBytes channel_id_ref;
54552         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54553         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54554         LDKU128 user_channel_id_ref;
54555         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54556         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54557         LDKThirtyTwoBytes former_temporary_channel_id_ref;
54558         CHECK((*env)->GetArrayLength(env, former_temporary_channel_id) == 32);
54559         (*env)->GetByteArrayRegion(env, former_temporary_channel_id, 0, 32, former_temporary_channel_id_ref.data);
54560         LDKPublicKey counterparty_node_id_ref;
54561         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54562         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54563         LDKOutPoint funding_txo_conv;
54564         funding_txo_conv.inner = untag_ptr(funding_txo);
54565         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
54566         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
54567         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
54568         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54569         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_ref, counterparty_node_id_ref, funding_txo_conv);
54570         int64_t ret_ref = tag_ptr(ret_copy, true);
54571         return ret_ref;
54572 }
54573
54574 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) {
54575         LDKThirtyTwoBytes channel_id_ref;
54576         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54577         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54578         LDKU128 user_channel_id_ref;
54579         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54580         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54581         LDKPublicKey counterparty_node_id_ref;
54582         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54583         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54584         LDKChannelTypeFeatures channel_type_conv;
54585         channel_type_conv.inner = untag_ptr(channel_type);
54586         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54587         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54588         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54589         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54590         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
54591         int64_t ret_ref = tag_ptr(ret_copy, true);
54592         return ret_ref;
54593 }
54594
54595 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) {
54596         LDKThirtyTwoBytes channel_id_ref;
54597         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54598         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54599         LDKU128 user_channel_id_ref;
54600         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54601         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54602         void* reason_ptr = untag_ptr(reason);
54603         CHECK_ACCESS(reason_ptr);
54604         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
54605         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
54606         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54607         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
54608         int64_t ret_ref = tag_ptr(ret_copy, true);
54609         return ret_ref;
54610 }
54611
54612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
54613         LDKThirtyTwoBytes channel_id_ref;
54614         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54615         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54616         LDKTransaction transaction_ref;
54617         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
54618         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
54619         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
54620         transaction_ref.data_is_owned = true;
54621         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54622         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
54623         int64_t ret_ref = tag_ptr(ret_copy, true);
54624         return ret_ref;
54625 }
54626
54627 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) {
54628         LDKThirtyTwoBytes temporary_channel_id_ref;
54629         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54630         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54631         LDKPublicKey counterparty_node_id_ref;
54632         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54633         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54634         LDKChannelTypeFeatures channel_type_conv;
54635         channel_type_conv.inner = untag_ptr(channel_type);
54636         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54637         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54638         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54639         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54640         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
54641         int64_t ret_ref = tag_ptr(ret_copy, true);
54642         return ret_ref;
54643 }
54644
54645 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) {
54646         LDKThirtyTwoBytes prev_channel_id_ref;
54647         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54648         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54649         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
54650         CHECK_ACCESS(failed_next_destination_ptr);
54651         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
54652         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
54653         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54654         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
54655         int64_t ret_ref = tag_ptr(ret_copy, true);
54656         return ret_ref;
54657 }
54658
54659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Event_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54660         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
54661         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
54662         jboolean ret_conv = Event_eq(a_conv, b_conv);
54663         return ret_conv;
54664 }
54665
54666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
54667         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
54668         LDKCVec_u8Z ret_var = Event_write(obj_conv);
54669         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54670         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54671         CVec_u8Z_free(ret_var);
54672         return ret_arr;
54673 }
54674
54675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54676         LDKu8slice ser_ref;
54677         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54678         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54679         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
54680         *ret_conv = Event_read(ser_ref);
54681         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54682         return tag_ptr(ret_conv, true);
54683 }
54684
54685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54686         if (!ptr_is_owned(this_ptr)) return;
54687         void* this_ptr_ptr = untag_ptr(this_ptr);
54688         CHECK_ACCESS(this_ptr_ptr);
54689         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
54690         FREE(untag_ptr(this_ptr));
54691         MessageSendEvent_free(this_ptr_conv);
54692 }
54693
54694 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
54695         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54696         *ret_copy = MessageSendEvent_clone(arg);
54697         int64_t ret_ref = tag_ptr(ret_copy, true);
54698         return ret_ref;
54699 }
54700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54701         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
54702         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
54703         return ret_conv;
54704 }
54705
54706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54707         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
54708         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54709         *ret_copy = MessageSendEvent_clone(orig_conv);
54710         int64_t ret_ref = tag_ptr(ret_copy, true);
54711         return ret_ref;
54712 }
54713
54714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54715         LDKPublicKey node_id_ref;
54716         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54717         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54718         LDKAcceptChannel msg_conv;
54719         msg_conv.inner = untag_ptr(msg);
54720         msg_conv.is_owned = ptr_is_owned(msg);
54721         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54722         msg_conv = AcceptChannel_clone(&msg_conv);
54723         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54724         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
54725         int64_t ret_ref = tag_ptr(ret_copy, true);
54726         return ret_ref;
54727 }
54728
54729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54730         LDKPublicKey node_id_ref;
54731         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54732         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54733         LDKOpenChannel msg_conv;
54734         msg_conv.inner = untag_ptr(msg);
54735         msg_conv.is_owned = ptr_is_owned(msg);
54736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54737         msg_conv = OpenChannel_clone(&msg_conv);
54738         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54739         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
54740         int64_t ret_ref = tag_ptr(ret_copy, true);
54741         return ret_ref;
54742 }
54743
54744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54745         LDKPublicKey node_id_ref;
54746         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54747         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54748         LDKFundingCreated msg_conv;
54749         msg_conv.inner = untag_ptr(msg);
54750         msg_conv.is_owned = ptr_is_owned(msg);
54751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54752         msg_conv = FundingCreated_clone(&msg_conv);
54753         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54754         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
54755         int64_t ret_ref = tag_ptr(ret_copy, true);
54756         return ret_ref;
54757 }
54758
54759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54760         LDKPublicKey node_id_ref;
54761         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54762         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54763         LDKFundingSigned msg_conv;
54764         msg_conv.inner = untag_ptr(msg);
54765         msg_conv.is_owned = ptr_is_owned(msg);
54766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54767         msg_conv = FundingSigned_clone(&msg_conv);
54768         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54769         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
54770         int64_t ret_ref = tag_ptr(ret_copy, true);
54771         return ret_ref;
54772 }
54773
54774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54775         LDKPublicKey node_id_ref;
54776         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54777         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54778         LDKChannelReady msg_conv;
54779         msg_conv.inner = untag_ptr(msg);
54780         msg_conv.is_owned = ptr_is_owned(msg);
54781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54782         msg_conv = ChannelReady_clone(&msg_conv);
54783         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54784         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
54785         int64_t ret_ref = tag_ptr(ret_copy, true);
54786         return ret_ref;
54787 }
54788
54789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54790         LDKPublicKey node_id_ref;
54791         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54792         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54793         LDKAnnouncementSignatures msg_conv;
54794         msg_conv.inner = untag_ptr(msg);
54795         msg_conv.is_owned = ptr_is_owned(msg);
54796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54797         msg_conv = AnnouncementSignatures_clone(&msg_conv);
54798         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54799         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
54800         int64_t ret_ref = tag_ptr(ret_copy, true);
54801         return ret_ref;
54802 }
54803
54804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
54805         LDKPublicKey node_id_ref;
54806         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54807         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54808         LDKCommitmentUpdate updates_conv;
54809         updates_conv.inner = untag_ptr(updates);
54810         updates_conv.is_owned = ptr_is_owned(updates);
54811         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
54812         updates_conv = CommitmentUpdate_clone(&updates_conv);
54813         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54814         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
54815         int64_t ret_ref = tag_ptr(ret_copy, true);
54816         return ret_ref;
54817 }
54818
54819 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) {
54820         LDKPublicKey node_id_ref;
54821         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54822         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54823         LDKRevokeAndACK msg_conv;
54824         msg_conv.inner = untag_ptr(msg);
54825         msg_conv.is_owned = ptr_is_owned(msg);
54826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54827         msg_conv = RevokeAndACK_clone(&msg_conv);
54828         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54829         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
54830         int64_t ret_ref = tag_ptr(ret_copy, true);
54831         return ret_ref;
54832 }
54833
54834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54835         LDKPublicKey node_id_ref;
54836         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54837         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54838         LDKClosingSigned msg_conv;
54839         msg_conv.inner = untag_ptr(msg);
54840         msg_conv.is_owned = ptr_is_owned(msg);
54841         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54842         msg_conv = ClosingSigned_clone(&msg_conv);
54843         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54844         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
54845         int64_t ret_ref = tag_ptr(ret_copy, true);
54846         return ret_ref;
54847 }
54848
54849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54850         LDKPublicKey node_id_ref;
54851         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54852         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54853         LDKShutdown msg_conv;
54854         msg_conv.inner = untag_ptr(msg);
54855         msg_conv.is_owned = ptr_is_owned(msg);
54856         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54857         msg_conv = Shutdown_clone(&msg_conv);
54858         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54859         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
54860         int64_t ret_ref = tag_ptr(ret_copy, true);
54861         return ret_ref;
54862 }
54863
54864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54865         LDKPublicKey node_id_ref;
54866         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54867         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54868         LDKChannelReestablish msg_conv;
54869         msg_conv.inner = untag_ptr(msg);
54870         msg_conv.is_owned = ptr_is_owned(msg);
54871         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54872         msg_conv = ChannelReestablish_clone(&msg_conv);
54873         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54874         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
54875         int64_t ret_ref = tag_ptr(ret_copy, true);
54876         return ret_ref;
54877 }
54878
54879 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) {
54880         LDKPublicKey node_id_ref;
54881         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54882         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54883         LDKChannelAnnouncement msg_conv;
54884         msg_conv.inner = untag_ptr(msg);
54885         msg_conv.is_owned = ptr_is_owned(msg);
54886         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54887         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54888         LDKChannelUpdate update_msg_conv;
54889         update_msg_conv.inner = untag_ptr(update_msg);
54890         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54891         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54892         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54893         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54894         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_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_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
54900         LDKChannelAnnouncement msg_conv;
54901         msg_conv.inner = untag_ptr(msg);
54902         msg_conv.is_owned = ptr_is_owned(msg);
54903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54904         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54905         LDKChannelUpdate update_msg_conv;
54906         update_msg_conv.inner = untag_ptr(update_msg);
54907         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54908         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54909         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54910         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54911         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
54912         int64_t ret_ref = tag_ptr(ret_copy, true);
54913         return ret_ref;
54914 }
54915
54916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
54917         LDKChannelUpdate msg_conv;
54918         msg_conv.inner = untag_ptr(msg);
54919         msg_conv.is_owned = ptr_is_owned(msg);
54920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54921         msg_conv = ChannelUpdate_clone(&msg_conv);
54922         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54923         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
54924         int64_t ret_ref = tag_ptr(ret_copy, true);
54925         return ret_ref;
54926 }
54927
54928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
54929         LDKNodeAnnouncement msg_conv;
54930         msg_conv.inner = untag_ptr(msg);
54931         msg_conv.is_owned = ptr_is_owned(msg);
54932         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54933         msg_conv = NodeAnnouncement_clone(&msg_conv);
54934         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54935         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
54936         int64_t ret_ref = tag_ptr(ret_copy, true);
54937         return ret_ref;
54938 }
54939
54940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54941         LDKPublicKey node_id_ref;
54942         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54943         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54944         LDKChannelUpdate msg_conv;
54945         msg_conv.inner = untag_ptr(msg);
54946         msg_conv.is_owned = ptr_is_owned(msg);
54947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54948         msg_conv = ChannelUpdate_clone(&msg_conv);
54949         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54950         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
54951         int64_t ret_ref = tag_ptr(ret_copy, true);
54952         return ret_ref;
54953 }
54954
54955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
54956         LDKPublicKey node_id_ref;
54957         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54958         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54959         void* action_ptr = untag_ptr(action);
54960         CHECK_ACCESS(action_ptr);
54961         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
54962         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
54963         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54964         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
54965         int64_t ret_ref = tag_ptr(ret_copy, true);
54966         return ret_ref;
54967 }
54968
54969 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) {
54970         LDKPublicKey node_id_ref;
54971         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54972         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54973         LDKQueryChannelRange msg_conv;
54974         msg_conv.inner = untag_ptr(msg);
54975         msg_conv.is_owned = ptr_is_owned(msg);
54976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54977         msg_conv = QueryChannelRange_clone(&msg_conv);
54978         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54979         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
54980         int64_t ret_ref = tag_ptr(ret_copy, true);
54981         return ret_ref;
54982 }
54983
54984 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) {
54985         LDKPublicKey node_id_ref;
54986         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54987         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54988         LDKQueryShortChannelIds msg_conv;
54989         msg_conv.inner = untag_ptr(msg);
54990         msg_conv.is_owned = ptr_is_owned(msg);
54991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54992         msg_conv = QueryShortChannelIds_clone(&msg_conv);
54993         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54994         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
54995         int64_t ret_ref = tag_ptr(ret_copy, true);
54996         return ret_ref;
54997 }
54998
54999 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) {
55000         LDKPublicKey node_id_ref;
55001         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55002         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55003         LDKReplyChannelRange msg_conv;
55004         msg_conv.inner = untag_ptr(msg);
55005         msg_conv.is_owned = ptr_is_owned(msg);
55006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55007         msg_conv = ReplyChannelRange_clone(&msg_conv);
55008         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55009         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
55010         int64_t ret_ref = tag_ptr(ret_copy, true);
55011         return ret_ref;
55012 }
55013
55014 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) {
55015         LDKPublicKey node_id_ref;
55016         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55017         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55018         LDKGossipTimestampFilter msg_conv;
55019         msg_conv.inner = untag_ptr(msg);
55020         msg_conv.is_owned = ptr_is_owned(msg);
55021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55022         msg_conv = GossipTimestampFilter_clone(&msg_conv);
55023         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55024         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
55025         int64_t ret_ref = tag_ptr(ret_copy, true);
55026         return ret_ref;
55027 }
55028
55029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55030         if (!ptr_is_owned(this_ptr)) return;
55031         void* this_ptr_ptr = untag_ptr(this_ptr);
55032         CHECK_ACCESS(this_ptr_ptr);
55033         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
55034         FREE(untag_ptr(this_ptr));
55035         MessageSendEventsProvider_free(this_ptr_conv);
55036 }
55037
55038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55039         if (!ptr_is_owned(this_ptr)) return;
55040         void* this_ptr_ptr = untag_ptr(this_ptr);
55041         CHECK_ACCESS(this_ptr_ptr);
55042         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
55043         FREE(untag_ptr(this_ptr));
55044         OnionMessageProvider_free(this_ptr_conv);
55045 }
55046
55047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55048         if (!ptr_is_owned(this_ptr)) return;
55049         void* this_ptr_ptr = untag_ptr(this_ptr);
55050         CHECK_ACCESS(this_ptr_ptr);
55051         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
55052         FREE(untag_ptr(this_ptr));
55053         EventsProvider_free(this_ptr_conv);
55054 }
55055
55056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55057         if (!ptr_is_owned(this_ptr)) return;
55058         void* this_ptr_ptr = untag_ptr(this_ptr);
55059         CHECK_ACCESS(this_ptr_ptr);
55060         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
55061         FREE(untag_ptr(this_ptr));
55062         EventHandler_free(this_ptr_conv);
55063 }
55064
55065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55066         LDKFilesystemPersister this_obj_conv;
55067         this_obj_conv.inner = untag_ptr(this_obj);
55068         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55070         FilesystemPersister_free(this_obj_conv);
55071 }
55072
55073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
55074         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
55075         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
55076         int64_t ret_ref = 0;
55077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55079         return ret_ref;
55080 }
55081
55082 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
55083         LDKFilesystemPersister this_arg_conv;
55084         this_arg_conv.inner = untag_ptr(this_arg);
55085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55087         this_arg_conv.is_owned = false;
55088         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
55089         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
55090         Str_free(ret_str);
55091         return ret_conv;
55092 }
55093
55094 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) {
55095         LDKFilesystemPersister this_arg_conv;
55096         this_arg_conv.inner = untag_ptr(this_arg);
55097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55099         this_arg_conv.is_owned = false;
55100         void* entropy_source_ptr = untag_ptr(entropy_source);
55101         CHECK_ACCESS(entropy_source_ptr);
55102         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
55103         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
55104                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55105                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
55106         }
55107         void* signer_provider_ptr = untag_ptr(signer_provider);
55108         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
55109         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
55110         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
55111         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, entropy_source_conv, signer_provider_conv);
55112         return tag_ptr(ret_conv, true);
55113 }
55114
55115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55116         LDKBackgroundProcessor this_obj_conv;
55117         this_obj_conv.inner = untag_ptr(this_obj);
55118         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55120         BackgroundProcessor_free(this_obj_conv);
55121 }
55122
55123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55124         if (!ptr_is_owned(this_ptr)) return;
55125         void* this_ptr_ptr = untag_ptr(this_ptr);
55126         CHECK_ACCESS(this_ptr_ptr);
55127         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
55128         FREE(untag_ptr(this_ptr));
55129         GossipSync_free(this_ptr_conv);
55130 }
55131
55132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
55133         LDKP2PGossipSync a_conv;
55134         a_conv.inner = untag_ptr(a);
55135         a_conv.is_owned = ptr_is_owned(a);
55136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55137         a_conv.is_owned = false;
55138         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55139         *ret_copy = GossipSync_p2_p(&a_conv);
55140         int64_t ret_ref = tag_ptr(ret_copy, true);
55141         return ret_ref;
55142 }
55143
55144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
55145         LDKRapidGossipSync a_conv;
55146         a_conv.inner = untag_ptr(a);
55147         a_conv.is_owned = ptr_is_owned(a);
55148         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55149         a_conv.is_owned = false;
55150         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55151         *ret_copy = GossipSync_rapid(&a_conv);
55152         int64_t ret_ref = tag_ptr(ret_copy, true);
55153         return ret_ref;
55154 }
55155
55156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
55157         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55158         *ret_copy = GossipSync_none();
55159         int64_t ret_ref = tag_ptr(ret_copy, true);
55160         return ret_ref;
55161 }
55162
55163 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) {
55164         void* persister_ptr = untag_ptr(persister);
55165         CHECK_ACCESS(persister_ptr);
55166         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
55167         if (persister_conv.free == LDKPersister_JCalls_free) {
55168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55169                 LDKPersister_JCalls_cloned(&persister_conv);
55170         }
55171         void* event_handler_ptr = untag_ptr(event_handler);
55172         CHECK_ACCESS(event_handler_ptr);
55173         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
55174         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
55175                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55176                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
55177         }
55178         LDKChainMonitor chain_monitor_conv;
55179         chain_monitor_conv.inner = untag_ptr(chain_monitor);
55180         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
55181         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
55182         chain_monitor_conv.is_owned = false;
55183         LDKChannelManager channel_manager_conv;
55184         channel_manager_conv.inner = untag_ptr(channel_manager);
55185         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
55186         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
55187         channel_manager_conv.is_owned = false;
55188         void* gossip_sync_ptr = untag_ptr(gossip_sync);
55189         CHECK_ACCESS(gossip_sync_ptr);
55190         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
55191         // WARNING: we may need a move here but no clone is available for LDKGossipSync
55192         LDKPeerManager peer_manager_conv;
55193         peer_manager_conv.inner = untag_ptr(peer_manager);
55194         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
55195         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
55196         peer_manager_conv.is_owned = false;
55197         void* logger_ptr = untag_ptr(logger);
55198         CHECK_ACCESS(logger_ptr);
55199         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
55200         if (logger_conv.free == LDKLogger_JCalls_free) {
55201                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55202                 LDKLogger_JCalls_cloned(&logger_conv);
55203         }
55204         void* scorer_ptr = untag_ptr(scorer);
55205         CHECK_ACCESS(scorer_ptr);
55206         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
55207         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
55208         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
55209                 // Manually implement clone for Java trait instances
55210                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
55211                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55212                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
55213                 }
55214         }
55215         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);
55216         int64_t ret_ref = 0;
55217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55219         return ret_ref;
55220 }
55221
55222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
55223         LDKBackgroundProcessor this_arg_conv;
55224         this_arg_conv.inner = untag_ptr(this_arg);
55225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55227         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55228         
55229         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55230         *ret_conv = BackgroundProcessor_join(this_arg_conv);
55231         return tag_ptr(ret_conv, true);
55232 }
55233
55234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
55235         LDKBackgroundProcessor this_arg_conv;
55236         this_arg_conv.inner = untag_ptr(this_arg);
55237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55239         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55240         
55241         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55242         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
55243         return tag_ptr(ret_conv, true);
55244 }
55245
55246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55247         if (!ptr_is_owned(this_ptr)) return;
55248         void* this_ptr_ptr = untag_ptr(this_ptr);
55249         CHECK_ACCESS(this_ptr_ptr);
55250         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
55251         FREE(untag_ptr(this_ptr));
55252         ParseError_free(this_ptr_conv);
55253 }
55254
55255 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
55256         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55257         *ret_copy = ParseError_clone(arg);
55258         int64_t ret_ref = tag_ptr(ret_copy, true);
55259         return ret_ref;
55260 }
55261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55262         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
55263         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
55264         return ret_conv;
55265 }
55266
55267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55268         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
55269         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55270         *ret_copy = ParseError_clone(orig_conv);
55271         int64_t ret_ref = tag_ptr(ret_copy, true);
55272         return ret_ref;
55273 }
55274
55275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
55276         void* a_ptr = untag_ptr(a);
55277         CHECK_ACCESS(a_ptr);
55278         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
55279         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
55280         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55281         *ret_copy = ParseError_bech32_error(a_conv);
55282         int64_t ret_ref = tag_ptr(ret_copy, true);
55283         return ret_ref;
55284 }
55285
55286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
55287         
55288         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55289         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
55290         int64_t ret_ref = tag_ptr(ret_copy, true);
55291         return ret_ref;
55292 }
55293
55294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
55295         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
55296         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55297         *ret_copy = ParseError_malformed_signature(a_conv);
55298         int64_t ret_ref = tag_ptr(ret_copy, true);
55299         return ret_ref;
55300 }
55301
55302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
55303         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55304         *ret_copy = ParseError_bad_prefix();
55305         int64_t ret_ref = tag_ptr(ret_copy, true);
55306         return ret_ref;
55307 }
55308
55309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
55310         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55311         *ret_copy = ParseError_unknown_currency();
55312         int64_t ret_ref = tag_ptr(ret_copy, true);
55313         return ret_ref;
55314 }
55315
55316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
55317         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55318         *ret_copy = ParseError_unknown_si_prefix();
55319         int64_t ret_ref = tag_ptr(ret_copy, true);
55320         return ret_ref;
55321 }
55322
55323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
55324         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55325         *ret_copy = ParseError_malformed_hrp();
55326         int64_t ret_ref = tag_ptr(ret_copy, true);
55327         return ret_ref;
55328 }
55329
55330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
55331         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55332         *ret_copy = ParseError_too_short_data_part();
55333         int64_t ret_ref = tag_ptr(ret_copy, true);
55334         return ret_ref;
55335 }
55336
55337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
55338         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55339         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
55340         int64_t ret_ref = tag_ptr(ret_copy, true);
55341         return ret_ref;
55342 }
55343
55344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
55345         
55346         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55347         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
55348         int64_t ret_ref = tag_ptr(ret_copy, true);
55349         return ret_ref;
55350 }
55351
55352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
55353         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55354         *ret_copy = ParseError_padding_error();
55355         int64_t ret_ref = tag_ptr(ret_copy, true);
55356         return ret_ref;
55357 }
55358
55359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
55360         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55361         *ret_copy = ParseError_integer_overflow_error();
55362         int64_t ret_ref = tag_ptr(ret_copy, true);
55363         return ret_ref;
55364 }
55365
55366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
55367         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55368         *ret_copy = ParseError_invalid_seg_wit_program_length();
55369         int64_t ret_ref = tag_ptr(ret_copy, true);
55370         return ret_ref;
55371 }
55372
55373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
55374         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55375         *ret_copy = ParseError_invalid_pub_key_hash_length();
55376         int64_t ret_ref = tag_ptr(ret_copy, true);
55377         return ret_ref;
55378 }
55379
55380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
55381         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55382         *ret_copy = ParseError_invalid_script_hash_length();
55383         int64_t ret_ref = tag_ptr(ret_copy, true);
55384         return ret_ref;
55385 }
55386
55387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
55388         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55389         *ret_copy = ParseError_invalid_recovery_id();
55390         int64_t ret_ref = tag_ptr(ret_copy, true);
55391         return ret_ref;
55392 }
55393
55394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
55395         LDKStr a_conv = java_to_owned_str(env, a);
55396         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55397         *ret_copy = ParseError_invalid_slice_length(a_conv);
55398         int64_t ret_ref = tag_ptr(ret_copy, true);
55399         return ret_ref;
55400 }
55401
55402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
55403         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55404         *ret_copy = ParseError_skip();
55405         int64_t ret_ref = tag_ptr(ret_copy, true);
55406         return ret_ref;
55407 }
55408
55409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55410         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
55411         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
55412         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
55413         return ret_conv;
55414 }
55415
55416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55417         if (!ptr_is_owned(this_ptr)) return;
55418         void* this_ptr_ptr = untag_ptr(this_ptr);
55419         CHECK_ACCESS(this_ptr_ptr);
55420         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
55421         FREE(untag_ptr(this_ptr));
55422         ParseOrSemanticError_free(this_ptr_conv);
55423 }
55424
55425 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
55426         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55427         *ret_copy = ParseOrSemanticError_clone(arg);
55428         int64_t ret_ref = tag_ptr(ret_copy, true);
55429         return ret_ref;
55430 }
55431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55432         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
55433         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
55434         return ret_conv;
55435 }
55436
55437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55438         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
55439         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55440         *ret_copy = ParseOrSemanticError_clone(orig_conv);
55441         int64_t ret_ref = tag_ptr(ret_copy, true);
55442         return ret_ref;
55443 }
55444
55445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
55446         void* a_ptr = untag_ptr(a);
55447         CHECK_ACCESS(a_ptr);
55448         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
55449         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
55450         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55451         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
55452         int64_t ret_ref = tag_ptr(ret_copy, true);
55453         return ret_ref;
55454 }
55455
55456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
55457         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
55458         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55459         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
55460         int64_t ret_ref = tag_ptr(ret_copy, true);
55461         return ret_ref;
55462 }
55463
55464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55465         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
55466         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
55467         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
55468         return ret_conv;
55469 }
55470
55471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55472         LDKInvoice this_obj_conv;
55473         this_obj_conv.inner = untag_ptr(this_obj);
55474         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55476         Invoice_free(this_obj_conv);
55477 }
55478
55479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55480         LDKInvoice a_conv;
55481         a_conv.inner = untag_ptr(a);
55482         a_conv.is_owned = ptr_is_owned(a);
55483         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55484         a_conv.is_owned = false;
55485         LDKInvoice b_conv;
55486         b_conv.inner = untag_ptr(b);
55487         b_conv.is_owned = ptr_is_owned(b);
55488         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55489         b_conv.is_owned = false;
55490         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
55491         return ret_conv;
55492 }
55493
55494 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
55495         LDKInvoice ret_var = Invoice_clone(arg);
55496         int64_t ret_ref = 0;
55497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55499         return ret_ref;
55500 }
55501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55502         LDKInvoice arg_conv;
55503         arg_conv.inner = untag_ptr(arg);
55504         arg_conv.is_owned = ptr_is_owned(arg);
55505         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55506         arg_conv.is_owned = false;
55507         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
55508         return ret_conv;
55509 }
55510
55511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55512         LDKInvoice orig_conv;
55513         orig_conv.inner = untag_ptr(orig);
55514         orig_conv.is_owned = ptr_is_owned(orig);
55515         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55516         orig_conv.is_owned = false;
55517         LDKInvoice ret_var = Invoice_clone(&orig_conv);
55518         int64_t ret_ref = 0;
55519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55521         return ret_ref;
55522 }
55523
55524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55525         LDKInvoice o_conv;
55526         o_conv.inner = untag_ptr(o);
55527         o_conv.is_owned = ptr_is_owned(o);
55528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55529         o_conv.is_owned = false;
55530         int64_t ret_conv = Invoice_hash(&o_conv);
55531         return ret_conv;
55532 }
55533
55534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55535         LDKSignedRawInvoice this_obj_conv;
55536         this_obj_conv.inner = untag_ptr(this_obj);
55537         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55539         SignedRawInvoice_free(this_obj_conv);
55540 }
55541
55542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55543         LDKSignedRawInvoice a_conv;
55544         a_conv.inner = untag_ptr(a);
55545         a_conv.is_owned = ptr_is_owned(a);
55546         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55547         a_conv.is_owned = false;
55548         LDKSignedRawInvoice b_conv;
55549         b_conv.inner = untag_ptr(b);
55550         b_conv.is_owned = ptr_is_owned(b);
55551         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55552         b_conv.is_owned = false;
55553         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
55554         return ret_conv;
55555 }
55556
55557 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
55558         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
55559         int64_t ret_ref = 0;
55560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55562         return ret_ref;
55563 }
55564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55565         LDKSignedRawInvoice arg_conv;
55566         arg_conv.inner = untag_ptr(arg);
55567         arg_conv.is_owned = ptr_is_owned(arg);
55568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55569         arg_conv.is_owned = false;
55570         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
55571         return ret_conv;
55572 }
55573
55574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55575         LDKSignedRawInvoice orig_conv;
55576         orig_conv.inner = untag_ptr(orig);
55577         orig_conv.is_owned = ptr_is_owned(orig);
55578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55579         orig_conv.is_owned = false;
55580         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
55581         int64_t ret_ref = 0;
55582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55584         return ret_ref;
55585 }
55586
55587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55588         LDKSignedRawInvoice o_conv;
55589         o_conv.inner = untag_ptr(o);
55590         o_conv.is_owned = ptr_is_owned(o);
55591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55592         o_conv.is_owned = false;
55593         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
55594         return ret_conv;
55595 }
55596
55597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55598         LDKRawInvoice this_obj_conv;
55599         this_obj_conv.inner = untag_ptr(this_obj);
55600         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55602         RawInvoice_free(this_obj_conv);
55603 }
55604
55605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
55606         LDKRawInvoice this_ptr_conv;
55607         this_ptr_conv.inner = untag_ptr(this_ptr);
55608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55610         this_ptr_conv.is_owned = false;
55611         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
55612         int64_t ret_ref = 0;
55613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55615         return ret_ref;
55616 }
55617
55618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55619         LDKRawInvoice this_ptr_conv;
55620         this_ptr_conv.inner = untag_ptr(this_ptr);
55621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55623         this_ptr_conv.is_owned = false;
55624         LDKRawDataPart val_conv;
55625         val_conv.inner = untag_ptr(val);
55626         val_conv.is_owned = ptr_is_owned(val);
55627         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55628         val_conv = RawDataPart_clone(&val_conv);
55629         RawInvoice_set_data(&this_ptr_conv, val_conv);
55630 }
55631
55632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55633         LDKRawInvoice a_conv;
55634         a_conv.inner = untag_ptr(a);
55635         a_conv.is_owned = ptr_is_owned(a);
55636         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55637         a_conv.is_owned = false;
55638         LDKRawInvoice b_conv;
55639         b_conv.inner = untag_ptr(b);
55640         b_conv.is_owned = ptr_is_owned(b);
55641         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55642         b_conv.is_owned = false;
55643         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
55644         return ret_conv;
55645 }
55646
55647 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
55648         LDKRawInvoice ret_var = RawInvoice_clone(arg);
55649         int64_t ret_ref = 0;
55650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55652         return ret_ref;
55653 }
55654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55655         LDKRawInvoice arg_conv;
55656         arg_conv.inner = untag_ptr(arg);
55657         arg_conv.is_owned = ptr_is_owned(arg);
55658         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55659         arg_conv.is_owned = false;
55660         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
55661         return ret_conv;
55662 }
55663
55664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55665         LDKRawInvoice orig_conv;
55666         orig_conv.inner = untag_ptr(orig);
55667         orig_conv.is_owned = ptr_is_owned(orig);
55668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55669         orig_conv.is_owned = false;
55670         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
55671         int64_t ret_ref = 0;
55672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55674         return ret_ref;
55675 }
55676
55677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55678         LDKRawInvoice o_conv;
55679         o_conv.inner = untag_ptr(o);
55680         o_conv.is_owned = ptr_is_owned(o);
55681         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55682         o_conv.is_owned = false;
55683         int64_t ret_conv = RawInvoice_hash(&o_conv);
55684         return ret_conv;
55685 }
55686
55687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55688         LDKRawDataPart this_obj_conv;
55689         this_obj_conv.inner = untag_ptr(this_obj);
55690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55692         RawDataPart_free(this_obj_conv);
55693 }
55694
55695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
55696         LDKRawDataPart this_ptr_conv;
55697         this_ptr_conv.inner = untag_ptr(this_ptr);
55698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55700         this_ptr_conv.is_owned = false;
55701         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
55702         int64_t ret_ref = 0;
55703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55705         return ret_ref;
55706 }
55707
55708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55709         LDKRawDataPart this_ptr_conv;
55710         this_ptr_conv.inner = untag_ptr(this_ptr);
55711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55713         this_ptr_conv.is_owned = false;
55714         LDKPositiveTimestamp val_conv;
55715         val_conv.inner = untag_ptr(val);
55716         val_conv.is_owned = ptr_is_owned(val);
55717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55718         val_conv = PositiveTimestamp_clone(&val_conv);
55719         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
55720 }
55721
55722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55723         LDKRawDataPart a_conv;
55724         a_conv.inner = untag_ptr(a);
55725         a_conv.is_owned = ptr_is_owned(a);
55726         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55727         a_conv.is_owned = false;
55728         LDKRawDataPart b_conv;
55729         b_conv.inner = untag_ptr(b);
55730         b_conv.is_owned = ptr_is_owned(b);
55731         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55732         b_conv.is_owned = false;
55733         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
55734         return ret_conv;
55735 }
55736
55737 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
55738         LDKRawDataPart ret_var = RawDataPart_clone(arg);
55739         int64_t ret_ref = 0;
55740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55742         return ret_ref;
55743 }
55744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55745         LDKRawDataPart arg_conv;
55746         arg_conv.inner = untag_ptr(arg);
55747         arg_conv.is_owned = ptr_is_owned(arg);
55748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55749         arg_conv.is_owned = false;
55750         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
55751         return ret_conv;
55752 }
55753
55754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55755         LDKRawDataPart orig_conv;
55756         orig_conv.inner = untag_ptr(orig);
55757         orig_conv.is_owned = ptr_is_owned(orig);
55758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55759         orig_conv.is_owned = false;
55760         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
55761         int64_t ret_ref = 0;
55762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55764         return ret_ref;
55765 }
55766
55767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
55768         LDKRawDataPart o_conv;
55769         o_conv.inner = untag_ptr(o);
55770         o_conv.is_owned = ptr_is_owned(o);
55771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55772         o_conv.is_owned = false;
55773         int64_t ret_conv = RawDataPart_hash(&o_conv);
55774         return ret_conv;
55775 }
55776
55777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55778         LDKPositiveTimestamp this_obj_conv;
55779         this_obj_conv.inner = untag_ptr(this_obj);
55780         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55782         PositiveTimestamp_free(this_obj_conv);
55783 }
55784
55785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55786         LDKPositiveTimestamp a_conv;
55787         a_conv.inner = untag_ptr(a);
55788         a_conv.is_owned = ptr_is_owned(a);
55789         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55790         a_conv.is_owned = false;
55791         LDKPositiveTimestamp b_conv;
55792         b_conv.inner = untag_ptr(b);
55793         b_conv.is_owned = ptr_is_owned(b);
55794         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55795         b_conv.is_owned = false;
55796         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
55797         return ret_conv;
55798 }
55799
55800 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
55801         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
55802         int64_t ret_ref = 0;
55803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55805         return ret_ref;
55806 }
55807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55808         LDKPositiveTimestamp arg_conv;
55809         arg_conv.inner = untag_ptr(arg);
55810         arg_conv.is_owned = ptr_is_owned(arg);
55811         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55812         arg_conv.is_owned = false;
55813         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
55814         return ret_conv;
55815 }
55816
55817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55818         LDKPositiveTimestamp orig_conv;
55819         orig_conv.inner = untag_ptr(orig);
55820         orig_conv.is_owned = ptr_is_owned(orig);
55821         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55822         orig_conv.is_owned = false;
55823         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
55824         int64_t ret_ref = 0;
55825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55827         return ret_ref;
55828 }
55829
55830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
55831         LDKPositiveTimestamp o_conv;
55832         o_conv.inner = untag_ptr(o);
55833         o_conv.is_owned = ptr_is_owned(o);
55834         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55835         o_conv.is_owned = false;
55836         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
55837         return ret_conv;
55838 }
55839
55840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55841         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
55842         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
55843         return ret_conv;
55844 }
55845
55846 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
55847         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
55848         return ret_conv;
55849 }
55850
55851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
55852         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
55853         return ret_conv;
55854 }
55855
55856 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
55857         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
55858         return ret_conv;
55859 }
55860
55861 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
55862         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
55863         return ret_conv;
55864 }
55865
55866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55867         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
55868         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
55869         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
55870         return ret_conv;
55871 }
55872
55873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
55874         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
55875         int64_t ret_conv = SiPrefix_hash(o_conv);
55876         return ret_conv;
55877 }
55878
55879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
55880         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
55881         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
55882         return ret_conv;
55883 }
55884
55885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55886         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
55887         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
55888         return ret_conv;
55889 }
55890
55891 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
55892         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
55893         return ret_conv;
55894 }
55895
55896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
55897         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
55898         return ret_conv;
55899 }
55900
55901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
55902         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
55903         return ret_conv;
55904 }
55905
55906 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
55907         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
55908         return ret_conv;
55909 }
55910
55911 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
55912         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
55913         return ret_conv;
55914 }
55915
55916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
55917         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
55918         int64_t ret_conv = Currency_hash(o_conv);
55919         return ret_conv;
55920 }
55921
55922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55923         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
55924         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
55925         jboolean ret_conv = Currency_eq(a_conv, b_conv);
55926         return ret_conv;
55927 }
55928
55929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55930         LDKSha256 this_obj_conv;
55931         this_obj_conv.inner = untag_ptr(this_obj);
55932         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55934         Sha256_free(this_obj_conv);
55935 }
55936
55937 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
55938         LDKSha256 ret_var = Sha256_clone(arg);
55939         int64_t ret_ref = 0;
55940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55942         return ret_ref;
55943 }
55944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55945         LDKSha256 arg_conv;
55946         arg_conv.inner = untag_ptr(arg);
55947         arg_conv.is_owned = ptr_is_owned(arg);
55948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55949         arg_conv.is_owned = false;
55950         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
55951         return ret_conv;
55952 }
55953
55954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55955         LDKSha256 orig_conv;
55956         orig_conv.inner = untag_ptr(orig);
55957         orig_conv.is_owned = ptr_is_owned(orig);
55958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55959         orig_conv.is_owned = false;
55960         LDKSha256 ret_var = Sha256_clone(&orig_conv);
55961         int64_t ret_ref = 0;
55962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55964         return ret_ref;
55965 }
55966
55967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
55968         LDKSha256 o_conv;
55969         o_conv.inner = untag_ptr(o);
55970         o_conv.is_owned = ptr_is_owned(o);
55971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55972         o_conv.is_owned = false;
55973         int64_t ret_conv = Sha256_hash(&o_conv);
55974         return ret_conv;
55975 }
55976
55977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55978         LDKSha256 a_conv;
55979         a_conv.inner = untag_ptr(a);
55980         a_conv.is_owned = ptr_is_owned(a);
55981         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55982         a_conv.is_owned = false;
55983         LDKSha256 b_conv;
55984         b_conv.inner = untag_ptr(b);
55985         b_conv.is_owned = ptr_is_owned(b);
55986         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55987         b_conv.is_owned = false;
55988         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
55989         return ret_conv;
55990 }
55991
55992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1from_1bytes(JNIEnv *env, jclass clz, int8_tArray bytes) {
55993         uint8_t bytes_arr[32];
55994         CHECK((*env)->GetArrayLength(env, bytes) == 32);
55995         (*env)->GetByteArrayRegion(env, bytes, 0, 32, bytes_arr);
55996         uint8_t (*bytes_ref)[32] = &bytes_arr;
55997         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
55998         int64_t ret_ref = 0;
55999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56001         return ret_ref;
56002 }
56003
56004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56005         LDKDescription this_obj_conv;
56006         this_obj_conv.inner = untag_ptr(this_obj);
56007         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56009         Description_free(this_obj_conv);
56010 }
56011
56012 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
56013         LDKDescription ret_var = Description_clone(arg);
56014         int64_t ret_ref = 0;
56015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56017         return ret_ref;
56018 }
56019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56020         LDKDescription arg_conv;
56021         arg_conv.inner = untag_ptr(arg);
56022         arg_conv.is_owned = ptr_is_owned(arg);
56023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56024         arg_conv.is_owned = false;
56025         int64_t ret_conv = Description_clone_ptr(&arg_conv);
56026         return ret_conv;
56027 }
56028
56029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56030         LDKDescription orig_conv;
56031         orig_conv.inner = untag_ptr(orig);
56032         orig_conv.is_owned = ptr_is_owned(orig);
56033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56034         orig_conv.is_owned = false;
56035         LDKDescription ret_var = Description_clone(&orig_conv);
56036         int64_t ret_ref = 0;
56037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56039         return ret_ref;
56040 }
56041
56042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
56043         LDKDescription o_conv;
56044         o_conv.inner = untag_ptr(o);
56045         o_conv.is_owned = ptr_is_owned(o);
56046         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56047         o_conv.is_owned = false;
56048         int64_t ret_conv = Description_hash(&o_conv);
56049         return ret_conv;
56050 }
56051
56052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56053         LDKDescription a_conv;
56054         a_conv.inner = untag_ptr(a);
56055         a_conv.is_owned = ptr_is_owned(a);
56056         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56057         a_conv.is_owned = false;
56058         LDKDescription b_conv;
56059         b_conv.inner = untag_ptr(b);
56060         b_conv.is_owned = ptr_is_owned(b);
56061         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56062         b_conv.is_owned = false;
56063         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
56064         return ret_conv;
56065 }
56066
56067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56068         LDKPayeePubKey this_obj_conv;
56069         this_obj_conv.inner = untag_ptr(this_obj);
56070         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56072         PayeePubKey_free(this_obj_conv);
56073 }
56074
56075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56076         LDKPayeePubKey this_ptr_conv;
56077         this_ptr_conv.inner = untag_ptr(this_ptr);
56078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56080         this_ptr_conv.is_owned = false;
56081         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
56083         return ret_arr;
56084 }
56085
56086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
56087         LDKPayeePubKey this_ptr_conv;
56088         this_ptr_conv.inner = untag_ptr(this_ptr);
56089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56091         this_ptr_conv.is_owned = false;
56092         LDKPublicKey val_ref;
56093         CHECK((*env)->GetArrayLength(env, val) == 33);
56094         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
56095         PayeePubKey_set_a(&this_ptr_conv, val_ref);
56096 }
56097
56098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
56099         LDKPublicKey a_arg_ref;
56100         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
56101         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
56102         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
56103         int64_t ret_ref = 0;
56104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56106         return ret_ref;
56107 }
56108
56109 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
56110         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
56111         int64_t ret_ref = 0;
56112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56114         return ret_ref;
56115 }
56116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56117         LDKPayeePubKey arg_conv;
56118         arg_conv.inner = untag_ptr(arg);
56119         arg_conv.is_owned = ptr_is_owned(arg);
56120         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56121         arg_conv.is_owned = false;
56122         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
56123         return ret_conv;
56124 }
56125
56126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56127         LDKPayeePubKey orig_conv;
56128         orig_conv.inner = untag_ptr(orig);
56129         orig_conv.is_owned = ptr_is_owned(orig);
56130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56131         orig_conv.is_owned = false;
56132         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
56133         int64_t ret_ref = 0;
56134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56136         return ret_ref;
56137 }
56138
56139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
56140         LDKPayeePubKey o_conv;
56141         o_conv.inner = untag_ptr(o);
56142         o_conv.is_owned = ptr_is_owned(o);
56143         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56144         o_conv.is_owned = false;
56145         int64_t ret_conv = PayeePubKey_hash(&o_conv);
56146         return ret_conv;
56147 }
56148
56149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56150         LDKPayeePubKey a_conv;
56151         a_conv.inner = untag_ptr(a);
56152         a_conv.is_owned = ptr_is_owned(a);
56153         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56154         a_conv.is_owned = false;
56155         LDKPayeePubKey b_conv;
56156         b_conv.inner = untag_ptr(b);
56157         b_conv.is_owned = ptr_is_owned(b);
56158         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56159         b_conv.is_owned = false;
56160         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
56161         return ret_conv;
56162 }
56163
56164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56165         LDKExpiryTime this_obj_conv;
56166         this_obj_conv.inner = untag_ptr(this_obj);
56167         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56169         ExpiryTime_free(this_obj_conv);
56170 }
56171
56172 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
56173         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
56174         int64_t ret_ref = 0;
56175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56177         return ret_ref;
56178 }
56179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56180         LDKExpiryTime arg_conv;
56181         arg_conv.inner = untag_ptr(arg);
56182         arg_conv.is_owned = ptr_is_owned(arg);
56183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56184         arg_conv.is_owned = false;
56185         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
56186         return ret_conv;
56187 }
56188
56189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56190         LDKExpiryTime orig_conv;
56191         orig_conv.inner = untag_ptr(orig);
56192         orig_conv.is_owned = ptr_is_owned(orig);
56193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56194         orig_conv.is_owned = false;
56195         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
56196         int64_t ret_ref = 0;
56197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56199         return ret_ref;
56200 }
56201
56202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
56203         LDKExpiryTime o_conv;
56204         o_conv.inner = untag_ptr(o);
56205         o_conv.is_owned = ptr_is_owned(o);
56206         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56207         o_conv.is_owned = false;
56208         int64_t ret_conv = ExpiryTime_hash(&o_conv);
56209         return ret_conv;
56210 }
56211
56212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56213         LDKExpiryTime a_conv;
56214         a_conv.inner = untag_ptr(a);
56215         a_conv.is_owned = ptr_is_owned(a);
56216         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56217         a_conv.is_owned = false;
56218         LDKExpiryTime b_conv;
56219         b_conv.inner = untag_ptr(b);
56220         b_conv.is_owned = ptr_is_owned(b);
56221         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56222         b_conv.is_owned = false;
56223         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
56224         return ret_conv;
56225 }
56226
56227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56228         LDKMinFinalCltvExpiryDelta this_obj_conv;
56229         this_obj_conv.inner = untag_ptr(this_obj);
56230         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56232         MinFinalCltvExpiryDelta_free(this_obj_conv);
56233 }
56234
56235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56236         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56237         this_ptr_conv.inner = untag_ptr(this_ptr);
56238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56240         this_ptr_conv.is_owned = false;
56241         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
56242         return ret_conv;
56243 }
56244
56245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
56246         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56247         this_ptr_conv.inner = untag_ptr(this_ptr);
56248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56250         this_ptr_conv.is_owned = false;
56251         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
56252 }
56253
56254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
56255         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
56256         int64_t ret_ref = 0;
56257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56259         return ret_ref;
56260 }
56261
56262 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
56263         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
56264         int64_t ret_ref = 0;
56265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56267         return ret_ref;
56268 }
56269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56270         LDKMinFinalCltvExpiryDelta arg_conv;
56271         arg_conv.inner = untag_ptr(arg);
56272         arg_conv.is_owned = ptr_is_owned(arg);
56273         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56274         arg_conv.is_owned = false;
56275         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
56276         return ret_conv;
56277 }
56278
56279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56280         LDKMinFinalCltvExpiryDelta orig_conv;
56281         orig_conv.inner = untag_ptr(orig);
56282         orig_conv.is_owned = ptr_is_owned(orig);
56283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56284         orig_conv.is_owned = false;
56285         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
56286         int64_t ret_ref = 0;
56287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56288         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56289         return ret_ref;
56290 }
56291
56292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1hash(JNIEnv *env, jclass clz, int64_t o) {
56293         LDKMinFinalCltvExpiryDelta o_conv;
56294         o_conv.inner = untag_ptr(o);
56295         o_conv.is_owned = ptr_is_owned(o);
56296         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56297         o_conv.is_owned = false;
56298         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
56299         return ret_conv;
56300 }
56301
56302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56303         LDKMinFinalCltvExpiryDelta a_conv;
56304         a_conv.inner = untag_ptr(a);
56305         a_conv.is_owned = ptr_is_owned(a);
56306         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56307         a_conv.is_owned = false;
56308         LDKMinFinalCltvExpiryDelta b_conv;
56309         b_conv.inner = untag_ptr(b);
56310         b_conv.is_owned = ptr_is_owned(b);
56311         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56312         b_conv.is_owned = false;
56313         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
56314         return ret_conv;
56315 }
56316
56317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
56318         if (!ptr_is_owned(this_ptr)) return;
56319         void* this_ptr_ptr = untag_ptr(this_ptr);
56320         CHECK_ACCESS(this_ptr_ptr);
56321         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
56322         FREE(untag_ptr(this_ptr));
56323         Fallback_free(this_ptr_conv);
56324 }
56325
56326 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
56327         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56328         *ret_copy = Fallback_clone(arg);
56329         int64_t ret_ref = tag_ptr(ret_copy, true);
56330         return ret_ref;
56331 }
56332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56333         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
56334         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
56335         return ret_conv;
56336 }
56337
56338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56339         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
56340         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56341         *ret_copy = Fallback_clone(orig_conv);
56342         int64_t ret_ref = tag_ptr(ret_copy, true);
56343         return ret_ref;
56344 }
56345
56346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
56347         
56348         LDKCVec_u8Z program_ref;
56349         program_ref.datalen = (*env)->GetArrayLength(env, program);
56350         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
56351         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
56352         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56353         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
56354         int64_t ret_ref = tag_ptr(ret_copy, true);
56355         return ret_ref;
56356 }
56357
56358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56359         LDKTwentyBytes a_ref;
56360         CHECK((*env)->GetArrayLength(env, a) == 20);
56361         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56362         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56363         *ret_copy = Fallback_pub_key_hash(a_ref);
56364         int64_t ret_ref = tag_ptr(ret_copy, true);
56365         return ret_ref;
56366 }
56367
56368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56369         LDKTwentyBytes a_ref;
56370         CHECK((*env)->GetArrayLength(env, a) == 20);
56371         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56372         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56373         *ret_copy = Fallback_script_hash(a_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_1hash(JNIEnv *env, jclass clz, int64_t o) {
56379         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
56380         int64_t ret_conv = Fallback_hash(o_conv);
56381         return ret_conv;
56382 }
56383
56384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56385         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
56386         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
56387         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
56388         return ret_conv;
56389 }
56390
56391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56392         LDKInvoiceSignature this_obj_conv;
56393         this_obj_conv.inner = untag_ptr(this_obj);
56394         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56396         InvoiceSignature_free(this_obj_conv);
56397 }
56398
56399 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
56400         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
56401         int64_t ret_ref = 0;
56402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56404         return ret_ref;
56405 }
56406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56407         LDKInvoiceSignature arg_conv;
56408         arg_conv.inner = untag_ptr(arg);
56409         arg_conv.is_owned = ptr_is_owned(arg);
56410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56411         arg_conv.is_owned = false;
56412         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
56413         return ret_conv;
56414 }
56415
56416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56417         LDKInvoiceSignature orig_conv;
56418         orig_conv.inner = untag_ptr(orig);
56419         orig_conv.is_owned = ptr_is_owned(orig);
56420         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56421         orig_conv.is_owned = false;
56422         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
56423         int64_t ret_ref = 0;
56424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56426         return ret_ref;
56427 }
56428
56429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
56430         LDKInvoiceSignature o_conv;
56431         o_conv.inner = untag_ptr(o);
56432         o_conv.is_owned = ptr_is_owned(o);
56433         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56434         o_conv.is_owned = false;
56435         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
56436         return ret_conv;
56437 }
56438
56439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56440         LDKInvoiceSignature a_conv;
56441         a_conv.inner = untag_ptr(a);
56442         a_conv.is_owned = ptr_is_owned(a);
56443         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56444         a_conv.is_owned = false;
56445         LDKInvoiceSignature b_conv;
56446         b_conv.inner = untag_ptr(b);
56447         b_conv.is_owned = ptr_is_owned(b);
56448         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56449         b_conv.is_owned = false;
56450         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
56451         return ret_conv;
56452 }
56453
56454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56455         LDKPrivateRoute this_obj_conv;
56456         this_obj_conv.inner = untag_ptr(this_obj);
56457         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56459         PrivateRoute_free(this_obj_conv);
56460 }
56461
56462 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
56463         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
56464         int64_t ret_ref = 0;
56465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56467         return ret_ref;
56468 }
56469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56470         LDKPrivateRoute arg_conv;
56471         arg_conv.inner = untag_ptr(arg);
56472         arg_conv.is_owned = ptr_is_owned(arg);
56473         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56474         arg_conv.is_owned = false;
56475         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
56476         return ret_conv;
56477 }
56478
56479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56480         LDKPrivateRoute orig_conv;
56481         orig_conv.inner = untag_ptr(orig);
56482         orig_conv.is_owned = ptr_is_owned(orig);
56483         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56484         orig_conv.is_owned = false;
56485         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
56486         int64_t ret_ref = 0;
56487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56489         return ret_ref;
56490 }
56491
56492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
56493         LDKPrivateRoute o_conv;
56494         o_conv.inner = untag_ptr(o);
56495         o_conv.is_owned = ptr_is_owned(o);
56496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56497         o_conv.is_owned = false;
56498         int64_t ret_conv = PrivateRoute_hash(&o_conv);
56499         return ret_conv;
56500 }
56501
56502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56503         LDKPrivateRoute a_conv;
56504         a_conv.inner = untag_ptr(a);
56505         a_conv.is_owned = ptr_is_owned(a);
56506         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56507         a_conv.is_owned = false;
56508         LDKPrivateRoute b_conv;
56509         b_conv.inner = untag_ptr(b);
56510         b_conv.is_owned = ptr_is_owned(b);
56511         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56512         b_conv.is_owned = false;
56513         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
56514         return ret_conv;
56515 }
56516
56517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
56518         LDKSignedRawInvoice this_arg_conv;
56519         this_arg_conv.inner = untag_ptr(this_arg);
56520         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56522         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
56523         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
56524         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
56525         return tag_ptr(ret_conv, true);
56526 }
56527
56528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
56529         LDKSignedRawInvoice this_arg_conv;
56530         this_arg_conv.inner = untag_ptr(this_arg);
56531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56533         this_arg_conv.is_owned = false;
56534         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
56535         int64_t ret_ref = 0;
56536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56538         return ret_ref;
56539 }
56540
56541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56542         LDKSignedRawInvoice this_arg_conv;
56543         this_arg_conv.inner = untag_ptr(this_arg);
56544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56546         this_arg_conv.is_owned = false;
56547         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56548         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
56549         return ret_arr;
56550 }
56551
56552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56553         LDKSignedRawInvoice this_arg_conv;
56554         this_arg_conv.inner = untag_ptr(this_arg);
56555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56557         this_arg_conv.is_owned = false;
56558         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
56559         int64_t ret_ref = 0;
56560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56562         return ret_ref;
56563 }
56564
56565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56566         LDKSignedRawInvoice this_arg_conv;
56567         this_arg_conv.inner = untag_ptr(this_arg);
56568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56570         this_arg_conv.is_owned = false;
56571         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
56572         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
56573         return tag_ptr(ret_conv, true);
56574 }
56575
56576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56577         LDKSignedRawInvoice this_arg_conv;
56578         this_arg_conv.inner = untag_ptr(this_arg);
56579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56581         this_arg_conv.is_owned = false;
56582         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
56583         return ret_conv;
56584 }
56585
56586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56587         LDKRawInvoice this_arg_conv;
56588         this_arg_conv.inner = untag_ptr(this_arg);
56589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56591         this_arg_conv.is_owned = false;
56592         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
56594         return ret_arr;
56595 }
56596
56597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56598         LDKRawInvoice this_arg_conv;
56599         this_arg_conv.inner = untag_ptr(this_arg);
56600         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56602         this_arg_conv.is_owned = false;
56603         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
56604         int64_t ret_ref = 0;
56605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56607         return ret_ref;
56608 }
56609
56610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
56611         LDKRawInvoice this_arg_conv;
56612         this_arg_conv.inner = untag_ptr(this_arg);
56613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56615         this_arg_conv.is_owned = false;
56616         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
56617         int64_t ret_ref = 0;
56618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56620         return ret_ref;
56621 }
56622
56623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56624         LDKRawInvoice this_arg_conv;
56625         this_arg_conv.inner = untag_ptr(this_arg);
56626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56628         this_arg_conv.is_owned = false;
56629         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
56630         int64_t ret_ref = 0;
56631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56633         return ret_ref;
56634 }
56635
56636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56637         LDKRawInvoice this_arg_conv;
56638         this_arg_conv.inner = untag_ptr(this_arg);
56639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56641         this_arg_conv.is_owned = false;
56642         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
56643         int64_t ret_ref = 0;
56644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56646         return ret_ref;
56647 }
56648
56649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56650         LDKRawInvoice this_arg_conv;
56651         this_arg_conv.inner = untag_ptr(this_arg);
56652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56654         this_arg_conv.is_owned = false;
56655         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
56656         int64_t ret_ref = 0;
56657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56659         return ret_ref;
56660 }
56661
56662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
56663         LDKRawInvoice this_arg_conv;
56664         this_arg_conv.inner = untag_ptr(this_arg);
56665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56667         this_arg_conv.is_owned = false;
56668         LDKMinFinalCltvExpiryDelta ret_var = RawInvoice_min_final_cltv_expiry_delta(&this_arg_conv);
56669         int64_t ret_ref = 0;
56670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56672         return ret_ref;
56673 }
56674
56675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56676         LDKRawInvoice this_arg_conv;
56677         this_arg_conv.inner = untag_ptr(this_arg);
56678         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56680         this_arg_conv.is_owned = false;
56681         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
56683         return ret_arr;
56684 }
56685
56686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56687         LDKRawInvoice this_arg_conv;
56688         this_arg_conv.inner = untag_ptr(this_arg);
56689         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56691         this_arg_conv.is_owned = false;
56692         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56693         *ret_copy = RawInvoice_payment_metadata(&this_arg_conv);
56694         int64_t ret_ref = tag_ptr(ret_copy, true);
56695         return ret_ref;
56696 }
56697
56698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56699         LDKRawInvoice this_arg_conv;
56700         this_arg_conv.inner = untag_ptr(this_arg);
56701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56703         this_arg_conv.is_owned = false;
56704         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
56705         int64_t ret_ref = 0;
56706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56708         return ret_ref;
56709 }
56710
56711 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
56712         LDKRawInvoice this_arg_conv;
56713         this_arg_conv.inner = untag_ptr(this_arg);
56714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56716         this_arg_conv.is_owned = false;
56717         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
56718         int64_tArray ret_arr = NULL;
56719         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
56720         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
56721         for (size_t o = 0; o < ret_var.datalen; o++) {
56722                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
56723                 int64_t ret_conv_14_ref = 0;
56724                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
56725                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
56726                 ret_arr_ptr[o] = ret_conv_14_ref;
56727         }
56728         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
56729         FREE(ret_var.data);
56730         return ret_arr;
56731 }
56732
56733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
56734         LDKRawInvoice this_arg_conv;
56735         this_arg_conv.inner = untag_ptr(this_arg);
56736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56738         this_arg_conv.is_owned = false;
56739         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56740         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
56741         int64_t ret_ref = tag_ptr(ret_copy, true);
56742         return ret_ref;
56743 }
56744
56745 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
56746         LDKRawInvoice this_arg_conv;
56747         this_arg_conv.inner = untag_ptr(this_arg);
56748         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56750         this_arg_conv.is_owned = false;
56751         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
56752         return ret_conv;
56753 }
56754
56755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
56756         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56757         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
56758         return tag_ptr(ret_conv, true);
56759 }
56760
56761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
56762         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56763         *ret_conv = PositiveTimestamp_from_system_time(time);
56764         return tag_ptr(ret_conv, true);
56765 }
56766
56767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
56768         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56769         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
56770         return tag_ptr(ret_conv, true);
56771 }
56772
56773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56774         LDKPositiveTimestamp this_arg_conv;
56775         this_arg_conv.inner = untag_ptr(this_arg);
56776         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56778         this_arg_conv.is_owned = false;
56779         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
56780         return ret_conv;
56781 }
56782
56783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56784         LDKPositiveTimestamp this_arg_conv;
56785         this_arg_conv.inner = untag_ptr(this_arg);
56786         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56788         this_arg_conv.is_owned = false;
56789         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
56790         return ret_conv;
56791 }
56792
56793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(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_time(&this_arg_conv);
56800         return ret_conv;
56801 }
56802
56803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56804         LDKInvoice 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_signable_hash(&this_arg_conv).data);
56811         return ret_arr;
56812 }
56813
56814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
56815         LDKInvoice this_arg_conv;
56816         this_arg_conv.inner = untag_ptr(this_arg);
56817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56819         this_arg_conv = Invoice_clone(&this_arg_conv);
56820         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
56821         int64_t ret_ref = 0;
56822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56824         return ret_ref;
56825 }
56826
56827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56828         LDKInvoice this_arg_conv;
56829         this_arg_conv.inner = untag_ptr(this_arg);
56830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56832         this_arg_conv.is_owned = false;
56833         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
56834         *ret_conv = Invoice_check_signature(&this_arg_conv);
56835         return tag_ptr(ret_conv, true);
56836 }
56837
56838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
56839         LDKSignedRawInvoice signed_invoice_conv;
56840         signed_invoice_conv.inner = untag_ptr(signed_invoice);
56841         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
56842         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
56843         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
56844         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
56845         *ret_conv = Invoice_from_signed(signed_invoice_conv);
56846         return tag_ptr(ret_conv, true);
56847 }
56848
56849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56850         LDKInvoice this_arg_conv;
56851         this_arg_conv.inner = untag_ptr(this_arg);
56852         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56854         this_arg_conv.is_owned = false;
56855         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
56856         return ret_conv;
56857 }
56858
56859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56860         LDKInvoice this_arg_conv;
56861         this_arg_conv.inner = untag_ptr(this_arg);
56862         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56864         this_arg_conv.is_owned = false;
56865         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
56866         return ret_conv;
56867 }
56868
56869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
56877         return ret_arr;
56878 }
56879
56880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56881         LDKInvoice this_arg_conv;
56882         this_arg_conv.inner = untag_ptr(this_arg);
56883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56885         this_arg_conv.is_owned = false;
56886         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56887         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
56888         return ret_arr;
56889 }
56890
56891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56892         LDKInvoice this_arg_conv;
56893         this_arg_conv.inner = untag_ptr(this_arg);
56894         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56896         this_arg_conv.is_owned = false;
56897         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
56899         return ret_arr;
56900 }
56901
56902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56903         LDKInvoice this_arg_conv;
56904         this_arg_conv.inner = untag_ptr(this_arg);
56905         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56907         this_arg_conv.is_owned = false;
56908         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56909         *ret_copy = Invoice_payment_metadata(&this_arg_conv);
56910         int64_t ret_ref = tag_ptr(ret_copy, true);
56911         return ret_ref;
56912 }
56913
56914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56915         LDKInvoice this_arg_conv;
56916         this_arg_conv.inner = untag_ptr(this_arg);
56917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56919         this_arg_conv.is_owned = false;
56920         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
56921         int64_t ret_ref = 0;
56922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56924         return ret_ref;
56925 }
56926
56927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56928         LDKInvoice this_arg_conv;
56929         this_arg_conv.inner = untag_ptr(this_arg);
56930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56932         this_arg_conv.is_owned = false;
56933         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
56935         return ret_arr;
56936 }
56937
56938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expires_1at(JNIEnv *env, jclass clz, int64_t this_arg) {
56939         LDKInvoice this_arg_conv;
56940         this_arg_conv.inner = untag_ptr(this_arg);
56941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56943         this_arg_conv.is_owned = false;
56944         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
56945         *ret_copy = Invoice_expires_at(&this_arg_conv);
56946         int64_t ret_ref = tag_ptr(ret_copy, true);
56947         return ret_ref;
56948 }
56949
56950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56951         LDKInvoice this_arg_conv;
56952         this_arg_conv.inner = untag_ptr(this_arg);
56953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56955         this_arg_conv.is_owned = false;
56956         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
56957         return ret_conv;
56958 }
56959
56960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
56961         LDKInvoice this_arg_conv;
56962         this_arg_conv.inner = untag_ptr(this_arg);
56963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56965         this_arg_conv.is_owned = false;
56966         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
56967         return ret_conv;
56968 }
56969
56970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1until_1expiry(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_duration_until_expiry(&this_arg_conv);
56977         return ret_conv;
56978 }
56979
56980 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) {
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         int64_t ret_conv = Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
56987         return ret_conv;
56988 }
56989
56990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
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         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
56997         return ret_conv;
56998 }
56999
57000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
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_min_final_cltv_expiry_delta(&this_arg_conv);
57007         return ret_conv;
57008 }
57009
57010 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Invoice_1fallback_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
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         LDKCVec_AddressZ ret_var = Invoice_fallback_addresses(&this_arg_conv);
57017         jobjectArray ret_arr = NULL;
57018         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, String_clz, NULL);
57019         ;
57020         jstring *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57021         for (size_t i = 0; i < ret_var.datalen; i++) {
57022                 LDKStr ret_conv_8_str = ret_var.data[i];
57023                 jstring ret_conv_8_conv = str_ref_to_java(env, ret_conv_8_str.chars, ret_conv_8_str.len);
57024                 Str_free(ret_conv_8_str);
57025                 ret_arr_ptr[i] = ret_conv_8_conv;
57026         }
57027         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57028         FREE(ret_var.data);
57029         return ret_arr;
57030 }
57031
57032 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
57033         LDKInvoice this_arg_conv;
57034         this_arg_conv.inner = untag_ptr(this_arg);
57035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57037         this_arg_conv.is_owned = false;
57038         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
57039         int64_tArray ret_arr = NULL;
57040         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57041         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57042         for (size_t o = 0; o < ret_var.datalen; o++) {
57043                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
57044                 int64_t ret_conv_14_ref = 0;
57045                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
57046                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
57047                 ret_arr_ptr[o] = ret_conv_14_ref;
57048         }
57049         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57050         FREE(ret_var.data);
57051         return ret_arr;
57052 }
57053
57054 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
57055         LDKInvoice this_arg_conv;
57056         this_arg_conv.inner = untag_ptr(this_arg);
57057         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57059         this_arg_conv.is_owned = false;
57060         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
57061         int64_tArray ret_arr = NULL;
57062         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57063         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57064         for (size_t l = 0; l < ret_var.datalen; l++) {
57065                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
57066                 int64_t ret_conv_11_ref = 0;
57067                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
57068                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
57069                 ret_arr_ptr[l] = ret_conv_11_ref;
57070         }
57071         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57072         FREE(ret_var.data);
57073         return ret_arr;
57074 }
57075
57076 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
57077         LDKInvoice this_arg_conv;
57078         this_arg_conv.inner = untag_ptr(this_arg);
57079         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57081         this_arg_conv.is_owned = false;
57082         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
57083         return ret_conv;
57084 }
57085
57086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
57087         LDKInvoice this_arg_conv;
57088         this_arg_conv.inner = untag_ptr(this_arg);
57089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57091         this_arg_conv.is_owned = false;
57092         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57093         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
57094         int64_t ret_ref = tag_ptr(ret_copy, true);
57095         return ret_ref;
57096 }
57097
57098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
57099         LDKStr description_conv = java_to_owned_str(env, description);
57100         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
57101         *ret_conv = Description_new(description_conv);
57102         return tag_ptr(ret_conv, true);
57103 }
57104
57105 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57106         LDKDescription this_arg_conv;
57107         this_arg_conv.inner = untag_ptr(this_arg);
57108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57110         this_arg_conv = Description_clone(&this_arg_conv);
57111         LDKStr ret_str = Description_into_inner(this_arg_conv);
57112         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57113         Str_free(ret_str);
57114         return ret_conv;
57115 }
57116
57117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
57118         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
57119         int64_t ret_ref = 0;
57120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57122         return ret_ref;
57123 }
57124
57125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
57126         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
57127         int64_t ret_ref = 0;
57128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57129         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57130         return ret_ref;
57131 }
57132
57133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
57134         LDKExpiryTime this_arg_conv;
57135         this_arg_conv.inner = untag_ptr(this_arg);
57136         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57138         this_arg_conv.is_owned = false;
57139         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
57140         return ret_conv;
57141 }
57142
57143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
57144         LDKExpiryTime this_arg_conv;
57145         this_arg_conv.inner = untag_ptr(this_arg);
57146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57148         this_arg_conv.is_owned = false;
57149         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
57150         return ret_conv;
57151 }
57152
57153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
57154         LDKRouteHint hops_conv;
57155         hops_conv.inner = untag_ptr(hops);
57156         hops_conv.is_owned = ptr_is_owned(hops);
57157         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
57158         hops_conv = RouteHint_clone(&hops_conv);
57159         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
57160         *ret_conv = PrivateRoute_new(hops_conv);
57161         return tag_ptr(ret_conv, true);
57162 }
57163
57164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57165         LDKPrivateRoute this_arg_conv;
57166         this_arg_conv.inner = untag_ptr(this_arg);
57167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57169         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
57170         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
57171         int64_t ret_ref = 0;
57172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57174         return ret_ref;
57175 }
57176
57177 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57178         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
57179         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
57180         return ret_conv;
57181 }
57182
57183 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
57184         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
57185         return ret_conv;
57186 }
57187
57188 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
57189         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
57190         return ret_conv;
57191 }
57192
57193 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
57194         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
57195         return ret_conv;
57196 }
57197
57198 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
57199         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
57200         return ret_conv;
57201 }
57202
57203 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
57204         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
57205         return ret_conv;
57206 }
57207
57208 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1min_1final_1cltv_1expiry_1delta_1too_1short(JNIEnv *env, jclass clz) {
57209         jclass ret_conv = LDKCreationError_to_java(env, CreationError_min_final_cltv_expiry_delta_too_short());
57210         return ret_conv;
57211 }
57212
57213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57214         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
57215         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
57216         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
57217         return ret_conv;
57218 }
57219
57220 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57221         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
57222         LDKStr ret_str = CreationError_to_str(o_conv);
57223         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57224         Str_free(ret_str);
57225         return ret_conv;
57226 }
57227
57228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57229         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
57230         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
57231         return ret_conv;
57232 }
57233
57234 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
57235         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
57236         return ret_conv;
57237 }
57238
57239 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
57240         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
57241         return ret_conv;
57242 }
57243
57244 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
57245         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
57246         return ret_conv;
57247 }
57248
57249 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
57250         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
57251         return ret_conv;
57252 }
57253
57254 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
57255         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
57256         return ret_conv;
57257 }
57258
57259 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
57260         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
57261         return ret_conv;
57262 }
57263
57264 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
57265         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
57266         return ret_conv;
57267 }
57268
57269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
57270         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
57271         return ret_conv;
57272 }
57273
57274 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
57275         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
57276         return ret_conv;
57277 }
57278
57279 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
57280         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
57281         return ret_conv;
57282 }
57283
57284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57285         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
57286         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
57287         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
57288         return ret_conv;
57289 }
57290
57291 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57292         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
57293         LDKStr ret_str = SemanticError_to_str(o_conv);
57294         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57295         Str_free(ret_str);
57296         return ret_conv;
57297 }
57298
57299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57300         if (!ptr_is_owned(this_ptr)) return;
57301         void* this_ptr_ptr = untag_ptr(this_ptr);
57302         CHECK_ACCESS(this_ptr_ptr);
57303         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
57304         FREE(untag_ptr(this_ptr));
57305         SignOrCreationError_free(this_ptr_conv);
57306 }
57307
57308 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
57309         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57310         *ret_copy = SignOrCreationError_clone(arg);
57311         int64_t ret_ref = tag_ptr(ret_copy, true);
57312         return ret_ref;
57313 }
57314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57315         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
57316         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
57317         return ret_conv;
57318 }
57319
57320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57321         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
57322         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57323         *ret_copy = SignOrCreationError_clone(orig_conv);
57324         int64_t ret_ref = tag_ptr(ret_copy, true);
57325         return ret_ref;
57326 }
57327
57328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
57329         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57330         *ret_copy = SignOrCreationError_sign_error();
57331         int64_t ret_ref = tag_ptr(ret_copy, true);
57332         return ret_ref;
57333 }
57334
57335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
57336         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
57337         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57338         *ret_copy = SignOrCreationError_creation_error(a_conv);
57339         int64_t ret_ref = tag_ptr(ret_copy, true);
57340         return ret_ref;
57341 }
57342
57343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57344         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
57345         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
57346         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
57347         return ret_conv;
57348 }
57349
57350 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57351         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
57352         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
57353         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57354         Str_free(ret_str);
57355         return ret_conv;
57356 }
57357
57358 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) {
57359         LDKInvoice invoice_conv;
57360         invoice_conv.inner = untag_ptr(invoice);
57361         invoice_conv.is_owned = ptr_is_owned(invoice);
57362         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57363         invoice_conv.is_owned = false;
57364         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57365         CHECK_ACCESS(retry_strategy_ptr);
57366         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57367         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57368         LDKChannelManager channelmanager_conv;
57369         channelmanager_conv.inner = untag_ptr(channelmanager);
57370         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57371         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57372         channelmanager_conv.is_owned = false;
57373         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57374         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
57375         return tag_ptr(ret_conv, true);
57376 }
57377
57378 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) {
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         LDKThirtyTwoBytes payment_id_ref;
57385         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57386         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57387         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57388         CHECK_ACCESS(retry_strategy_ptr);
57389         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57390         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57391         LDKChannelManager channelmanager_conv;
57392         channelmanager_conv.inner = untag_ptr(channelmanager);
57393         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57394         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57395         channelmanager_conv.is_owned = false;
57396         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57397         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57398         return tag_ptr(ret_conv, true);
57399 }
57400
57401 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) {
57402         LDKInvoice invoice_conv;
57403         invoice_conv.inner = untag_ptr(invoice);
57404         invoice_conv.is_owned = ptr_is_owned(invoice);
57405         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57406         invoice_conv.is_owned = false;
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_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57417         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, 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_1with_1id(JNIEnv *env, jclass clz, int64_t invoice, int64_t amount_msats, int8_tArray payment_id, 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         LDKThirtyTwoBytes payment_id_ref;
57428         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57429         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57430         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57431         CHECK_ACCESS(retry_strategy_ptr);
57432         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57433         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57434         LDKChannelManager channelmanager_conv;
57435         channelmanager_conv.inner = untag_ptr(channelmanager);
57436         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57437         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57438         channelmanager_conv.is_owned = false;
57439         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57440         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57441         return tag_ptr(ret_conv, true);
57442 }
57443
57444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57445         if (!ptr_is_owned(this_ptr)) return;
57446         void* this_ptr_ptr = untag_ptr(this_ptr);
57447         CHECK_ACCESS(this_ptr_ptr);
57448         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
57449         FREE(untag_ptr(this_ptr));
57450         PaymentError_free(this_ptr_conv);
57451 }
57452
57453 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
57454         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57455         *ret_copy = PaymentError_clone(arg);
57456         int64_t ret_ref = tag_ptr(ret_copy, true);
57457         return ret_ref;
57458 }
57459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57460         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
57461         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
57462         return ret_conv;
57463 }
57464
57465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57466         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
57467         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57468         *ret_copy = PaymentError_clone(orig_conv);
57469         int64_t ret_ref = tag_ptr(ret_copy, true);
57470         return ret_ref;
57471 }
57472
57473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
57474         LDKStr a_conv = java_to_owned_str(env, a);
57475         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57476         *ret_copy = PaymentError_invoice(a_conv);
57477         int64_t ret_ref = tag_ptr(ret_copy, true);
57478         return ret_ref;
57479 }
57480
57481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, jclass a) {
57482         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_java(env, a);
57483         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57484         *ret_copy = PaymentError_sending(a_conv);
57485         int64_t ret_ref = tag_ptr(ret_copy, true);
57486         return ret_ref;
57487 }
57488
57489 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) {
57490         void* amt_msat_ptr = untag_ptr(amt_msat);
57491         CHECK_ACCESS(amt_msat_ptr);
57492         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57493         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57494         LDKThirtyTwoBytes payment_hash_ref;
57495         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57496         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57497         LDKStr description_conv = java_to_owned_str(env, description);
57498         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57499         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57500         if (phantom_route_hints_constr.datalen > 0)
57501                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57502         else
57503                 phantom_route_hints_constr.data = NULL;
57504         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57505         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57506                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57507                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57508                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57509                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57510                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57511                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57512                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57513         }
57514         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57515         void* entropy_source_ptr = untag_ptr(entropy_source);
57516         CHECK_ACCESS(entropy_source_ptr);
57517         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57518         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57519                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57520                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57521         }
57522         void* node_signer_ptr = untag_ptr(node_signer);
57523         CHECK_ACCESS(node_signer_ptr);
57524         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57525         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57527                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57528         }
57529         void* logger_ptr = untag_ptr(logger);
57530         CHECK_ACCESS(logger_ptr);
57531         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57532         if (logger_conv.free == LDKLogger_JCalls_free) {
57533                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57534                 LDKLogger_JCalls_cloned(&logger_conv);
57535         }
57536         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57537         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57538         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57539         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57540         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57541         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57542         *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);
57543         return tag_ptr(ret_conv, true);
57544 }
57545
57546 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) {
57547         void* amt_msat_ptr = untag_ptr(amt_msat);
57548         CHECK_ACCESS(amt_msat_ptr);
57549         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57550         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57551         LDKThirtyTwoBytes payment_hash_ref;
57552         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57553         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57554         LDKSha256 description_hash_conv;
57555         description_hash_conv.inner = untag_ptr(description_hash);
57556         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57557         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57558         description_hash_conv = Sha256_clone(&description_hash_conv);
57559         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57560         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57561         if (phantom_route_hints_constr.datalen > 0)
57562                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57563         else
57564                 phantom_route_hints_constr.data = NULL;
57565         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57566         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57567                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57568                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57569                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57570                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57571                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57572                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57573                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57574         }
57575         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57576         void* entropy_source_ptr = untag_ptr(entropy_source);
57577         CHECK_ACCESS(entropy_source_ptr);
57578         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57579         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57581                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57582         }
57583         void* node_signer_ptr = untag_ptr(node_signer);
57584         CHECK_ACCESS(node_signer_ptr);
57585         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57586         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57587                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57588                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57589         }
57590         void* logger_ptr = untag_ptr(logger);
57591         CHECK_ACCESS(logger_ptr);
57592         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57593         if (logger_conv.free == LDKLogger_JCalls_free) {
57594                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57595                 LDKLogger_JCalls_cloned(&logger_conv);
57596         }
57597         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57598         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57599         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57600         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57601         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57602         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57603         *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);
57604         return tag_ptr(ret_conv, true);
57605 }
57606
57607 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) {
57608         LDKChannelManager channelmanager_conv;
57609         channelmanager_conv.inner = untag_ptr(channelmanager);
57610         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57611         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57612         channelmanager_conv.is_owned = false;
57613         void* node_signer_ptr = untag_ptr(node_signer);
57614         CHECK_ACCESS(node_signer_ptr);
57615         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57616         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57617                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57618                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57619         }
57620         void* logger_ptr = untag_ptr(logger);
57621         CHECK_ACCESS(logger_ptr);
57622         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57623         if (logger_conv.free == LDKLogger_JCalls_free) {
57624                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57625                 LDKLogger_JCalls_cloned(&logger_conv);
57626         }
57627         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57628         void* amt_msat_ptr = untag_ptr(amt_msat);
57629         CHECK_ACCESS(amt_msat_ptr);
57630         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57631         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57632         LDKStr description_conv = java_to_owned_str(env, description);
57633         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57634         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57635         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57636         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57637         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57638         *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);
57639         return tag_ptr(ret_conv, true);
57640 }
57641
57642 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) {
57643         LDKChannelManager channelmanager_conv;
57644         channelmanager_conv.inner = untag_ptr(channelmanager);
57645         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57646         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57647         channelmanager_conv.is_owned = false;
57648         void* node_signer_ptr = untag_ptr(node_signer);
57649         CHECK_ACCESS(node_signer_ptr);
57650         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57651         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57653                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57654         }
57655         void* logger_ptr = untag_ptr(logger);
57656         CHECK_ACCESS(logger_ptr);
57657         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57658         if (logger_conv.free == LDKLogger_JCalls_free) {
57659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57660                 LDKLogger_JCalls_cloned(&logger_conv);
57661         }
57662         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57663         void* amt_msat_ptr = untag_ptr(amt_msat);
57664         CHECK_ACCESS(amt_msat_ptr);
57665         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57666         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57667         LDKSha256 description_hash_conv;
57668         description_hash_conv.inner = untag_ptr(description_hash);
57669         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57670         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57671         description_hash_conv = Sha256_clone(&description_hash_conv);
57672         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57673         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57674         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57675         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57676         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57677         *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);
57678         return tag_ptr(ret_conv, true);
57679 }
57680
57681 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) {
57682         LDKChannelManager channelmanager_conv;
57683         channelmanager_conv.inner = untag_ptr(channelmanager);
57684         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57685         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57686         channelmanager_conv.is_owned = false;
57687         void* node_signer_ptr = untag_ptr(node_signer);
57688         CHECK_ACCESS(node_signer_ptr);
57689         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57690         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57691                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57692                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57693         }
57694         void* logger_ptr = untag_ptr(logger);
57695         CHECK_ACCESS(logger_ptr);
57696         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57697         if (logger_conv.free == LDKLogger_JCalls_free) {
57698                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57699                 LDKLogger_JCalls_cloned(&logger_conv);
57700         }
57701         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57702         void* amt_msat_ptr = untag_ptr(amt_msat);
57703         CHECK_ACCESS(amt_msat_ptr);
57704         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57705         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57706         LDKSha256 description_hash_conv;
57707         description_hash_conv.inner = untag_ptr(description_hash);
57708         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57709         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57710         description_hash_conv = Sha256_clone(&description_hash_conv);
57711         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57712         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57713         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57714         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57715         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57716         *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);
57717         return tag_ptr(ret_conv, true);
57718 }
57719
57720 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) {
57721         LDKChannelManager channelmanager_conv;
57722         channelmanager_conv.inner = untag_ptr(channelmanager);
57723         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57724         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57725         channelmanager_conv.is_owned = false;
57726         void* node_signer_ptr = untag_ptr(node_signer);
57727         CHECK_ACCESS(node_signer_ptr);
57728         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57729         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57730                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57731                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57732         }
57733         void* logger_ptr = untag_ptr(logger);
57734         CHECK_ACCESS(logger_ptr);
57735         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57736         if (logger_conv.free == LDKLogger_JCalls_free) {
57737                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57738                 LDKLogger_JCalls_cloned(&logger_conv);
57739         }
57740         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57741         void* amt_msat_ptr = untag_ptr(amt_msat);
57742         CHECK_ACCESS(amt_msat_ptr);
57743         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57744         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57745         LDKStr description_conv = java_to_owned_str(env, description);
57746         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57747         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57748         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57749         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57750         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57751         *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);
57752         return tag_ptr(ret_conv, true);
57753 }
57754
57755 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) {
57756         LDKChannelManager channelmanager_conv;
57757         channelmanager_conv.inner = untag_ptr(channelmanager);
57758         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57759         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57760         channelmanager_conv.is_owned = false;
57761         void* node_signer_ptr = untag_ptr(node_signer);
57762         CHECK_ACCESS(node_signer_ptr);
57763         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57764         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57765                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57766                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57767         }
57768         void* logger_ptr = untag_ptr(logger);
57769         CHECK_ACCESS(logger_ptr);
57770         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57771         if (logger_conv.free == LDKLogger_JCalls_free) {
57772                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57773                 LDKLogger_JCalls_cloned(&logger_conv);
57774         }
57775         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57776         void* amt_msat_ptr = untag_ptr(amt_msat);
57777         CHECK_ACCESS(amt_msat_ptr);
57778         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57779         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57780         LDKStr description_conv = java_to_owned_str(env, description);
57781         LDKThirtyTwoBytes payment_hash_ref;
57782         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57783         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57784         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57785         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57786         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57787         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57788         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57789         *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);
57790         return tag_ptr(ret_conv, true);
57791 }
57792
57793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57794         LDKStr s_conv = java_to_owned_str(env, s);
57795         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
57796         *ret_conv = SiPrefix_from_str(s_conv);
57797         return tag_ptr(ret_conv, true);
57798 }
57799
57800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57801         LDKStr s_conv = java_to_owned_str(env, s);
57802         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
57803         *ret_conv = Invoice_from_str(s_conv);
57804         return tag_ptr(ret_conv, true);
57805 }
57806
57807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57808         LDKStr s_conv = java_to_owned_str(env, s);
57809         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
57810         *ret_conv = SignedRawInvoice_from_str(s_conv);
57811         return tag_ptr(ret_conv, true);
57812 }
57813
57814 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57815         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
57816         LDKStr ret_str = ParseError_to_str(o_conv);
57817         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57818         Str_free(ret_str);
57819         return ret_conv;
57820 }
57821
57822 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57823         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
57824         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
57825         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57826         Str_free(ret_str);
57827         return ret_conv;
57828 }
57829
57830 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57831         LDKInvoice o_conv;
57832         o_conv.inner = untag_ptr(o);
57833         o_conv.is_owned = ptr_is_owned(o);
57834         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57835         o_conv.is_owned = false;
57836         LDKStr ret_str = Invoice_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_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57843         LDKSignedRawInvoice o_conv;
57844         o_conv.inner = untag_ptr(o);
57845         o_conv.is_owned = ptr_is_owned(o);
57846         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57847         o_conv.is_owned = false;
57848         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
57849         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57850         Str_free(ret_str);
57851         return ret_conv;
57852 }
57853
57854 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57855         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
57856         LDKStr ret_str = Currency_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_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57863         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
57864         LDKStr ret_str = SiPrefix_to_str(o_conv);
57865         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57866         Str_free(ret_str);
57867         return ret_conv;
57868 }
57869
57870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
57871         LDKRapidGossipSync this_obj_conv;
57872         this_obj_conv.inner = untag_ptr(this_obj);
57873         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57875         RapidGossipSync_free(this_obj_conv);
57876 }
57877
57878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
57879         LDKNetworkGraph network_graph_conv;
57880         network_graph_conv.inner = untag_ptr(network_graph);
57881         network_graph_conv.is_owned = ptr_is_owned(network_graph);
57882         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
57883         network_graph_conv.is_owned = false;
57884         void* logger_ptr = untag_ptr(logger);
57885         CHECK_ACCESS(logger_ptr);
57886         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57887         if (logger_conv.free == LDKLogger_JCalls_free) {
57888                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57889                 LDKLogger_JCalls_cloned(&logger_conv);
57890         }
57891         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
57892         int64_t ret_ref = 0;
57893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57895         return ret_ref;
57896 }
57897
57898 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) {
57899         LDKRapidGossipSync this_arg_conv;
57900         this_arg_conv.inner = untag_ptr(this_arg);
57901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57903         this_arg_conv.is_owned = false;
57904         LDKu8slice update_data_ref;
57905         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
57906         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
57907         void* current_time_unix_ptr = untag_ptr(current_time_unix);
57908         CHECK_ACCESS(current_time_unix_ptr);
57909         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
57910         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
57911         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
57912         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
57913         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
57914         return tag_ptr(ret_conv, true);
57915 }
57916
57917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
57918         LDKRapidGossipSync this_arg_conv;
57919         this_arg_conv.inner = untag_ptr(this_arg);
57920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57922         this_arg_conv.is_owned = false;
57923         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
57924         return ret_conv;
57925 }
57926
57927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57928         if (!ptr_is_owned(this_ptr)) return;
57929         void* this_ptr_ptr = untag_ptr(this_ptr);
57930         CHECK_ACCESS(this_ptr_ptr);
57931         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
57932         FREE(untag_ptr(this_ptr));
57933         GraphSyncError_free(this_ptr_conv);
57934 }
57935
57936 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
57937         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57938         *ret_copy = GraphSyncError_clone(arg);
57939         int64_t ret_ref = tag_ptr(ret_copy, true);
57940         return ret_ref;
57941 }
57942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57943         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
57944         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
57945         return ret_conv;
57946 }
57947
57948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57949         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
57950         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57951         *ret_copy = GraphSyncError_clone(orig_conv);
57952         int64_t ret_ref = tag_ptr(ret_copy, true);
57953         return ret_ref;
57954 }
57955
57956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
57957         void* a_ptr = untag_ptr(a);
57958         CHECK_ACCESS(a_ptr);
57959         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
57960         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
57961         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57962         *ret_copy = GraphSyncError_decode_error(a_conv);
57963         int64_t ret_ref = tag_ptr(ret_copy, true);
57964         return ret_ref;
57965 }
57966
57967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
57968         LDKLightningError a_conv;
57969         a_conv.inner = untag_ptr(a);
57970         a_conv.is_owned = ptr_is_owned(a);
57971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57972         a_conv = LightningError_clone(&a_conv);
57973         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57974         *ret_copy = GraphSyncError_lightning_error(a_conv);
57975         int64_t ret_ref = tag_ptr(ret_copy, true);
57976         return ret_ref;
57977 }
57978